@@ -50,36 +50,35 @@ void* allocate(VM* vm, size_t size) {
52void* allocCon(VM* vm, int arity) {
52void* allocCon(VM* vm, int arity) {
53− Closure* cl = allocate(vm, sizeof(ClosureType) +
53+ Closure* cl = allocate(vm, sizeof(Closure) + sizeof(VAL)*arity);
54− sizeof(con) + sizeof(VAL)*arity);
55 cl -> ty = CON;
54 cl -> ty = CON;
56 if (arity == 0) {
55 if (arity == 0) {
57 cl -> info.c.args = NULL;
56 cl -> info.c.args = NULL;
59− cl -> info.c.args = (void*)((char*)cl + sizeof(ClosureType)
58+ cl -> info.c.args = (void*)((char*)cl + sizeof(Closure));
62 return (void*)cl;
60 return (void*)cl;
65VAL MKFLOAT(VM* vm, double val) {
63VAL MKFLOAT(VM* vm, double val) {
66− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(double));
64+ Closure* cl = allocate(vm, sizeof(Closure));
67 cl -> ty = FLOAT;
65 cl -> ty = FLOAT;
68 cl -> info.f = val;
66 cl -> info.f = val;
69 return cl;
67 return cl;
72VAL MKSTR(VM* vm, char* str) {
70VAL MKSTR(VM* vm, char* str) {
73− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(char*) +
71+ Closure* cl = allocate(vm, sizeof(Closure) + // Type) + sizeof(char*) +
74 sizeof(char)*strlen(str)+1);
72 sizeof(char)*strlen(str)+1);
75 cl -> ty = STRING;
73 cl -> ty = STRING;
76− cl -> info.str = (char*)cl + sizeof(ClosureType) + sizeof(char*);
74+ cl -> info.str = (char*)cl + sizeof(Closure);
77 strcpy(cl -> info.str, str);
76 strcpy(cl -> info.str, str);
78 return cl;
77 return cl;
81VAL MKPTR(VM* vm, void* ptr) {
80VAL MKPTR(VM* vm, void* ptr) {
82− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(void*));
81+ Closure* cl = allocate(vm, sizeof(Closure));
83 cl -> ty = PTR;
82 cl -> ty = PTR;
84 cl -> info.ptr = ptr;
83 cl -> info.ptr = ptr;
85 return cl;
84 return cl;
@@ -138,9 +137,9 @@ void dumpVal(VAL v) {
140VAL idris_castIntStr(VM* vm, VAL i) {
139VAL idris_castIntStr(VM* vm, VAL i) {
141− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(char*) + sizeof(char)*16);
140+ Closure* cl = allocate(vm, sizeof(Closure) + sizeof(char)*16);
142 cl -> ty = STRING;
141 cl -> ty = STRING;
143− cl -> info.str = (char*)cl + sizeof(ClosureType) + sizeof(char*);
142+ cl -> info.str = (char*)cl + sizeof(Closure);
144 sprintf(cl -> info.str, "%ld", GETINT(i));
143 sprintf(cl -> info.str, "%ld", GETINT(i));
145 return cl;
144 return cl;
@@ -152,9 +151,9 @@ VAL idris_castStrInt(VM* vm, VAL i) {
154VAL idris_castFloatStr(VM* vm, VAL i) {
153VAL idris_castFloatStr(VM* vm, VAL i) {
155− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(char*) + sizeof(char)*32);
154+ Closure* cl = allocate(vm, sizeof(Closure) + sizeof(char)*32);
156 cl -> ty = STRING;
155 cl -> ty = STRING;
157− cl -> info.str = (char*)cl + sizeof(ClosureType) + sizeof(char*);
156+ cl -> info.str = (char*)cl + sizeof(Closure);
158 sprintf(cl -> info.str, "%g", GETFLOAT(i));
157 sprintf(cl -> info.str, "%g", GETFLOAT(i));
159 return cl;
158 return cl;
@@ -166,10 +165,9 @@ VAL idris_castStrFloat(VM* vm, VAL i) {
166VAL idris_concat(VM* vm, VAL l, VAL r) {
165VAL idris_concat(VM* vm, VAL l, VAL r) {
167 char *ls = GETSTR(l);
166 char *ls = GETSTR(l);
168 char *rs = GETSTR(r);
167 char *rs = GETSTR(r);
169− Closure* cl = allocate(vm, sizeof(ClosureType) + sizeof(char*) +
168+ Closure* cl = allocate(vm, sizeof(Closure) + strlen(ls) + strlen(rs) + 1);
170− strlen(ls) + strlen(rs) + 1);
171 cl -> ty = STRING;
169 cl -> ty = STRING;
172− cl -> info.str = (char*)cl + sizeof(ClosureType) + sizeof(char*);
170+ cl -> info.str = (char*)cl + sizeof(Closure);
173 strcpy(cl -> info.str, ls);
171 strcpy(cl -> info.str, ls);
174 strcat(cl -> info.str, rs);
172 strcat(cl -> info.str, rs);
175 return cl;
173 return cl;