Browse Source

module.js -> Module.ob

Vladislav Folts 11 years ago
parent
commit
96fe598309
11 changed files with 312 additions and 133 deletions
  1. 2 2
      src/context.js
  2. 7 0
      src/js/JsString.js
  3. 120 0
      src/js/Module.js
  4. 24 14
      src/js/Procedure.js
  5. 1 0
      src/js/Types.js
  6. 0 90
      src/module.js
  7. 7 0
      src/ob/JsString.ob
  8. 124 0
      src/ob/Module.ob
  9. 25 25
      src/ob/Procedure.ob
  10. 1 1
      src/ob/Symbols.ob
  11. 1 1
      src/ob/Types.ob

+ 2 - 2
src/context.js

@@ -3,7 +3,7 @@
 var Cast = require("js/Cast.js");
 var Cast = require("js/Cast.js");
 var Code = require("js/Code.js");
 var Code = require("js/Code.js");
 var Errors = require("js/Errors.js");
 var Errors = require("js/Errors.js");
-var Module = require("module.js");
+var Module = require("js/Module.js");
 var op = require("js/Operator.js");
 var op = require("js/Operator.js");
 var Parser = require("parser.js");
 var Parser = require("parser.js");
 var Procedure = require("js/Procedure.js");
 var Procedure = require("js/Procedure.js");
@@ -1940,7 +1940,7 @@ exports.Context = Class.extend({
     rtl: function(){return this.__rtl;},
     rtl: function(){return this.__rtl;},
     findModule: function(name){
     findModule: function(name){
         if (name == "JS"){
         if (name == "JS"){
-            return new Module.JS();
+            return Module.makeJS();
         }
         }
         return this.__moduleResolver ? this.__moduleResolver(name) : undefined;
         return this.__moduleResolver ? this.__moduleResolver(name) : undefined;
     }
     }

+ 7 - 0
src/js/JsString.js

@@ -69,6 +69,12 @@ function concat(self/*Type*/, add/*Type*/){
 	result = self + add;
 	result = self + add;
 	return result;
 	return result;
 }
 }
+
+function eq(s1/*Type*/, s2/*Type*/){
+	var result = false;
+	result = s1 == s2;
+	return result;
+}
 exports.Type = Type;
 exports.Type = Type;
 exports.make = make;
 exports.make = make;
 exports.makeEmpty = makeEmpty;
 exports.makeEmpty = makeEmpty;
@@ -80,3 +86,4 @@ exports.indexOfFrom = indexOfFrom;
 exports.substr = substr;
 exports.substr = substr;
 exports.appendChar = appendChar;
 exports.appendChar = appendChar;
 exports.concat = concat;
 exports.concat = concat;
+exports.eq = eq;

+ 120 - 0
src/js/Module.js

@@ -0,0 +1,120 @@
+var RTL$ = require("rtl.js");
+var Code = require("js/Code.js");
+var Context = require("js/Context.js");
+var Errors = require("js/Errors.js");
+var JsArray = require("js/JsArray.js");
+var JsString = require("js/JsString.js");
+var Procedure = require("js/Procedure.js");
+var Symbols = require("js/Symbols.js");
+var Types = require("js/Types.js");
+var Type = Types.Module.extend({
+	init: function Type(){
+		Types.Module.prototype.init.call(this);
+	}
+});
+var AnyType = Types.StorageType.extend({
+	init: function AnyType(){
+		Types.StorageType.prototype.init.call(this);
+	}
+});
+var AnyTypeProc = Types.DefinedProcedure.extend({
+	init: function AnyTypeProc(){
+		Types.DefinedProcedure.prototype.init.call(this);
+	}
+});
+var JS = Type.extend({
+	init: function JS(){
+		Type.prototype.init.call(this);
+	}
+});
+var doProcId = null;var varTypeId = null;
+var any = null;
+var anyProc = new AnyTypeProc();
+var doProcSymbol = null;var varTypeSymbol = null;
+AnyType.prototype.description = function(){
+	return JsString.make("JS.var");
+}
+AnyType.prototype.initializer = function(cx/*Type*/){
+	return JsString.make("undefined");
+}
+AnyType.prototype.callGenerator = function(cx/*PType*/, id/*Type*/){
+	return Procedure.makeProcCallGenerator(cx, id, anyProc);
+}
+AnyType.prototype.findSymbol = function(id/*Type*/){
+	return any;
+}
+AnyTypeProc.prototype.args = function(){
+	return null;
+}
+AnyTypeProc.prototype.result = function(){
+	return any;
+}
+JS.prototype.findSymbol = function(id/*Type*/){
+	var result = null;
+	if (JsString.eq(id, doProcId)){
+		result = doProcSymbol;
+	}
+	else if (JsString.eq(id, varTypeId)){
+		result = varTypeSymbol;
+	}
+	else {
+		result = Symbols.makeSymbol(id, Types.makeProcedure(any));
+	}
+	return Symbols.makeFound(result, null);
+}
+
+function makeVarTypeSymbol(){
+	return Symbols.makeSymbol(varTypeId, Types.makeTypeId(any));
+}
+
+function makeDoProcSymbol(){
+	var Call = Procedure.StdCall.extend({
+		init: function Call(){
+			Procedure.StdCall.prototype.init.call(this);
+		}
+	});
+	var Proc = Procedure.Std.extend({
+		init: function Proc(){
+			Procedure.Std.prototype.init.call(this);
+		}
+	});
+	var description = null;
+	var call = null;
+	var proc = null;
+	Call.prototype.make = function(args/*Type*/, cx/*Type*/){
+		var arg = null;
+		var type = null;
+		arg = Procedure.checkSingleArgument(args, this);
+		type = arg.type();
+		if (!(type instanceof Types.String)){
+			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.make("string is expected as an argument of "), description), JsString.make(", got ")), type.description()));
+		}
+		return Code.makeSimpleExpression(Types.stringValue(RTL$.typeGuard(type, Types.String)), null);
+	}
+	Proc.prototype.description = function(){
+		return description;
+	}
+	description = JsString.make("JS predefined procedure 'do'");
+	call = new Call();
+	Procedure.initStdCall(call);
+	Procedure.hasArgumentWithCustomType(call);
+	proc = new Proc();
+	Procedure.initStd(JsString.makeEmpty(), call, proc);
+	return Procedure.makeSymbol(proc);
+}
+
+function makeJS(){
+	var result = null;
+	result = new JS();
+	Types.initModule(result, JsString.make("this"));
+	return result;
+}
+doProcId = JsString.make("do$");
+varTypeId = JsString.make("var$");
+any = new AnyType();
+doProcSymbol = makeDoProcSymbol();
+varTypeSymbol = makeVarTypeSymbol();
+exports.Type = Type;
+exports.AnyType = AnyType;
+exports.AnyTypeProc = AnyTypeProc;
+exports.makeJS = makeJS;

+ 24 - 14
src/js/Procedure.js

@@ -123,11 +123,15 @@ function checkArguments(actual/*Type*/, expected/*Type*/){
 	processArguments(actual, expected, null);
 	processArguments(actual, expected, null);
 }
 }
 
 
+function initStd(name/*Type*/, call/*PCall*/, result/*Std*/){
+	Types.initProcedure(result, name);
+	result.call = call;
+}
+
 function makeStd(name/*Type*/, call/*PCall*/){
 function makeStd(name/*Type*/, call/*PCall*/){
 	var result = null;
 	var result = null;
 	result = new Std();
 	result = new Std();
-	Types.initProcedure(result, name);
-	result.call = call;
+	initStd(name, call, result);
 	return result;
 	return result;
 }
 }
 CallGenerator.prototype.handleArgument = function(e/*PExpression*/){
 CallGenerator.prototype.handleArgument = function(e/*PExpression*/){
@@ -264,9 +268,9 @@ function hasVarArgumnetWithCustomType(call/*PStdCall*/){
 	JsArray.add(call.args, a);
 	JsArray.add(call.args, a);
 }
 }
 
 
-function checkSingleArgument(actual/*Type*/, expected/*Type*/){
-	RTL$.assert(JsArray.len(expected) == 1);
-	checkArguments(actual, expected);
+function checkSingleArgument(actual/*Type*/, call/*StdCall*/){
+	RTL$.assert(JsArray.len(call.args) == 1);
+	checkArguments(actual, call.args);
 	RTL$.assert(JsArray.len(actual) == 1);
 	RTL$.assert(JsArray.len(actual) == 1);
 	return nthArgument(actual, 0);
 	return nthArgument(actual, 0);
 }
 }
@@ -282,7 +286,7 @@ function makeNew(){
 		var arg = null;
 		var arg = null;
 		var argType = null;
 		var argType = null;
 		var baseType = null;
 		var baseType = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		argType = arg.type();
 		argType = arg.type();
 		if (!(argType instanceof Types.Pointer)){
 		if (!(argType instanceof Types.Pointer)){
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("POINTER variable expected, got '"), argType.description()), JsString.make("'")));
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("POINTER variable expected, got '"), argType.description()), JsString.make("'")));
@@ -309,7 +313,7 @@ function makeLen(){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
 		var argType = null;
 		var argType = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		argType = arg.type();
 		argType = arg.type();
 		if (!(argType instanceof Types.Array) && !(argType instanceof Types.String)){
 		if (!(argType instanceof Types.Array) && !(argType instanceof Types.String)){
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("ARRAY or string is expected as an argument of LEN, got '"), argType.description()), JsString.make("'")));
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("ARRAY or string is expected as an argument of LEN, got '"), argType.description()), JsString.make("'")));
@@ -333,7 +337,7 @@ function makeOdd(){
 		var arg = null;
 		var arg = null;
 		var code = null;
 		var code = null;
 		var constValue = null;
 		var constValue = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		code = Code.adjustPrecedence(arg, Precedence.bitAnd);
 		code = Code.adjustPrecedence(arg, Precedence.bitAnd);
 		constValue = arg.constValue();
 		constValue = arg.constValue();
 		if (constValue != null){
 		if (constValue != null){
@@ -357,7 +361,7 @@ function makeAssert(){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
 		var rtl = null;
 		var rtl = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		rtl = cx.rtl();
 		rtl = cx.rtl();
 		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.concat(rtl.assertId(), JsString.make("(")), arg.code()), JsString.make(")")), null);
 		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.concat(rtl.assertId(), JsString.make("(")), arg.code()), JsString.make(")")), null);
 	}
 	}
@@ -502,7 +506,7 @@ function makeAbs(){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
 		var argType = null;
 		var argType = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		argType = arg.type();
 		argType = arg.type();
 		if (!JsArray.contains(Types.numeric(), argType)){
 		if (!JsArray.contains(Types.numeric(), argType)){
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("type mismatch: expected numeric type, got '"), argType.description()), JsString.make("'")));
 			Errors.raise(JsString.concat(JsString.concat(JsString.make("type mismatch: expected numeric type, got '"), argType.description()), JsString.make("'")));
@@ -524,7 +528,7 @@ function makeFloor(){
 	var call = null;
 	var call = null;
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.make("Math.floor("), arg.code()), JsString.make(")")), Types.basic().integer);
 		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.make("Math.floor("), arg.code()), JsString.make(")")), Types.basic().integer);
 	}
 	}
 	call = new CallImpl();
 	call = new CallImpl();
@@ -543,7 +547,7 @@ function makeFlt(){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
 		var value = null;
 		var value = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		value = arg.constValue();
 		value = arg.constValue();
 		if (value != null){
 		if (value != null){
 			value = Code.makeRealConst(RTL$.typeGuard(value, Code.IntConst).value);
 			value = Code.makeRealConst(RTL$.typeGuard(value, Code.IntConst).value);
@@ -596,7 +600,7 @@ function makeOrd(){
 		var code = null;
 		var code = null;
 		var ch = 0;
 		var ch = 0;
 		var result = null;
 		var result = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		argType = arg.type();
 		argType = arg.type();
 		if (argType == Types.basic().ch || argType == Types.basic().set){
 		if (argType == Types.basic().ch || argType == Types.basic().set){
 			value = arg.constValue();
 			value = arg.constValue();
@@ -632,7 +636,7 @@ function makeChr(){
 	var call = null;
 	var call = null;
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
 		var arg = null;
 		var arg = null;
-		arg = checkSingleArgument(args, this.args);
+		arg = checkSingleArgument(args, this);
 		return Code.makeSimpleExpression(arg.code(), Types.basic().ch);
 		return Code.makeSimpleExpression(arg.code(), Types.basic().ch);
 	}
 	}
 	call = new CallImpl();
 	call = new CallImpl();
@@ -761,13 +765,19 @@ JsArray.add(predefined, makeChr());
 JsArray.add(predefined, makePack());
 JsArray.add(predefined, makePack());
 JsArray.add(predefined, makeUnpk());
 JsArray.add(predefined, makeUnpk());
 exports.Call = Call;
 exports.Call = Call;
+exports.StdCall = StdCall;
 exports.CallGenerator = CallGenerator;
 exports.CallGenerator = CallGenerator;
 exports.Type = Type;
 exports.Type = Type;
 exports.Std = Std;
 exports.Std = Std;
 exports.predefined = function(){return predefined;};
 exports.predefined = function(){return predefined;};
 exports.checkArgumentsCount = checkArgumentsCount;
 exports.checkArgumentsCount = checkArgumentsCount;
+exports.initStd = initStd;
 exports.makeCallGenerator = makeCallGenerator;
 exports.makeCallGenerator = makeCallGenerator;
 exports.makeProcCallGeneratorWithCustomArgs = makeProcCallGeneratorWithCustomArgs;
 exports.makeProcCallGeneratorWithCustomArgs = makeProcCallGeneratorWithCustomArgs;
 exports.makeArgumentsCode = makeArgumentsCode;
 exports.makeArgumentsCode = makeArgumentsCode;
 exports.makeProcCallGenerator = makeProcCallGenerator;
 exports.makeProcCallGenerator = makeProcCallGenerator;
+exports.makeSymbol = makeSymbol;
+exports.initStdCall = initStdCall;
+exports.hasArgumentWithCustomType = hasArgumentWithCustomType;
+exports.checkSingleArgument = checkSingleArgument;
 exports.make = make;
 exports.make = make;

+ 1 - 0
src/js/Types.js

@@ -580,6 +580,7 @@ nil = new Nil();
 exports.openArrayLength = openArrayLength;
 exports.openArrayLength = openArrayLength;
 exports.Id = Id;
 exports.Id = Id;
 exports.Type = Type;
 exports.Type = Type;
+exports.StorageType = StorageType;
 exports.TypeId = TypeId;
 exports.TypeId = TypeId;
 exports.ForwardTypeId = ForwardTypeId;
 exports.ForwardTypeId = ForwardTypeId;
 exports.Const = Const;
 exports.Const = Const;

+ 0 - 90
src/module.js

@@ -1,90 +0,0 @@
-"use strict";
-
-var Code = require("js/Code.js");
-var Errors = require("js/Errors.js");
-var Procedure = require("js/Procedure.js");
-var Symbol = require("js/Symbols.js");
-var Type = require("js/Types.js");
-
-var AnyTypeProc = Type.Procedure.extend({
-    init: function AnyTypeProc(){
-        Type.Procedure.prototype.init.call("PROCEDURE: JS.var");
-    },
-    result: function(){return any;},
-    args: function(){return undefined;}
-});
-
-var anyProc = new AnyTypeProc();
-
-var AnyType = Type.Type.extend({
-    init: function AnyType(){
-        Type.Type.prototype.init.call(this);
-    },
-    description: function(){return "JS.var";},
-    initializer: function(){return undefined;},
-    findSymbol: function(){return this;},
-    callGenerator: function(context, id){
-        return new Procedure.makeProcCallGenerator(context, id, anyProc);
-    }
-});
-
-var any = new AnyType();
-
-var doProcId = "do$";
-var varTypeId = "var$";
-
-var doProcSymbol = (function(){
-    var description = "JS predefined procedure 'do'";
-
-    var expectedArgs = [Type.makeProcedureArgument(undefined, false)];
-
-    var Call = Procedure.Call.extend({
-        init: function DoProcedureCall(){
-            Procedure.Call.prototype.init.call(this);
-        },
-        make: function(args, cx){
-            Procedure.checkArgumentsCount(args.length, expectedArgs.length);
-            var type = args[0].type();
-            if (!(type instanceof Type.String))
-                throw new Errors.Error(
-                    "string is expected as an argument of " + description
-                    + ", got " + type.description());
-            
-            return Code.makeExpression(Type.stringValue(type));
-        }
-    });
-
-    var call = new Call();
-    var ProcType = Type.Procedure.extend({
-        init: function(){
-            Type.Procedure.prototype.init.call(this);
-            Type.initProcedure(this, doProcId);
-        },
-        description: function(){return description;},
-        callGenerator: function(context){
-            return Procedure.makeCallGenerator(call, context);
-        }
-        });
-
-    return Symbol.makeSymbol(doProcId, new ProcType());
-})();
-
-var varTypeSymbol = function(){
-    return Symbol.makeSymbol(varTypeId, Type.makeTypeId(any));
-}();
-
-var JSModule = Type.Module.extend({
-    init: function Module$JSModule(){
-        Type.Module.prototype.init.call(this);
-        Type.initModule(this, "this");
-    },
-    findSymbol: function(id){
-        return Symbol.makeFound(
-            id == doProcId ? doProcSymbol
-          : id == varTypeId ? varTypeSymbol
-          : Symbol.makeSymbol(id, any));
-    }
-});
-
-exports.AnyType = AnyType;
-exports.JS = JSModule;

+ 7 - 0
src/ob/JsString.ob

@@ -82,4 +82,11 @@ BEGIN
     RETURN result
     RETURN result
 END concat;
 END concat;
 
 
+PROCEDURE eq*(s1, s2: Type): BOOLEAN;
+VAR result: BOOLEAN;
+BEGIN
+    JS.do("result = s1 == s2");
+    RETURN result
+END eq;
+
 END JsString.
 END JsString.

+ 124 - 0
src/ob/Module.ob

@@ -0,0 +1,124 @@
+MODULE Module;
+IMPORT Code, Context, Errors, JsArray, JsString, Procedure, Symbols, Types;
+TYPE
+    Type* = RECORD(Types.Module)
+        PROCEDURE findSymbol(id: JsString.Type): Symbols.PFoundSymbol
+    END;
+    PType* = POINTER TO Type;
+
+    AnyType* = RECORD(Types.StorageType)
+        PROCEDURE callGenerator(cx: Context.PType; id: JsString.Type): Procedure.PCallGenerator;
+        PROCEDURE findSymbol(id: JsString.Type): Types.PType
+    END;
+
+    AnyTypeProc* = RECORD(Types.DefinedProcedure)
+    END;
+
+    JS = RECORD(Type)
+    END;
+VAR
+    doProcId, varTypeId: JsString.Type;
+    any: POINTER TO AnyType;
+    anyProc: AnyTypeProc;
+    doProcSymbol, varTypeSymbol: Symbols.PSymbol;
+
+PROCEDURE AnyType.description(): JsString.Type;
+    RETURN JsString.make("JS.var")
+END AnyType.description;
+
+PROCEDURE AnyType.initializer(cx: Context.Type): JsString.Type;
+    RETURN JsString.make("undefined")
+END AnyType.initializer;
+
+PROCEDURE AnyType.callGenerator(cx: Context.PType; id: JsString.Type): Procedure.PCallGenerator;
+    RETURN Procedure.makeProcCallGenerator(cx, id, anyProc)
+END AnyType.callGenerator;
+
+PROCEDURE AnyType.findSymbol(id: JsString.Type): Types.PType;
+    RETURN any
+END AnyType.findSymbol;
+
+PROCEDURE AnyTypeProc.args(): JsArray.Type;
+    RETURN NIL
+END AnyTypeProc.args;
+
+PROCEDURE AnyTypeProc.result(): Types.PType;
+    RETURN any
+END AnyTypeProc.result;
+
+PROCEDURE JS.findSymbol(id: JsString.Type): Symbols.PFoundSymbol;
+VAR
+    result: Symbols.PSymbol;
+BEGIN
+    IF JsString.eq(id, doProcId) THEN
+        result := doProcSymbol;
+    ELSIF JsString.eq(id, varTypeId) THEN
+        result := varTypeSymbol;
+    ELSE
+        result := Symbols.makeSymbol(id, Types.makeProcedure(any));
+    END;
+    RETURN Symbols.makeFound(result, NIL)
+END JS.findSymbol;
+
+PROCEDURE makeVarTypeSymbol(): Symbols.PSymbol;
+    RETURN Symbols.makeSymbol(varTypeId, Types.makeTypeId(any))
+END makeVarTypeSymbol;
+
+PROCEDURE makeDoProcSymbol(): Symbols.PSymbol;
+TYPE
+    Call = RECORD(Procedure.StdCall)
+    END;
+    Proc = RECORD(Procedure.Std)
+    END;
+VAR
+    description: JsString.Type;
+    call: POINTER TO Call;
+    proc: POINTER TO Proc;
+
+    PROCEDURE Call.make(args: JsArray.Type; cx: Context.Type): Code.PExpression;
+    VAR
+        arg: Code.PExpression;
+        type: Types.PType;
+    BEGIN
+        arg := Procedure.checkSingleArgument(args, SELF);
+        type := arg.type();
+        IF ~(type IS Types.PString) THEN
+            Errors.raise(JsString.concat(JsString.concat(JsString.concat(
+                JsString.make("string is expected as an argument of "),
+                description),
+                JsString.make(", got ")),
+                type.description()));
+        END;
+        RETURN Code.makeSimpleExpression(Types.stringValue(type(Types.PString)^), NIL)
+    END Call.make;
+
+    PROCEDURE Proc.description(): JsString.Type;
+        RETURN description
+    END Proc.description;
+BEGIN
+    description := JsString.make("JS predefined procedure 'do'");
+    NEW(call);
+    Procedure.initStdCall(call);
+    Procedure.hasArgumentWithCustomType(call);
+
+    NEW(proc);
+    Procedure.initStd(JsString.makeEmpty(), call, proc^);
+    RETURN Procedure.makeSymbol(proc)
+END makeDoProcSymbol;
+
+PROCEDURE makeJS*(): PType;
+VAR
+    result: POINTER TO JS;
+BEGIN
+    NEW(result);
+    Types.initModule(result^, JsString.make("this"));
+    RETURN result
+END makeJS;
+
+BEGIN
+    doProcId := JsString.make("do$");
+    varTypeId := JsString.make("var$");
+    NEW(any);
+    doProcSymbol := makeDoProcSymbol();
+    varTypeSymbol := makeVarTypeSymbol();
+END Module.

+ 25 - 25
src/ob/Procedure.ob

@@ -13,11 +13,11 @@ IMPORT
     Types;
     Types;
 TYPE
 TYPE
     Call* = RECORD
     Call* = RECORD
-        PROCEDURE make(args: JsArray.Type; cx: Context.Type): Code.PExpression
+        PROCEDURE make*(args: JsArray.Type; cx: Context.Type): Code.PExpression
     END;
     END;
     PCall = POINTER TO Call;
     PCall = POINTER TO Call;
 
 
-    StdCall = RECORD(Call)
+    StdCall* = RECORD(Call)
         args: JsArray.Type
         args: JsArray.Type
     END;
     END;
     PStdCall = POINTER TO StdCall;
     PStdCall = POINTER TO StdCall;
@@ -30,7 +30,7 @@ TYPE
         cx: Context.PType;
         cx: Context.PType;
         call: PCall
         call: PCall
     END;
     END;
-    PCallGenerator = POINTER TO CallGenerator;
+    PCallGenerator* = POINTER TO CallGenerator;
 
 
     Impl = RECORD(Types.Procedure)
     Impl = RECORD(Types.Procedure)
         PROCEDURE callGenerator(cx: Context.PType): PCallGenerator
         PROCEDURE callGenerator(cx: Context.PType): PCallGenerator
@@ -161,13 +161,18 @@ BEGIN
     processArguments(actual, expected, NIL);
     processArguments(actual, expected, NIL);
 END checkArguments;
 END checkArguments;
 
 
+PROCEDURE initStd*(name: JsString.Type; call: PCall; result: Std);
+BEGIN
+    Types.initProcedure(result, name);
+    result.call := call;
+END initStd;
+
 PROCEDURE makeStd(name: JsString.Type; call: PCall): Types.PProcedure;
 PROCEDURE makeStd(name: JsString.Type; call: PCall): Types.PProcedure;
 VAR
 VAR
     result: POINTER TO Std;
     result: POINTER TO Std;
 BEGIN
 BEGIN
     NEW(result);
     NEW(result);
-    Types.initProcedure(result^, name);
-    result.call := call;
+    initStd(name, call, result^);
     RETURN result
     RETURN result
 END makeStd;
 END makeStd;
 
 
@@ -292,7 +297,7 @@ PROCEDURE Std.callGenerator(cx: Context.PType): PCallGenerator;
     RETURN makeCallGenerator(SELF.call, cx)
     RETURN makeCallGenerator(SELF.call, cx)
 END Std.callGenerator;
 END Std.callGenerator;
 
 
-PROCEDURE makeSymbol(p: Types.PProcedure): Symbols.PSymbol;
+PROCEDURE makeSymbol*(p: Types.PProcedure): Symbols.PSymbol;
     RETURN Symbols.makeSymbol(p.name, Types.makeProcedure(p))
     RETURN Symbols.makeSymbol(p.name, Types.makeProcedure(p))
 END makeSymbol;
 END makeSymbol;
 
 
@@ -304,7 +309,7 @@ BEGIN
     RETURN arg(Code.PExpression)
     RETURN arg(Code.PExpression)
 END nthArgument;
 END nthArgument;
 
 
-PROCEDURE initStdCall(call: PStdCall);
+PROCEDURE initStdCall*(call: PStdCall);
 BEGIN
 BEGIN
     call.args := JsArray.make();
     call.args := JsArray.make();
 END initStdCall;
 END initStdCall;
@@ -328,7 +333,7 @@ BEGIN
     JsArray.add(call.args, a);
     JsArray.add(call.args, a);
 END hasVarArgument;
 END hasVarArgument;
 
 
-PROCEDURE hasArgumentWithCustomType(call: PStdCall);
+PROCEDURE hasArgumentWithCustomType*(call: PStdCall);
 VAR
 VAR
     a: Types.PProcedureArgument;
     a: Types.PProcedureArgument;
 BEGIN
 BEGIN
@@ -345,10 +350,10 @@ BEGIN
     JsArray.add(call.args, a);
     JsArray.add(call.args, a);
 END hasVarArgumnetWithCustomType;
 END hasVarArgumnetWithCustomType;
 
 
-PROCEDURE checkSingleArgument(actual: JsArray.Type; expected: JsArray.Type): Code.PExpression;
+PROCEDURE checkSingleArgument*(actual: JsArray.Type; call: StdCall): Code.PExpression;
 BEGIN
 BEGIN
-    ASSERT(JsArray.len(expected) = 1);
-    checkArguments(actual, expected);
+    ASSERT(JsArray.len(call.args) = 1);
+    checkArguments(actual, call.args);
     ASSERT(JsArray.len(actual) = 1);
     ASSERT(JsArray.len(actual) = 1);
     RETURN nthArgument(actual, 0)
     RETURN nthArgument(actual, 0)
 END checkSingleArgument;
 END checkSingleArgument;
@@ -366,7 +371,7 @@ PROCEDURE makeNew(): Symbols.PSymbol;
         argType: Types.PType;
         argType: Types.PType;
         baseType: Types.PRecord;
         baseType: Types.PRecord;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         argType := arg.type();
         argType := arg.type();
         IF ~(argType IS Types.PPointer) THEN
         IF ~(argType IS Types.PPointer) THEN
             Errors.raise(JsString.concat(JsString.concat(
             Errors.raise(JsString.concat(JsString.concat(
@@ -404,7 +409,7 @@ PROCEDURE makeLen(): Symbols.PSymbol;
         arg: Code.PExpression;
         arg: Code.PExpression;
         argType: Types.PType;
         argType: Types.PType;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         argType := arg.type();
         argType := arg.type();
         IF ~(argType IS Types.PArray) & ~(argType IS Types.PString) THEN
         IF ~(argType IS Types.PArray) & ~(argType IS Types.PString) THEN
             Errors.raise(JsString.concat(JsString.concat(
             Errors.raise(JsString.concat(JsString.concat(
@@ -420,11 +425,6 @@ BEGIN
     NEW(call);
     NEW(call);
     initStdCall(call);
     initStdCall(call);
     hasArgumentWithCustomType(call);
     hasArgumentWithCustomType(call);
-    (*call.args[0].type := Types.makeArray(
-        JsString.make("ARRAY OF any type"), 
-        NIL, 
-        NIL,
-        Types.openArrayLength);*)
     RETURN makeSymbol(makeStd(JsString.make("LEN"), call))
     RETURN makeSymbol(makeStd(JsString.make("LEN"), call))
 END makeLen;
 END makeLen;
 
 
@@ -441,7 +441,7 @@ PROCEDURE makeOdd(): Symbols.PSymbol;
         code: JsString.Type;
         code: JsString.Type;
         constValue: Code.PConst;
         constValue: Code.PConst;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         code := Code.adjustPrecedence(arg, Precedence.bitAnd);
         code := Code.adjustPrecedence(arg, Precedence.bitAnd);
         
         
         constValue := arg.constValue();
         constValue := arg.constValue();
@@ -476,7 +476,7 @@ PROCEDURE makeAssert(): Symbols.PSymbol;
         arg: Code.PExpression;
         arg: Code.PExpression;
         rtl: Context.PRtl;
         rtl: Context.PRtl;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         rtl := cx.rtl();
         rtl := cx.rtl();
         RETURN Code.makeSimpleExpression(
         RETURN Code.makeSimpleExpression(
             JsString.concat(JsString.concat(JsString.concat(
             JsString.concat(JsString.concat(JsString.concat(
@@ -667,7 +667,7 @@ PROCEDURE makeAbs(): Symbols.PSymbol;
         arg: Code.PExpression;
         arg: Code.PExpression;
         argType: Types.PType;
         argType: Types.PType;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         argType := arg.type();
         argType := arg.type();
         IF ~JsArray.contains(Types.numeric, argType) THEN
         IF ~JsArray.contains(Types.numeric, argType) THEN
             Errors.raise(JsString.concat(JsString.concat(
             Errors.raise(JsString.concat(JsString.concat(
@@ -700,7 +700,7 @@ PROCEDURE makeFloor(): Symbols.PSymbol;
     VAR
     VAR
         arg: Code.PExpression;
         arg: Code.PExpression;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         RETURN Code.makeSimpleExpression(
         RETURN Code.makeSimpleExpression(
             JsString.concat(JsString.concat(
             JsString.concat(JsString.concat(
                 JsString.make("Math.floor("), 
                 JsString.make("Math.floor("), 
@@ -727,7 +727,7 @@ PROCEDURE makeFlt(): Symbols.PSymbol;
         arg: Code.PExpression;
         arg: Code.PExpression;
         value: Code.PConst;
         value: Code.PConst;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         value := arg.constValue();
         value := arg.constValue();
         IF value # NIL THEN
         IF value # NIL THEN
             value := Code.makeRealConst(FLT(value^(Code.IntConst).value));
             value := Code.makeRealConst(FLT(value^(Code.IntConst).value));
@@ -791,7 +791,7 @@ PROCEDURE makeOrd(): Symbols.PSymbol;
         ch: CHAR;
         ch: CHAR;
         result: Code.PExpression;
         result: Code.PExpression;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         argType := arg.type();
         argType := arg.type();
         IF (argType = Types.basic.ch) OR (argType = Types.basic.set) THEN
         IF (argType = Types.basic.ch) OR (argType = Types.basic.set) THEN
             value := arg.constValue();
             value := arg.constValue();
@@ -842,7 +842,7 @@ PROCEDURE makeChr(): Symbols.PSymbol;
     VAR
     VAR
         arg: Code.PExpression;
         arg: Code.PExpression;
     BEGIN
     BEGIN
-        arg := checkSingleArgument(args, SELF.args);
+        arg := checkSingleArgument(args, SELF);
         RETURN Code.makeSimpleExpression(arg.code(), Types.basic.ch)
         RETURN Code.makeSimpleExpression(arg.code(), Types.basic.ch)
     END CallImpl.make;
     END CallImpl.make;
 BEGIN
 BEGIN

+ 1 - 1
src/ob/Symbols.ob

@@ -24,7 +24,7 @@ TYPE
         mScope: Context.PScope
         mScope: Context.PScope
     END;
     END;
 
 
-    PFoundSymbol = POINTER TO FoundSymbol;
+    PFoundSymbol* = POINTER TO FoundSymbol;
 
 
 PROCEDURE Symbol.id(): JsString.Type;
 PROCEDURE Symbol.id(): JsString.Type;
     RETURN SELF.mId
     RETURN SELF.mId

+ 1 - 1
src/ob/Types.ob

@@ -16,7 +16,7 @@ TYPE
     END;
     END;
     PType* = POINTER TO Type;
     PType* = POINTER TO Type;
 
 
-    StorageType = RECORD(Type)    
+    StorageType* = RECORD(Type)    
         PROCEDURE initializer*(cx: Context.Type): JsString.Type
         PROCEDURE initializer*(cx: Context.Type): JsString.Type
     END;
     END;