Mercurial > repos > tabletprog
comparison cbackend.js @ 267:d2b70cba661e
Warning cleanup
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 18 Jul 2014 00:14:22 -0700 |
parents | 75dc7161c1ca |
children | bb2b4613fdc8 |
comparison
equal
deleted
inserted
replaced
266:75dc7161c1ca | 267:d2b70cba661e |
---|---|
91 throw new Error('symbol ' + name + ' not found in ' + assignNames.join('<-')); | 91 throw new Error('symbol ' + name + ' not found in ' + assignNames.join('<-')); |
92 } | 92 } |
93 if (info.type == 'toplevel') { | 93 if (info.type == 'toplevel') { |
94 return toplevel.moduleVar(name); | 94 return toplevel.moduleVar(name); |
95 } else if (info.type == 'self' && info.def instanceof lambda) { | 95 } else if (info.type == 'self' && info.def instanceof lambda) { |
96 return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, ' + (new symbol('self', this.symbols)).toC() + ')'; | 96 return 'mcall(' + getMethodId(name) + '/* ' + name + ' */, 1, (object *)' + (new symbol('self', this.symbols)).toC() + ')'; |
97 } else if (info.type == 'parent' && info.def instanceof lambda) { | 97 } else if (info.type == 'parent' && info.def instanceof lambda) { |
98 var obj = (new symbol('self', this.symbols)).toC() + '->header.'; | 98 var obj = (new symbol('self', this.symbols)).toC() + '->header.'; |
99 for (var i = 0; i < info.depth; ++i) { | 99 for (var i = 0; i < info.depth; ++i) { |
100 obj += (i ? '->' : '') + 'parent'; | 100 obj += (i ? '->' : '') + 'parent'; |
101 } | 101 } |
447 } else { | 447 } else { |
448 var escaped = escapeCName(propname); | 448 var escaped = escapeCName(propname); |
449 this.addMessage(propname, { | 449 this.addMessage(propname, { |
450 vars: {}, | 450 vars: {}, |
451 lines: [ | 451 lines: [ |
452 'return self->' + escaped + ';' | 452 'return (object *)self->' + escaped + ';' |
453 ]}); | 453 ]}); |
454 this.addMessage(propname + '!', { | 454 this.addMessage(propname + '!', { |
455 vars: {}, | 455 vars: {}, |
456 lines: [ | 456 lines: [ |
457 'self->' + escaped + ' = va_arg(args, object *);', | 457 'self->' + escaped + ' = va_arg(args, object *);', |
1084 compiled.push(indent(js)); | 1084 compiled.push(indent(js)); |
1085 } | 1085 } |
1086 } | 1086 } |
1087 if (compiled.length) { | 1087 if (compiled.length) { |
1088 if (exprs[exprs.length - 1] instanceof assignment) { | 1088 if (exprs[exprs.length - 1] instanceof assignment) { |
1089 compiled.push('return ' + exprs[exprs.length - 1].symbol.toC() + ';'); | 1089 compiled.push('return (object *)' + exprs[exprs.length - 1].symbol.toC() + ';'); |
1090 } else { | 1090 } else { |
1091 compiled[compiled.length-1] = 'return (object *)(' + compiled[compiled.length-1] + ');'; | 1091 compiled[compiled.length-1] = 'return (object *)(' + compiled[compiled.length-1] + ');'; |
1092 } | 1092 } |
1093 } | 1093 } |
1094 exprs = compiled; | 1094 exprs = compiled; |
1203 if (existing.type == 'local' && !existing.isdeclared) { | 1203 if (existing.type == 'local' && !existing.isdeclared) { |
1204 prefix = 'object *'; | 1204 prefix = 'object *'; |
1205 this.symbols.declareVar(this.symbol.name); | 1205 this.symbols.declareVar(this.symbol.name); |
1206 debugprint('//declared var', this.symbol.name); | 1206 debugprint('//declared var', this.symbol.name); |
1207 } | 1207 } |
1208 return prefix + this.symbol.toC() + ' = ' + val; | 1208 var cast = ''; |
1209 if (this.symbol.name == 'self') { | |
1210 //ugly hack alert | |
1211 cast = '(void *)'; | |
1212 } else { | |
1213 cast = '(object *)'; | |
1214 } | |
1215 return prefix + this.symbol.toC() + ' = ' + cast + val; | |
1209 }; | 1216 }; |
1210 assignment.prototype.toCObject = function(cobj) { | 1217 assignment.prototype.toCObject = function(cobj) { |
1211 debugprint('//message definition', this.symbol.name); | 1218 debugprint('//message definition', this.symbol.name); |
1212 assignNames.push('#' + this.symbol.name); | 1219 assignNames.push('#' + this.symbol.name); |
1213 if (this.expression.toCObject) { | 1220 if (this.expression.toCObject) { |