Mercurial > repos > tabletprog
comparison types.js @ 129:09b65b364927
Some old changes to the WIP type checker
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 06 Aug 2013 00:17:44 -0700 |
parents | 182c311a9fed |
children |
comparison
equal
deleted
inserted
replaced
128:5e34563f90ae | 129:09b65b364927 |
---|---|
367 } | 367 } |
368 }, | 368 }, |
369 get messages() { | 369 get messages() { |
370 this.lazyinit(); | 370 this.lazyinit(); |
371 return this.type.messages; | 371 return this.type.messages; |
372 } | |
373 }; | |
374 | |
375 object.prototype.toType = function(parent) { | |
376 var me = new objecttype(); | |
377 for (var i in this.messages) { | |
378 this.messages[i].toObjectType(me); | |
379 } | |
380 return me; | |
381 }; | |
382 | |
383 lambda.prototype.toType = function(parent) { | |
384 var me = new lambdatype(); | |
385 for (var i in this.args) { | |
386 me.addParam(this.args[i].cleanName()); | |
387 } | |
388 for (var i in this.expressions) { | |
389 this.expressions[i].toType(me); | |
390 } | |
391 return me; | |
392 }; | |
393 | |
394 funcall.prototype.toType = function(parent) { | |
395 var name = this.name[this.name.length-1] == ':' ? this.name.substr(0, this.name.length-1) : this.name; | |
396 switch(name) | |
397 { | |
398 case 'typeParam': | |
399 break; | |
400 case 'isa': | |
401 break; | |
402 }; | |
403 | |
404 assignment.prototype.toObjectType = function(parent) { | |
405 if (this.expression.instanceof lambda) { | |
406 parent.addMessage(this.symbol.name, this.expression.toType(parent)); | |
407 } else { | |
408 var valtype = this.expression.toType(parent); | |
409 var getter = new lambdatype(); | |
410 getter.returntype = valtype; | |
411 var setter = new lambdatype(); | |
412 setter.addParam('val'); | |
413 setter.paramType('val', valtype); | |
414 setter.returntype = parent; | |
415 parent.addMessage(this.symbol.name, setter); | |
372 } | 416 } |
373 }; | 417 }; |
374 | 418 |
375 function typetest() | 419 function typetest() |
376 { | 420 { |