changeset 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 5e34563f90ae
children 6a1a716bb8c6
files types.js
diffstat 1 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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();