# HG changeset patch # User Mike Pavone # Date 1376045888 25200 # Node ID 282b8056b702b11fe479143dd924e7b402baf952 # Parent 833624457b81c4b879b6128bcf33013e5dd32535 Lambda bugfix and some improvments to the llMessage support diff -r 833624457b81 -r 282b8056b702 cbackend.js --- a/cbackend.js Fri Aug 09 01:37:09 2013 -0700 +++ b/cbackend.js Fri Aug 09 03:58:08 2013 -0700 @@ -267,6 +267,11 @@ var receiver = this.receiver ? this.receiver : this.args[0]; return receiver.toCTypeName() + ' *'; break; + case 'struct:': + case 'struct': + var receiver = this.receiver ? this.receiver : this.args[0]; + return 'struct ' + receiver.toCTypeName(); + break; default: throw new Error('invalid use of funcall expression where a C type name is expected'); } @@ -329,9 +334,17 @@ var args = this.args.slice(0, this.args.length); if (this.receiver) { if(this.args.length == 0) { - return this.receiver.toCLLExpr(vars) + '->' + this.name; + if (this.receiver instanceof symbol && this.receiver.name in vars && vars[this.receiver.name].substr(-1) != "*") { + return this.receiver.toCLLExpr(vars) + '.' + this.name; + } else { + return this.receiver.toCLLExpr(vars) + '->' + this.name; + } } else if (this.args.length == 1 && name[name.length-1] == '!') { - return this.receiver.toCLLExpr(vars) + '->' + this.name.substr(0, name.length-1) + ' = ' + args[0].toCLLExpr(vars); + if (this.receiver instanceof symbol && this.receiver.name in vars && vars[this.receiver.name].substr(-1) != "*") { + return this.receiver.toCLLExpr(vars) + '.' + this.name.substr(0, name.length-1) + ' = ' + args[0].toCLLExpr(vars); + } else { + return this.receiver.toCLLExpr(vars) + '->' + this.name.substr(0, name.length-1) + ' = ' + args[0].toCLLExpr(vars); + } } else { args.splice(0, 0, this.receiver); } @@ -570,6 +583,8 @@ vars: vars, lines: messages[i].args[2].toCLines(vars, true) }); + } else if(messages[i].name == 'includeSystemHeader:' && messages[i].args.length == 1) { + me.addInclude("<" + messages[i].args[0].val + ">"); } else { throw new Error('Only import and import:from calls allowed in object context. ' + messages[i].name + 'with ' + messages[i].args.length + ' arguments found instead.'); @@ -973,7 +988,7 @@ debugprint('//' + this.name, 'has envvar:', envvar, 'num vars closed over:', Object.keys(this.symbols.closedover).length); return 'make_lambda(' + envvar + ', (closure_func)' + this.name + ')'; } else { - toplevelcode += 'lambda ' + this.name + '_obj = {{&lambda_meta, NULL}, NULL, lambda_' + mynum + '};\n'; + toplevelcode += 'lambda ' + this.name + '_obj = {{&lambda_meta, NULL}, NULL, ' + this.name + '};\n'; return '((object *)&' + this.name + '_obj)'; } }