# HG changeset patch # User Michael Pavone # Date 1405667662 25200 # Node ID d2b70cba661ebb55098af37b72826e80f93da438 # Parent 75dc7161c1ca52c2018d8d0e8a9935fe36823879 Warning cleanup diff -r 75dc7161c1ca -r d2b70cba661e cbackend.js --- a/cbackend.js Thu Jul 17 23:57:41 2014 -0700 +++ b/cbackend.js Fri Jul 18 00:14:22 2014 -0700 @@ -93,7 +93,7 @@ if (info.type == 'toplevel') { return toplevel.moduleVar(name); } else if (info.type == 'self' && info.def instanceof lambda) { - return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, ' + (new symbol('self', this.symbols)).toC() + ')'; + return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, (object *)' + (new symbol('self', this.symbols)).toC() + ')'; } else if (info.type == 'parent' && info.def instanceof lambda) { var obj = (new symbol('self', this.symbols)).toC() + '->header.'; for (var i = 0; i < info.depth; ++i) { @@ -449,7 +449,7 @@ this.addMessage(propname, { vars: {}, lines: [ - 'return self->' + escaped + ';' + 'return (object *)self->' + escaped + ';' ]}); this.addMessage(propname + '!', { vars: {}, @@ -1086,7 +1086,7 @@ } if (compiled.length) { if (exprs[exprs.length - 1] instanceof assignment) { - compiled.push('return ' + exprs[exprs.length - 1].symbol.toC() + ';'); + compiled.push('return (object *)' + exprs[exprs.length - 1].symbol.toC() + ';'); } else { compiled[compiled.length-1] = 'return (object *)(' + compiled[compiled.length-1] + ');'; } @@ -1205,7 +1205,14 @@ this.symbols.declareVar(this.symbol.name); debugprint('//declared var', this.symbol.name); } - return prefix + this.symbol.toC() + ' = ' + val; + var cast = ''; + if (this.symbol.name == 'self') { + //ugly hack alert + cast = '(void *)'; + } else { + cast = '(object *)'; + } + return prefix + this.symbol.toC() + ' = ' + cast + val; }; assignment.prototype.toCObject = function(cobj) { debugprint('//message definition', this.symbol.name); diff -r 75dc7161c1ca -r d2b70cba661e modules/string.tp --- a/modules/string.tp Thu Jul 17 23:57:41 2014 -0700 +++ b/modules/string.tp Fri Jul 18 00:14:22 2014 -0700 @@ -61,7 +61,7 @@ argb <- (string ptr) out <- (string ptr) } andCode: :argbo { - argb <- mcall: string 1 argbo + argb <- (mcall: string 1 argbo) castTo: (string ptr) out <- make_object: (addr_of: string_meta) NULL 0 out bytes!: bytes + (argb bytes) out len!: len + (argb len) @@ -173,7 +173,7 @@ i <- uint32_t notFound <- uint32_t } andCode: :oneedle :startpos :ifNotFound { - sneedle <- mcall: string 1 oneedle + sneedle <- (mcall: string 1 oneedle) castTo: (string ptr) i <- startpos num notFound <- 1 while: { notFound && i + (sneedle bytes) <= bytes} do: { diff -r 75dc7161c1ca -r d2b70cba661e runtime/object.c --- a/runtime/object.c Thu Jul 17 23:57:41 2014 -0700 +++ b/runtime/object.c Fri Jul 18 00:14:22 2014 -0700 @@ -4,7 +4,7 @@ #include #include -object * make_object(obj_meta * meta, void * parent, int num_props, ...) +void * make_object(obj_meta * meta, void * parent, int num_props, ...) { va_list args; object * newobj = GC_MALLOC(meta->size); diff -r 75dc7161c1ca -r d2b70cba661e runtime/object.h --- a/runtime/object.h Thu Jul 17 23:57:41 2014 -0700 +++ b/runtime/object.h Fri Jul 18 00:14:22 2014 -0700 @@ -37,7 +37,7 @@ object * mcall(uint32_t method_id, uint32_t num_args, object * self, ...); #define ccall(clos, num_args, ...) (((lambda *)clos)->func(((lambda *)clos)->env, num_args,##__VA_ARGS__)) -object * make_object(obj_meta * meta, void * parent, int num_props, ...); +void * make_object(obj_meta * meta, void * parent, int num_props, ...); object * make_lambda(void * env, closure_func func); object * make_array(uint32_t num_els, ...); object * make_list(uint32_t num_els, ...);