comparison compiler.js @ 273:0dc7322590da

Make import:from actually work. Fix some macro bugs. Add a cpointer primitive type for storing an opaque pointer to a C object.
author Michael Pavone <pavone@retrodev.com>
date Sun, 20 Jul 2014 00:12:43 -0700
parents d6a4c9e7716e
children d4df33596e7d
comparison
equal deleted inserted replaced
272:bb2b4613fdc8 273:0dc7322590da
378 if ((this.args[0] instanceof lambda) || (this.args[0] instanceof object) || (this.args[0] instanceof symbol)) { 378 if ((this.args[0] instanceof lambda) || (this.args[0] instanceof object) || (this.args[0] instanceof symbol)) {
379 return; 379 return;
380 } else { 380 } else {
381 throw new Error("Unexpected AST type for foreign:"); 381 throw new Error("Unexpected AST type for foreign:");
382 } 382 }
383 } else if (this.name == 'import:from:' && symbols instanceof osymbols && this.args.length == 2) {
384 each(this.args[0].val, function(i, el) {
385 if (!(el instanceof symbol)) {
386 throw new Error('Names in import:from statement must be symbols');
387 }
388 symbols.defineMsg(el.name, new lambda([], []));
389 });
383 } else if (this.name == 'llProperty:withType:') { 390 } else if (this.name == 'llProperty:withType:') {
384 if (this.args[0] instanceof symbol) { 391 if (this.args[0] instanceof symbol) {
385 if ((this.args[1] instanceof symbol) || (this.args[1] instanceof funcall)) { 392 if ((this.args[1] instanceof symbol) || (this.args[1] instanceof funcall)) {
386 symbols.defineLLProperty(this.args[0] instanceof symbol ? this.args[0].name : this.args[0].val); 393 symbols.defineLLProperty(this.args[0] instanceof symbol ? this.args[0].name : this.args[0].val);
387 return; 394 return;
389 throw new Error("Second argument to llProperty:withType: must be a symbol or funcall"); 396 throw new Error("Second argument to llProperty:withType: must be a symbol or funcall");
390 } 397 }
391 } else { 398 } else {
392 throw new Error("First argument to llProperty:withType: must be a symbol or string"); 399 throw new Error("First argument to llProperty:withType: must be a symbol or string");
393 } 400 }
394 } else if (this.name == 'llMessage:withVars:andCode:') { 401 } else if (this.name == 'llMessage:withVars:andCode:' && symbols instanceof osymbols) {
395 if (this.args[0] instanceof symbol || this.args[0] instanceof strlit) { 402 if (this.args[0] instanceof symbol || this.args[0] instanceof strlit) {
396 if (this.args[1] instanceof lambda) { 403 if (this.args[1] instanceof lambda) {
397 if (this.args[2] instanceof lambda) { 404 if (this.args[2] instanceof lambda) {
405
398 symbols.defineMsg(this.args[0].name, this.args[2]); 406 symbols.defineMsg(this.args[0].name, this.args[2]);
399 isll = true; 407 isll = true;
400 } else { 408 } else {
401 throw new Error("Third argument to llMessage:withVars:andCode: must be a lambda"); 409 throw new Error("Third argument to llMessage:withVars:andCode: must be a lambda");
402 } 410 }