Hi,
well I guess this will be my allocation for today! :)
I'm getting this runtime error. I get the same error if it calls the
subscript function, which is a generic version of what the testit
function does. The testit function was an attempt to narrow the error down.
$ flx --force avl/array.flx
Info: resolving vtable for flx::rtl::con_tby linking to
__imp___ZTVN3flx3rtl5con_tE (auto-import)
B(1=53.1)
B(4=88.1)
B(5=23.1)
testit.[4]
in find[T]
Shape size error: allocator size = 4
Shape aNode size = 16
/usr/local/bin/flx: line 475: 1276 Aborted (core
dumped) env "PATH=/usr/local/lib/felix/felix-1.1.3_rc1/bin:$PATH"
/usr/local/lib/felix/felix-1.1.3_rc1/bin/flx_run.exe avl/array.dll
#import <flx.flxh>;
open List;
open C_hack;
open Avl;
open Double;
open VArray;
module VArray {
class vArray[T] {
var arr:avl[aNode[T]];
var dflt:T;
ctor(value:T) {
dflt = value;
arr = Nil[aNode[T]];
}
}
fun subscript[T](arr:vArray[T], idx:int):T = {
var ret:T;
ret = arr.dflt;
var z <- new aNode[T](idx, arr.dflt);
print$ f"subscriptB.[%d]\n" idx;
match find(arr.arr, z, cmp of (aNode[T]*aNode[T])) with
| None[T] => {
print_line "None";
ret = arr.dflt;
}
| Some ?x => {
print "Some ";
//pr_node(0, x);
ret = x.element;
}
endmatch;
return ret;
}
class aNode[T] {
var index:int;
var element:T;
ctor(idx:int, x:T) {
index = idx;
element = x;
}
}
fun cmp[T](x:aNode[T], y:aNode[T]) = {
return cmp(x.index, y.index);
}
proc adder[T](arr:vArray[T], i:int, x:T) {
var z <- new aNode[T](i, x);
arr.arr = insert(arr.arr, z, cmp of (aNode[T]*aNode[T]));
}
}
fun cmp(x:aNode[double], y:aNode[double]) = {
return cmp(x.index, y.index);
}
proc pr_node[T] (d:int, x:aNode[T]) {
print$ " " * d;
print$ f"B(%d)\n" (x.index);
}
proc pr_treeT[T](tree:avl[aNode[T]]) {
Avl::iter[aNode[T]] ((pr_node of (int*aNode[T])), tree);
}
proc pr_node (d:int, x:aNode[int]) {
print$ " " * d;
print$ f"B(%d.%d)\n" (x.index, x.element);
}
proc pr_node (d:int, x:aNode[double]) {
print$ " " * d;
print$ f"B(%d=%.1f)\n" (x.index, x.element);
}
proc pr_treeD(tree:avl[aNode[double]]) {
Avl::iter[aNode[double]] (pr_node of (int*aNode[double]), tree);
}
fun find[T] (tree : avl[T], y : T, cmp : T*T->int) : opt[T] = {
print "in find[T]\n";
return
match tree with
| Nil => None[T]
| Tree(?H, ?x, ?left, ?right) =>
if cmp(x, y) > 0 then
find(left, y, cmp)
elif cmp(x, y) < 0 then
find(right, y, cmp)
else
Some x
endif
endmatch
;
}
proc testit (arr:vArray[double], idx:int) {
var z <- new aNode[double](idx, arr.dflt);
print$ f"testit.[%d]\n" idx;
C_hack::ignore(find(arr.arr, z, cmp of (aNode[double]*aNode[double])));
}
proc flx_main() {
var ar <- new vArray[double](0.0);
adder(ar, 4, 88.1);
adder(ar, 5, 23.1);
adder(ar, 1, 53.1);
pr_treeD(ar.arr);
endl;
testit(ar, 4);
//var xx = ar.[4];
//print_line xx;
}
flx_main();
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language