Commit e2a72da9 authored by Laszlo Domoszlai's avatar Laszlo Domoszlai
Browse files

some print cases

parent 87e99838
...@@ -57,7 +57,7 @@ int main() ...@@ -57,7 +57,7 @@ int main()
// char* funstream = "160 F13 example.Start0 0 AF11 example.map2 VF11 example.incAF17 _predefined._Cons2 LI1 AF17 _predefined._Cons2 LI2 AF17 _predefined._Cons2 LI3 VF16 _predefined._Nil36 F11 example.inc1 1 AF3 add2 VA0 LI1 148 F11 example.map2 1 SVA0 2 C16 _predefined._NilVF16 _predefined._NilC17 _predefined._ConsAF17 _predefined._Cons2 AA1 1 VL0 AF11 example.map2 VA1 VL1 50 A2 17 _predefined._Cons2 0 16 _predefined._Nil0 0 "; // char* funstream = "160 F13 example.Start0 0 AF11 example.map2 VF11 example.incAF17 _predefined._Cons2 LI1 AF17 _predefined._Cons2 LI2 AF17 _predefined._Cons2 LI3 VF16 _predefined._Nil36 F11 example.inc1 1 AF3 add2 VA0 LI1 148 F11 example.map2 1 SVA0 2 C16 _predefined._NilVF16 _predefined._NilC17 _predefined._ConsAF17 _predefined._Cons2 AA1 1 VL0 AF11 example.map2 VA1 VL1 50 A2 17 _predefined._Cons2 0 16 _predefined._Nil0 0 ";
// [_predefined._Cons [2] [_predefined._Cons [3] [_predefined._Cons [4] [_predefined._Nil]]]] // [_predefined._Cons [2] [_predefined._Cons [3] [_predefined._Cons [4] [_predefined._Nil]]]]
char* funstream = "44 F13 example.Start0 0 AF11 example.fib1 LI35 119 F11 example.fib1 1 IAF2 lt2 VA0 LI2 LI1 AF3 add2 AF11 example.fib1 AF3 sub2 VA0 LI1 AF11 example.fib1 AF3 sub2 VA0 LI2 "; char* funstream = "43 F13 example.Start0 0 AF11 example.fib1 LI3 119 F11 example.fib1 1 IAF2 lt2 VA0 LI2 LI1 AF3 add2 AF11 example.fib1 AF3 sub2 VA0 LI1 AF11 example.fib1 AF3 sub2 VA0 LI2 ";
int nrfuns = parse(&funstream, strlen(funstream)); int nrfuns = parse(&funstream, strlen(funstream));
printf("Number of functions parsed: %d\n", nrfuns); printf("Number of functions parsed: %d\n", nrfuns);
......
...@@ -18,6 +18,9 @@ int printDesc(Desc* f) ...@@ -18,6 +18,9 @@ int printDesc(Desc* f)
case FT_SLICE: case FT_SLICE:
printDesc(((SliceEntry*) f)->forward_ptr); printDesc(((SliceEntry*) f)->forward_ptr);
return f->arity; return f->arity;
case FT_PRIM:
printf("%s", ((PrimEntry*) f)->name);
return f->arity;
case FT_FUN: case FT_FUN:
printf("%s", ((FunEntry*) f)->name); printf("%s", ((FunEntry*) f)->name);
return f->arity; return f->arity;
...@@ -150,8 +153,8 @@ void eval(Thunk* thunk) ...@@ -150,8 +153,8 @@ void eval(Thunk* thunk)
thunk = thunk->_forward_ptr; thunk = thunk->_forward_ptr;
} }
//print(thunk, false); print(thunk, false);
//printf("\n"); printf("\n");
switch(thunk->desc->type) switch(thunk->desc->type)
{ {
...@@ -207,9 +210,20 @@ void print(Thunk* thunk, bool force) ...@@ -207,9 +210,20 @@ void print(Thunk* thunk, bool force)
{ {
printf("%d", thunk->_int); printf("%d", thunk->_int);
} }
else if((FunEntry*) thunk->desc == __BOOL__)
{
if(thunk->_bool)
{
printf("True");
}
else
{
printf("False");
}
}
else else
{ {
printf("printDesc: unhandled BOXED LIT\n"); printf("print: unhandled BOXED LIT\n");
exit(-1); exit(-1);
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment