# HG changeset patch # User Mike Pavone # Date 1375773464 25200 # Node ID 09b65b364927ab4ba0d55e862e8a24accc3440d5 # Parent 5e34563f90ae18b545229c14f274092e2cca2d62 Some old changes to the WIP type checker diff -r 5e34563f90ae -r 09b65b364927 types.js --- a/types.js Tue Aug 06 00:17:22 2013 -0700 +++ b/types.js Tue Aug 06 00:17:44 2013 -0700 @@ -372,6 +372,50 @@ } }; +object.prototype.toType = function(parent) { + var me = new objecttype(); + for (var i in this.messages) { + this.messages[i].toObjectType(me); + } + return me; +}; + +lambda.prototype.toType = function(parent) { + var me = new lambdatype(); + for (var i in this.args) { + me.addParam(this.args[i].cleanName()); + } + for (var i in this.expressions) { + this.expressions[i].toType(me); + } + return me; +}; + +funcall.prototype.toType = function(parent) { + var name = this.name[this.name.length-1] == ':' ? this.name.substr(0, this.name.length-1) : this.name; + switch(name) + { + case 'typeParam': + break; + case 'isa': + break; +}; + +assignment.prototype.toObjectType = function(parent) { + if (this.expression.instanceof lambda) { + parent.addMessage(this.symbol.name, this.expression.toType(parent)); + } else { + var valtype = this.expression.toType(parent); + var getter = new lambdatype(); + getter.returntype = valtype; + var setter = new lambdatype(); + setter.addParam('val'); + setter.paramType('val', valtype); + setter.returntype = parent; + parent.addMessage(this.symbol.name, setter); + } +}; + function typetest() { var foo = new objecttype();