Browse Source

move compiled source to archive (do not track compiled source)

Vladislav Folts 11 years ago
parent
commit
83ffadda90

+ 2 - 3
.gitignore

@@ -1,3 +1,4 @@
+bin/js/
 _out/
 snapshot*/
 test/output/
@@ -11,7 +12,6 @@ test/output/
 *.pydevproject
 .project
 .metadata
-bin/
 tmp/
 *.tmp
 *.bak
@@ -103,7 +103,7 @@ DocProject/Help/html
 publish
 
 # Others
-[Bb]in
+# [Bb]in
 [Oo]bj
 sql
 TestResults
@@ -146,7 +146,6 @@ dist
 build
 eggs
 parts
-bin
 var
 sdist
 develop-eggs

BIN
bin/compiled.zip


+ 1 - 1
build.cmd

@@ -1,2 +1,2 @@
-build.py _out --no-git
+build.py _out --no-git %*
 start _out\oberonjs.html

+ 39 - 10
build.py

@@ -1,11 +1,29 @@
 
 #!/usr/bin/python
 from browser.linkjs import link
+import argparse
 import os
 import shutil
 import stat
 import subprocess
 import sys
+import zipfile
+
+class package( object ):
+    root = 'bin/js'
+    archive = 'bin/compiled.zip'
+
+    @staticmethod
+    def pack():
+        file = zipfile.ZipFile(package.archive, 'w')
+        for f in os.listdir(package.root):
+            file.write(os.path.join('bin/js', f), f)
+
+    @staticmethod
+    def unpack():
+        cleanup(package.root)
+        file = zipfile.ZipFile(package.archive, 'r')
+        file.extractall(package.root)
 
 # http://stackoverflow.com/questions/1889597/deleting-directory-in-python
 def remove_readonly(fn, path, excinfo):
@@ -31,6 +49,9 @@ def is_parent_for(parent, child):
         child = next
 
 def cleanup(dir):
+    if not os.path.exists(dir):
+        return
+
     this_dir = os.path.dirname(__file__)
     if is_parent_for(dir, this_dir):
         raise Exception("cannot delete itself: %s" % this_dir)
@@ -44,8 +65,7 @@ def copy(src, dst_dir):
     shutil.copy(src, dst)
 
 def copytree(src, dst):
-    if os.path.exists(dst):
-        cleanup(dst)
+    cleanup(dst)
     print('%s -> %s' % (src, dst))
     shutil.copytree(src, dst)
 
@@ -53,12 +73,13 @@ def run(cmd):
     p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, shell = True)
     return p.stdout.read().decode()
 
-def build(out, use_git):
+def build(options):
     version = None
-    if use_git:
+    if not options.no_git:
         print(run('git pull'))
         version = run('git log -1 --format="%ci%n%H"')
 
+    out = options.output
     build_version = None
     build_version_path = os.path.join(out, 'version.txt')
     try:
@@ -71,12 +92,19 @@ def build(out, use_git):
         print("current html is up to date, do nothing")
         return
 
+    if options.pack:
+        print 'packaing compiled js to %s...' % package.root
+        package.pack()
+    else:
+        print 'unpackaing compiled js to %s...' % package.root
+        package.unpack()
+
     if not os.path.exists(out):
         os.mkdir(out)
 
     link(['oc.js', 'oberon/oberon_grammar.js', 'eberon/eberon_grammar.js'],
          os.path.join(out, 'oc.js'),
-         ['src', 'src/eberon'],
+         ['src', 'bin'],
          version)
     copy('browser/oberonjs.html', out)
     for d in ['codemirror', 'jslibs']:
@@ -90,8 +118,9 @@ def build(out, use_git):
             f.write(version)
 
 if __name__ == '__main__':
-    if len(sys.argv) < 2:
-        print('Pull repo and build html page\nUsage: build.py <output directory> [--no-git]')
-        exit(-1)
-    use_git = len(sys.argv) < 3 or sys.argv[2] != '--no-git'
-    build(sys.argv[1], use_git)
+    parser = argparse.ArgumentParser(description='Pull repo and build html page')
+    parser.add_argument('output', help='output directory')
+    parser.add_argument('--no-git', help='do not pull from git', action="store_true")
+    parser.add_argument('--pack', help='pack compiled source', action="store_true")
+    args = parser.parse_args()
+    build(args)

+ 2 - 2
src/eberon/eberon_context.js

@@ -3,10 +3,10 @@
 var Cast = require("js/Cast.js");
 var Code = require("js/Code.js");
 var Context = require("context.js");
-var EberonString = require("eberon/js/EberonString.js");
+var EberonString = require("js/EberonString.js");
 var Errors = require("js/Errors.js");
 var op = require("js/Operator.js");
-var eOp = require("eberon/js/EberonOperator.js");
+var eOp = require("js/EberonOperator.js");
 var Symbol = require("js/Symbols.js");
 var Procedure = require("js/Procedure.js");
 var Type = require("js/Types.js");

+ 2 - 2
src/eberon/eberon_grammar.js

@@ -1,9 +1,9 @@
 "use strict";
 
-var Cast = require("eberon/js/EberonCast.js");
+var Cast = require("js/EberonCast.js");
 var Context = require("context.js");
 var EbContext = require("eberon/eberon_context.js");
-var EberonString = require("eberon/js/EberonString.js");
+var EberonString = require("js/EberonString.js");
 var Grammar = require("grammar.js");
 var Parser = require("parser.js");
 var Scope = require("js/Scope.js");

+ 0 - 20
src/eberon/js/EberonCast.js

@@ -1,20 +0,0 @@
-var Cast = require("js/Cast.js");
-var EberonString = require("js/EberonString.js");
-var Types = require("js/Types.js");
-
-function implicit(from/*PType*/, to/*PType*/, toVar/*BOOLEAN*/, ops/*Operations*/, op/*VAR PCastOp*/){
-	var result = 0;
-	if (from == EberonString.string() && Types.isString(to)){
-		if (toVar){
-			result = Cast.errVarParameter;
-		}
-		else {
-			result = Cast.errNo;
-		}
-	}
-	else {
-		result = Cast.implicit(from, to, toVar, ops, op);
-	}
-	return result;
-}
-exports.implicit = implicit;

+ 0 - 69
src/eberon/js/EberonOperator.js

@@ -1,69 +0,0 @@
-var RTL$ = require("rtl.js");
-var Code = require("js/Code.js");
-var CodePrecedence = require("js/CodePrecedence.js");
-var JsString = require("js/JsString.js");
-var OberonRtl = require("js/OberonRtl.js");
-var Operator = require("js/Operator.js");
-
-function opAddStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeStrConst(JsString.concat(RTL$.typeGuard(left, Code.StrConst).value, RTL$.typeGuard(right, Code.StrConst).value));
-}
-
-function opEqualStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.StrConst).value == RTL$.typeGuard(right, Code.StrConst).value ? 1 : 0);
-}
-
-function opNotEqualStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.StrConst).value != RTL$.typeGuard(right, Code.StrConst).value ? 1 : 0);
-}
-
-function opLessStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(0);
-}
-
-function opGreaterStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(0);
-}
-
-function opLessEqualStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(0);
-}
-
-function opGraterEqualStr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(0);
-}
-
-function addStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opAddStr, " + ", CodePrecedence.addSub);
-}
-
-function equalStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opEqualStr, " == ", CodePrecedence.equal);
-}
-
-function notEqualStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opNotEqualStr, " != ", CodePrecedence.equal);
-}
-
-function lessStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opLessStr, " < ", CodePrecedence.relational);
-}
-
-function greaterStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opGreaterStr, " > ", CodePrecedence.relational);
-}
-
-function lessEqualStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opLessEqualStr, " <= ", CodePrecedence.relational);
-}
-
-function greaterEqualStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Operator.binaryWithCode(left, right, rtl, opGraterEqualStr, " >= ", CodePrecedence.relational);
-}
-exports.addStr = addStr;
-exports.equalStr = equalStr;
-exports.notEqualStr = notEqualStr;
-exports.lessStr = lessStr;
-exports.greaterStr = greaterStr;
-exports.lessEqualStr = lessEqualStr;
-exports.greaterEqualStr = greaterEqualStr;

+ 0 - 4
src/eberon/js/EberonString.js

@@ -1,4 +0,0 @@
-var Types = require("js/Types.js");
-var string = null;
-string = Types.makeBasic("STRING", "''");
-exports.string = function(){return string;};

+ 0 - 186
src/js/Cast.js

@@ -1,186 +0,0 @@
-var RTL$ = require("rtl.js");
-var Code = require("js/Code.js");
-var OberonRtl = require("js/OberonRtl.js");
-var JsArray = require("js/JsArray.js");
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var Types = require("js/Types.js");
-var errNo = 0;
-var err = 1;
-var errVarParameter = 2;
-var CastOp = Object.Type.extend({
-	init: function CastOp(){
-		Object.Type.prototype.init.call(this);
-	}
-});
-var CastOpStrToChar = CastOp.extend({
-	init: function CastOpStrToChar(){
-		CastOp.prototype.init.call(this);
-		this.c = 0;
-	}
-});
-var Operations = RTL$.extend({
-	init: function Operations(){
-		this.castToUint8 = null;
-	}
-});
-var areTypesExactlyMatch = null;
-var doNothing = null;
-
-function findBaseType(base/*PRecord*/, type/*PRecord*/){
-	while (true){
-		if (type != null && type != base){
-			type = Types.recordBase(type);
-		} else break;
-	}
-	return type;
-}
-
-function findPointerBaseType(base/*PPointer*/, type/*Pointer*/){
-	var result = null;
-	if (findBaseType(Types.pointerBase(base), Types.pointerBase(type)) != null){
-		result = base;
-	}
-	return result;
-}
-
-function matchesToNIL(t/*Type*/){
-	return t instanceof Types.Pointer || t instanceof Types.Procedure;
-}
-
-function areTypesMatch(t1/*PType*/, t2/*PType*/){
-	return areTypesExactlyMatch(t1, t2) || Types.isInt(t1) && Types.isInt(t2) || (t1 == Types.nil() && matchesToNIL(t2) || t2 == Types.nil() && matchesToNIL(t1));
-}
-
-function areArgsMatch(oa1/*PType*/, oa2/*PType*/, p1/*PDefinedProcedure*/, p2/*PDefinedProcedure*/){
-	var a1 = null;
-	var a2 = null;
-	a1 = RTL$.typeGuard(oa1, Types.ProcedureArgument);
-	a2 = RTL$.typeGuard(oa2, Types.ProcedureArgument);
-	return a1.isVar == a2.isVar && (a1.type == p1 && a2.type == p2 || areTypesExactlyMatch(a1.type, a2.type));
-}
-
-function areProceduresMatch(p1/*PDefinedProcedure*/, p2/*PDefinedProcedure*/){
-	var result = false;
-	var args1 = null;var args2 = null;
-	var argsLen = 0;
-	var i = 0;
-	var r1 = null;var r2 = null;
-	args1 = p1.args();
-	args2 = p2.args();
-	argsLen = JsArray.len(args1);
-	if (JsArray.len(args2) == argsLen){
-		while (true){
-			if (i < argsLen && areArgsMatch(JsArray.at(args1, i), JsArray.at(args2, i), p1, p2)){
-				++i;
-			} else break;
-		}
-		if (i == argsLen){
-			r1 = p1.result();
-			r2 = p2.result();
-			result = r1 == p1 && r2 == p2 || areTypesExactlyMatch(r1, r2);
-		}
-	}
-	return result;
-}
-
-function areTypesExactlyMatchImpl(t1/*PType*/, t2/*PType*/){
-	var result = false;
-	if (t1 == t2){
-		result = true;
-	}
-	else if (t1 instanceof Types.Array && t2 instanceof Types.Array){
-		result = Types.arrayLength(RTL$.typeGuard(t1, Types.Array)) == Types.arrayLength(RTL$.typeGuard(t2, Types.Array)) && areTypesMatch(Types.arrayElementsType(RTL$.typeGuard(t1, Types.Array)), Types.arrayElementsType(RTL$.typeGuard(t2, Types.Array)));
-	}
-	else if (t1 instanceof Types.Pointer && t2 instanceof Types.Pointer){
-		result = areTypesMatch(Types.pointerBase(RTL$.typeGuard(t1, Types.Pointer)), Types.pointerBase(RTL$.typeGuard(t2, Types.Pointer)));
-	}
-	else if (t1 instanceof Types.DefinedProcedure && t2 instanceof Types.DefinedProcedure){
-		result = areProceduresMatch(RTL$.typeGuard(t1, Types.DefinedProcedure), RTL$.typeGuard(t2, Types.DefinedProcedure));
-	}
-	return result;
-}
-CastOpStrToChar.prototype.make = function(rtl/*PType*/, e/*PExpression*/){
-	return Code.makeSimpleExpression(JsString.fromInt(this.c), Types.basic().ch);
-}
-
-function makeCastOpStrToChar(c/*CHAR*/){
-	var result = null;
-	result = new CastOpStrToChar();
-	result.c = c;
-	return result;
-}
-
-function implicit(from/*PType*/, to/*PType*/, toVar/*BOOLEAN*/, ops/*Operations*/, op/*VAR PCastOp*/){
-	var result = 0;
-	var c = 0;
-	var ignore = false;
-	result = err;
-	op.set(null);
-	if (from == to){
-		result = errNo;
-	}
-	else if (from == Types.basic().uint8 && to == Types.basic().integer){
-		if (toVar){
-			result = errVarParameter;
-		}
-		else {
-			result = errNo;
-		}
-	}
-	else if (from == Types.basic().integer && to == Types.basic().uint8){
-		if (toVar){
-			result = errVarParameter;
-		}
-		else {
-			op.set(ops.castToUint8);
-			result = errNo;
-		}
-	}
-	else if (from instanceof Types.String){
-		if (to == Types.basic().ch){
-			if (Types.stringAsChar(RTL$.typeGuard(from, Types.String), {set: function($v){c = $v;}, get: function(){return c;}})){
-				op.set(makeCastOpStrToChar(c));
-				result = errNo;
-			}
-		}
-		else if (Types.isString(to)){
-			result = errNo;
-		}
-	}
-	else if (from instanceof Types.Array && to instanceof Types.Array){
-		if ((Types.arrayLength(RTL$.typeGuard(from, Types.Array)) == Types.arrayLength(RTL$.typeGuard(to, Types.Array)) || Types.arrayLength(RTL$.typeGuard(to, Types.Array)) == Types.openArrayLength) && areTypesExactlyMatch(Types.arrayElementsType(RTL$.typeGuard(from, Types.Array)), Types.arrayElementsType(RTL$.typeGuard(to, Types.Array)))){
-			result = errNo;
-		}
-	}
-	else if (from instanceof Types.Pointer && to instanceof Types.Pointer){
-		if (findPointerBaseType(RTL$.typeGuard(to, Types.Pointer), RTL$.typeGuard(from, Types.Pointer)) != null){
-			result = errNo;
-		}
-	}
-	else if (from instanceof Types.Record && to instanceof Types.Record){
-		if (findBaseType(RTL$.typeGuard(to, Types.Record), RTL$.typeGuard(from, Types.Record)) != null){
-			result = errNo;
-		}
-	}
-	else if (from == Types.nil() && matchesToNIL(to)){
-		result = errNo;
-	}
-	else if (from instanceof Types.DefinedProcedure && to instanceof Types.DefinedProcedure){
-		if (areProceduresMatch(RTL$.typeGuard(from, Types.DefinedProcedure), RTL$.typeGuard(to, Types.DefinedProcedure))){
-			result = errNo;
-		}
-	}
-	return result;
-}
-areTypesExactlyMatch = areTypesExactlyMatchImpl;
-exports.errNo = errNo;
-exports.err = err;
-exports.errVarParameter = errVarParameter;
-exports.CastOp = CastOp;
-exports.Operations = Operations;
-exports.doNothing = function(){return doNothing;};
-exports.findPointerBaseType = findPointerBaseType;
-exports.areTypesMatch = areTypesMatch;
-exports.areProceduresMatch = areProceduresMatch;
-exports.implicit = implicit;

+ 0 - 422
src/js/Code.js

@@ -1,422 +0,0 @@
-var RTL$ = require("rtl.js");
-var JsMap = require("js/JsMap.js");
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var Stream = require("js/Stream.js");
-var ScopeBase = require("js/ScopeBase.js");
-var Symbols = require("js/Symbols.js");
-var Precedence = require("js/CodePrecedence.js");
-var Types = require("js/Types.js");
-var kTab = "\t";
-var IGenerator = RTL$.extend({
-	init: function IGenerator(){
-	}
-});
-var NullGenerator = IGenerator.extend({
-	init: function NullGenerator(){
-		IGenerator.prototype.init.call(this);
-	}
-});
-var SimpleGenerator = NullGenerator.extend({
-	init: function SimpleGenerator(){
-		NullGenerator.prototype.init.call(this);
-		this.mResult = null;
-	}
-});
-var Generator = SimpleGenerator.extend({
-	init: function Generator(){
-		SimpleGenerator.prototype.init.call(this);
-		this.indent = 0;
-	}
-});
-var Designator = RTL$.extend({
-	init: function Designator(){
-		this.mCode = null;
-		this.mLval = null;
-		this.mRefCode = null;
-		this.mType = null;
-		this.mInfo = null;
-		this.mScope = null;
-	}
-});
-var Const = RTL$.extend({
-	init: function Const(){
-	}
-});
-var IntConst = Const.extend({
-	init: function IntConst(){
-		Const.prototype.init.call(this);
-		this.value = 0;
-	}
-});
-var RealConst = Const.extend({
-	init: function RealConst(){
-		Const.prototype.init.call(this);
-		this.value = 0;
-	}
-});
-var SetConst = Const.extend({
-	init: function SetConst(){
-		Const.prototype.init.call(this);
-		this.value = 0;
-	}
-});
-var StrConst = Const.extend({
-	init: function StrConst(){
-		Const.prototype.init.call(this);
-		this.value = null;
-	}
-});
-var StringConst = Const.extend({
-	init: function StringConst(){
-		Const.prototype.init.call(this);
-		this.value = null;
-	}
-});
-var Expression = Object.Type.extend({
-	init: function Expression(){
-		Object.Type.prototype.init.call(this);
-		this.mCode = null;
-		this.mType = null;
-		this.mDesignator = null;
-		this.mConstValue = null;
-		this.mMaxPrecedence = 0;
-	}
-});
-var ModuleGenerator = RTL$.extend({
-	init: function ModuleGenerator(){
-		this.name = null;
-		this.imports = null;
-	}
-});
-var Closure = Object.Type.extend({
-	init: function Closure(){
-		Object.Type.prototype.init.call(this);
-		this.result = null;
-	}
-});
-var nullGenerator = new NullGenerator();
-NullGenerator.prototype.write = function(s/*Type*/){
-}
-NullGenerator.prototype.openScope = function(){
-}
-NullGenerator.prototype.closeScope = function(ending/*Type*/){
-}
-NullGenerator.prototype.result = function(){
-	return null;
-}
-SimpleGenerator.prototype.write = function(s/*Type*/){
-	this.mResult = JsString.concat(this.mResult, s);
-}
-SimpleGenerator.prototype.result = function(){
-	return this.mResult;
-}
-
-function putIndent(s/*Type*/, indent/*INTEGER*/){
-	var i = 0;
-	for (i = 0; i <= indent - 1 | 0; ++i){
-		s = JsString.appendChar(s, 9);
-	}
-	return s;
-}
-Generator.prototype.write = function(s/*Type*/){
-	var pos = 0;
-	var index = 0;
-	index = JsString.indexOf(s, 10);
-	while (true){
-		if (index != -1){
-			++index;
-			this.mResult = JsString.concat(this.mResult, JsString.substr(s, pos, index - pos | 0));
-			this.mResult = putIndent(this.mResult, this.indent);
-			pos = index;
-			index = JsString.indexOfFrom(s, 10, pos);
-		} else break;
-	}
-	this.mResult = JsString.concat(this.mResult, JsString.substr(s, pos, JsString.len(s) - pos | 0));
-}
-Generator.prototype.openScope = function(){
-	++this.indent;
-	this.mResult = JsString.appendChar(this.mResult, 123);
-	this.mResult = JsString.appendChar(this.mResult, 10);
-	this.mResult = putIndent(this.mResult, this.indent);
-}
-Generator.prototype.closeScope = function(ending/*Type*/){
-	--this.indent;
-	this.mResult = JsString.substr(this.mResult, 0, JsString.len(this.mResult) - 1 | 0);
-	this.mResult = JsString.appendChar(this.mResult, 125);
-	if (ending != null){
-		this.write(ending);
-	}
-	else {
-		this.mResult = JsString.appendChar(this.mResult, 10);
-		this.mResult = putIndent(this.mResult, this.indent);
-	}
-}
-Expression.prototype.code = function(){
-	return this.mCode;
-}
-Expression.prototype.lval = function(){
-	var result = null;
-	if (this.mDesignator != null){
-		result = this.mDesignator.mLval;
-	}
-	else {
-		result = this.mCode;
-	}
-	return result;
-}
-Expression.prototype.type = function(){
-	return this.mType;
-}
-Expression.prototype.designator = function(){
-	return this.mDesignator;
-}
-Expression.prototype.constValue = function(){
-	return this.mConstValue;
-}
-Expression.prototype.maxPrecedence = function(){
-	return this.mMaxPrecedence;
-}
-Expression.prototype.isTerm = function(){
-	return this.mDesignator == null && this.mMaxPrecedence == Precedence.none;
-}
-
-function makeIntConst(n/*INTEGER*/){
-	var result = null;
-	result = new IntConst();
-	result.value = n;
-	return result;
-}
-
-function makeRealConst(n/*REAL*/){
-	var result = null;
-	result = new RealConst();
-	result.value = n;
-	return result;
-}
-
-function makeSetConst(s/*SET*/){
-	var result = null;
-	result = new SetConst();
-	result.value = s;
-	return result;
-}
-
-function makeStrConst(s/*Type*/){
-	var result = null;
-	result = new StrConst();
-	result.value = s;
-	return result;
-}
-
-function makeStringConst(s/*Type*/){
-	var result = null;
-	result = new StringConst();
-	result.value = s;
-	return result;
-}
-
-function makeExpressionWithPrecedence(code/*Type*/, type/*PType*/, designator/*PDesignator*/, constValue/*PConst*/, maxPrecedence/*INTEGER*/){
-	var result = null;
-	RTL$.assert(code != null);
-	result = new Expression();
-	result.mCode = code;
-	result.mType = type;
-	result.mDesignator = designator;
-	result.mConstValue = constValue;
-	result.mMaxPrecedence = maxPrecedence;
-	return result;
-}
-
-function makeExpression(code/*Type*/, type/*PType*/, designator/*PDesignator*/, constValue/*PConst*/){
-	return makeExpressionWithPrecedence(code, type, designator, constValue, Precedence.none);
-}
-
-function makeSimpleExpression(code/*Type*/, type/*PType*/){
-	return makeExpression(code, type, null, null);
-}
-Designator.prototype.code = function(){
-	return this.mCode;
-}
-Designator.prototype.lval = function(){
-	return this.mLval;
-}
-Designator.prototype.refCode = function(){
-	return this.mRefCode;
-}
-Designator.prototype.type = function(){
-	return this.mType;
-}
-Designator.prototype.info = function(){
-	return this.mInfo;
-}
-Designator.prototype.scope = function(){
-	return this.mScope;
-}
-
-function makeDesignator(code/*Type*/, lval/*Type*/, refCode/*RefCodeProc*/, type/*PType*/, info/*PId*/, scope/*PType*/){
-	var result = null;
-	result = new Designator();
-	result.mCode = code;
-	result.mLval = lval;
-	result.mRefCode = refCode;
-	result.mType = type;
-	result.mInfo = info;
-	result.mScope = scope;
-	return result;
-}
-
-function derefExpression(e/*PExpression*/){
-	var result = null;
-	if (e.mDesignator == null || (e.mType instanceof Types.Array || e.mType instanceof Types.Record) || !(e.mDesignator.mInfo instanceof Types.VariableRef)){
-		result = e;
-	}
-	else {
-		result = makeSimpleExpression(JsString.concat(e.mCode, JsString.make(".get()")), e.mType);
-	}
-	return result;
-}
-
-function refExpression(e/*PExpression*/){
-	var result = null;
-	if (e.mDesignator == null || e.mDesignator.mInfo instanceof Types.VariableRef){
-		result = e;
-	}
-	else {
-		result = makeSimpleExpression(e.mDesignator.mRefCode(e.mDesignator.mCode), e.mType);
-	}
-	return result;
-}
-
-function adjustPrecedence(e/*PExpression*/, precedence/*INTEGER*/){
-	var result = null;
-	result = e.mCode;
-	if (precedence != Precedence.none && e.mMaxPrecedence > precedence){
-		result = JsString.concat(JsString.concat(JsString.make("("), result), JsString.make(")"));
-	}
-	return result;
-}
-
-function isPointerShouldBeExported(type/*Pointer*/){
-	var r = null;
-	r = Types.pointerBase(type);
-	return Types.typeName(r) == null;
-}
-
-function typeShouldBeExported(typeId/*PId*/){
-	var type = null;
-	type = RTL$.typeGuard(typeId, Types.TypeId).type();
-	return type instanceof Types.Record || type instanceof Types.Pointer && isPointerShouldBeExported(RTL$.typeGuard(type, Types.Pointer));
-}
-
-function genExport(s/*Symbol*/){
-	var result = null;
-	if (s.isVariable()){
-		result = JsString.concat(JsString.concat(JsString.make("function(){return "), s.id()), JsString.make(";}"));
-	}
-	else if (!s.isType() || typeShouldBeExported(s.info())){
-		result = s.id();
-	}
-	return result;
-}
-
-function genCommaList(name/*Type*/, closure/*Closure*/){
-	if (JsString.len(closure.result) != 0){
-		closure.result = JsString.concat(closure.result, JsString.make(", "));
-	}
-	closure.result = JsString.concat(closure.result, name);
-}
-
-function genAliasesAdaptor(key/*Type*/, value/*Type*/, closure/*VAR Type*/){
-	genCommaList(value, RTL$.typeGuard(closure, Closure));
-}
-ModuleGenerator.prototype.prolog = function(){
-	var closure = new Closure();
-	closure.result = JsString.makeEmpty();
-	JsMap.forEachString(this.imports, genAliasesAdaptor, closure);
-	return JsString.appendChar(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("var "), this.name), JsString.make(" = function (")), closure.result), JsString.make("){")), 10);
-}
-
-function genExports(s/*Symbol*/, closure/*Closure*/){
-	var code = null;
-	code = genExport(s);
-	if (code != null){
-		if (JsString.len(closure.result) != 0){
-			closure.result = JsString.appendChar(JsString.appendChar(closure.result, 44), 10);
-		}
-		closure.result = JsString.concat(JsString.concat(JsString.concat(JsString.appendChar(closure.result, 9), s.id()), JsString.make(": ")), code);
-	}
-}
-
-function genExportsAdaptor(key/*Type*/, value/*PType*/, closure/*VAR Type*/){
-	genExports(RTL$.typeGuard(value, Symbols.Symbol), RTL$.typeGuard(closure, Closure));
-}
-
-function genImportListAdaptor(key/*Type*/, value/*Type*/, closure/*VAR Type*/){
-	genCommaList(key, RTL$.typeGuard(closure, Closure));
-}
-ModuleGenerator.prototype.epilog = function(exports/*Type*/){
-	var result = null;
-	var closure = new Closure();
-	closure.result = JsString.makeEmpty();
-	JsMap.forEach(exports, genExportsAdaptor, closure);
-	result = closure.result;
-	if (JsString.len(result) != 0){
-		result = JsString.appendChar(JsString.appendChar(JsString.appendChar(JsString.concat(JsString.appendChar(JsString.make("return {"), 10), result), 10), 125), 10);
-	}
-	result = JsString.concat(result, JsString.make("}("));
-	closure.result = JsString.makeEmpty();
-	JsMap.forEachString(this.imports, genImportListAdaptor, closure);
-	result = JsString.appendChar(JsString.concat(JsString.concat(result, closure.result), JsString.make(");")), 10);
-	return result;
-}
-
-function initSimpleGenerator(g/*SimpleGenerator*/){
-	g.mResult = JsString.makeEmpty();
-}
-
-function makeSimpleGenerator(){
-	var result = null;
-	result = new SimpleGenerator();
-	initSimpleGenerator(result);
-	return result;
-}
-
-function makeGenerator(){
-	var result = null;
-	result = new Generator();
-	initSimpleGenerator(result);
-	return result;
-}
-
-function makeModuleGenerator(name/*Type*/, imports/*Strings*/){
-	var result = null;
-	result = new ModuleGenerator();
-	result.name = name;
-	result.imports = imports;
-	return result;
-}
-exports.Designator = Designator;
-exports.Const = Const;
-exports.IntConst = IntConst;
-exports.RealConst = RealConst;
-exports.SetConst = SetConst;
-exports.StrConst = StrConst;
-exports.Expression = Expression;
-exports.nullGenerator = function(){return nullGenerator;};
-exports.makeIntConst = makeIntConst;
-exports.makeRealConst = makeRealConst;
-exports.makeSetConst = makeSetConst;
-exports.makeStrConst = makeStrConst;
-exports.makeStringConst = makeStringConst;
-exports.makeExpressionWithPrecedence = makeExpressionWithPrecedence;
-exports.makeExpression = makeExpression;
-exports.makeSimpleExpression = makeSimpleExpression;
-exports.makeDesignator = makeDesignator;
-exports.derefExpression = derefExpression;
-exports.refExpression = refExpression;
-exports.adjustPrecedence = adjustPrecedence;
-exports.genExport = genExport;
-exports.makeSimpleGenerator = makeSimpleGenerator;
-exports.makeGenerator = makeGenerator;
-exports.makeModuleGenerator = makeModuleGenerator;

+ 0 - 28
src/js/CodePrecedence.js

@@ -1,28 +0,0 @@
-var none = 0;
-var unary = 4;
-var mulDivMod = 5;
-var addSub = 6;
-var shift = 7;
-var relational = 8;
-var equal = 9;
-var bitAnd = 10;
-var bitXor = 11;
-var bitOr = 12;
-var and = 13;
-var or = 14;
-var conditional = 15;
-var assignment = 17;
-exports.none = none;
-exports.unary = unary;
-exports.mulDivMod = mulDivMod;
-exports.addSub = addSub;
-exports.shift = shift;
-exports.relational = relational;
-exports.equal = equal;
-exports.bitAnd = bitAnd;
-exports.bitXor = bitXor;
-exports.bitOr = bitOr;
-exports.and = and;
-exports.or = or;
-exports.conditional = conditional;
-exports.assignment = assignment;

+ 0 - 16
src/js/Context.js

@@ -1,16 +0,0 @@
-var RTL$ = require("rtl.js");
-var JsString = require("js/JsString.js");
-var OberonRtl = require("js/OberonRtl.js");
-var Object = require("js/Object.js");
-var ScopeBase = require("js/ScopeBase.js");
-var Type = RTL$.extend({
-	init: function Type(){
-		this.handleChar = null;
-		this.handleLiteral = null;
-		this.handleString = null;
-		this.handleIdent = null;
-		this.isLexem = null;
-		this.qualifyScope = null;
-	}
-});
-exports.Type = Type;

+ 0 - 15
src/js/Errors.js

@@ -1,15 +0,0 @@
-var RTL$ = require("rtl.js");
-var JS = GLOBAL;
-var JsString = require("js/JsString.js");
-var Error = RTL$.extend({
-	init: function Error(){
-	}
-});
-
-function raise(msg/*Type*/){
-	throw new Error(msg);
-}
-Error = function(msg){this.__msg = msg;};
-Error.prototype.toString = function(){return this.__msg;};;
-exports.Error = Error;
-exports.raise = raise;

+ 0 - 90
src/js/JsArray.js

@@ -1,90 +0,0 @@
-var RTL$ = require("rtl.js");
-var JS = GLOBAL;
-var Object = require("js/Object.js");
-var JsString = require("js/JsString.js");
-var Type = RTL$.extend({
-	init: function Type(){
-	}
-});
-var Strings = RTL$.extend({
-	init: function Strings(){
-	}
-});
-
-function len(a/*Type*/){
-	var result = 0;
-	result = a.length;
-	return result;
-}
-
-function stringsLen(a/*Strings*/){
-	var result = 0;
-	result = a.length;
-	return result;
-}
-
-function add(a/*Type*/, o/*PType*/){
-	a.push(o);
-}
-
-function addString(a/*Strings*/, o/*Type*/){
-	a.push(o);
-}
-
-function removeString(a/*Strings*/, i/*INTEGER*/){
-	a.splice(i, 1);
-}
-
-function at(a/*Type*/, i/*INTEGER*/){
-	var result = null;
-	result = a[i];
-	return result;
-}
-
-function stringsAt(a/*Strings*/, i/*INTEGER*/){
-	var result = null;
-	result = a[i];
-	return result;
-}
-
-function stringsIndexOf(a/*Strings*/, x/*Type*/){
-	var result = 0;
-	result = a.indexOf(x);
-	return result;
-}
-
-function contains(a/*Type*/, x/*PType*/){
-	var result = false;
-	result = (a.indexOf(x) != -1);
-	return result;
-}
-
-function containsString(a/*Strings*/, x/*Type*/){
-	return stringsIndexOf(a, x) != -1;
-}
-
-function make(){
-	var result = null;
-	result = [];
-	return result;
-}
-
-function makeStrings(){
-	var result = null;
-	result = [];
-	return result;
-}
-exports.Type = Type;
-exports.Strings = Strings;
-exports.len = len;
-exports.stringsLen = stringsLen;
-exports.add = add;
-exports.addString = addString;
-exports.removeString = removeString;
-exports.at = at;
-exports.stringsAt = stringsAt;
-exports.stringsIndexOf = stringsIndexOf;
-exports.contains = contains;
-exports.containsString = containsString;
-exports.make = make;
-exports.makeStrings = makeStrings;

+ 0 - 55
src/js/JsMap.js

@@ -1,55 +0,0 @@
-var RTL$ = require("rtl.js");
-var JS = GLOBAL;
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var Type = RTL$.extend({
-	init: function Type(){
-	}
-});
-var Strings = RTL$.extend({
-	init: function Strings(){
-	}
-});
-
-function make(){
-	var result = null;
-	result = {};
-	return result;
-}
-
-function has(m/*Type*/, s/*Type*/){
-	var result = false;
-	result = m.hasOwnProperty(s);
-	return result;
-}
-
-function find(m/*Type*/, s/*Type*/, r/*VAR PType*/){
-	var result = false;
-	var value = m[s]; if (value !== undefined){result = true; r.set(value);};
-	return result;
-}
-
-function put(m/*Type*/, s/*Type*/, o/*PType*/){
-	m[s] = o;
-}
-
-function erase(m/*Type*/, s/*Type*/){
-	delete m[s];
-}
-
-function forEach(m/*Type*/, p/*ForEachProc*/, closure/*VAR Type*/){
-	for(var key in m){p(key, m[key], closure)};
-}
-
-function forEachString(m/*Strings*/, p/*ForEachStringProc*/, closure/*VAR Type*/){
-	for(var key in m){p(key, m[key], closure)};
-}
-exports.Type = Type;
-exports.Strings = Strings;
-exports.make = make;
-exports.has = has;
-exports.find = find;
-exports.put = put;
-exports.erase = erase;
-exports.forEach = forEach;
-exports.forEachString = forEachString;

+ 0 - 89
src/js/JsString.js

@@ -1,89 +0,0 @@
-var RTL$ = require("rtl.js");
-var JS = GLOBAL;
-var Type = RTL$.extend({
-	init: function Type(){
-	}
-});
-
-function make(s/*ARRAY OF CHAR*/){
-	var result = null;
-	var i = 0;
-	result = '';
-	for (i = 0; i <= s.length - 1 | 0; ++i){
-		result += JS.String.fromCharCode(s.charCodeAt(i));
-	}
-	return result;
-}
-
-function makeEmpty(){
-	var result = null;
-	result = '';
-	return result;
-}
-
-function fromInt(i/*INTEGER*/){
-	var result = null;
-	result = '' + i;
-	return result;
-}
-
-function len(self/*Type*/){
-	var result = 0;
-	result = self.length;
-	return result;
-}
-
-function at(self/*Type*/, pos/*INTEGER*/){
-	var result = 0;
-	result = self.charCodeAt(pos);
-	return result;
-}
-
-function indexOf(self/*Type*/, c/*CHAR*/){
-	var result = 0;
-	result = self.indexOf(JS.String.fromCharCode(c));
-	return result;
-}
-
-function indexOfFrom(self/*Type*/, c/*CHAR*/, pos/*INTEGER*/){
-	var result = 0;
-	result = self.indexOf(JS.String.fromCharCode(c), pos);
-	return result;
-}
-
-function substr(self/*Type*/, pos/*INTEGER*/, len/*INTEGER*/){
-	var result = null;
-	result = self.substr(pos, len);
-	return result;
-}
-
-function appendChar(self/*Type*/, c/*CHAR*/){
-	var result = null;
-	result = self;
-	result += JS.String.fromCharCode(c);
-	return result;
-}
-
-function concat(self/*Type*/, add/*Type*/){
-	var result = null;
-	result = self + add;
-	return result;
-}
-
-function eq(s1/*Type*/, s2/*Type*/){
-	var result = false;
-	result = s1 == s2;
-	return result;
-}
-exports.Type = Type;
-exports.make = make;
-exports.makeEmpty = makeEmpty;
-exports.fromInt = fromInt;
-exports.len = len;
-exports.at = at;
-exports.indexOf = indexOf;
-exports.indexOfFrom = indexOfFrom;
-exports.substr = substr;
-exports.appendChar = appendChar;
-exports.concat = concat;
-exports.eq = eq;

+ 0 - 9
src/js/Language.js

@@ -1,9 +0,0 @@
-var RTL$ = require("rtl.js");
-var Cast = require("js/Cast.js");
-var JsString = require("js/JsString.js");
-var T = require("js/Types.js");
-var Types = RTL$.extend({
-	init: function Types(){
-	}
-});
-exports.Types = Types;

+ 0 - 8
src/js/LanguageContext.js

@@ -1,8 +0,0 @@
-var Context = require("js/Context.js");
-var Language = require("js/Language.js");
-var Type = Context.Type.extend({
-	init: function Type(){
-		Context.Type.prototype.init.call(this);
-	}
-});
-exports.Type = Type;

+ 0 - 201
src/js/Lexer.js

@@ -1,201 +0,0 @@
-var RTL$ = require("rtl.js");
-var Context = require("js/Context.js");
-var JS = GLOBAL;
-var JsString = require("js/JsString.js");
-var Errors = require("js/Errors.js");
-var Stream = require("js/Stream.js");
-var quote = "\"";
-var commentBegin = "(*";
-var commentEnd = "*)";
-var jsReservedWords = "break case catch continue debugger default delete do else finally for function if in instanceof new return switch this throw try typeof var void while with false true null class enum export extends import super implements interface let package private protected public static yield Math";
-var Literal = RTL$.extend({
-	init: function Literal(){
-		this.s = RTL$.makeCharArray(1);
-	}
-});
-
-function isDigit(c/*CHAR*/){
-	return c >= 48 && c <= 57;
-}
-
-function isLetter(c/*CHAR*/){
-	return c >= 97 && c <= 122 || c >= 65 && c <= 90;
-}
-
-function digit(stream/*Type*/, context/*Type*/){
-	var result = false;
-	var c = 0;
-	if (!Stream.eof(stream)){
-		c = Stream.getChar(stream);
-		if (isDigit(c)){
-			context.handleChar(c);
-			result = true;
-		}
-	}
-	return result;
-}
-
-function hexDigit(stream/*Type*/, context/*Type*/){
-	var result = false;
-	var c = 0;
-	c = Stream.getChar(stream);
-	if (isDigit(c) || c >= 65 && c <= 70){
-		context.handleChar(c);
-		result = true;
-	}
-	return result;
-}
-
-function handleLiteral(context/*Type*/, s/*ARRAY OF CHAR*/){
-	var result = false;
-	var r = context.handleLiteral(JsString.make(s)); result = (r === undefined || r);
-	return result;
-}
-
-function point(stream/*Type*/, context/*Type*/){
-	var result = false;
-	if (!Stream.eof(stream) && Stream.getChar(stream) == 46 && (Stream.eof(stream) || Stream.peekChar(stream) != 46)){
-		result = handleLiteral(context, ".");
-	}
-	return result;
-}
-
-function string(stream/*Type*/, context/*Type*/){
-	var result = false;
-	var c = 0;
-	var s = null;
-	if (!Stream.eof(stream)){
-		c = Stream.getChar(stream);
-		if (c == 34){
-			if (!Stream.eof(stream)){
-				s = JsString.make("");
-				c = Stream.getChar(stream);
-				while (true){
-					if (c != 34 && !Stream.eof(stream)){
-						if (c != 34){
-							s = JsString.appendChar(s, c);
-						}
-						c = Stream.getChar(stream);
-					} else break;
-				}
-			}
-			if (s == null || c != 34){
-				Errors.raise(JsString.make("unexpected end of string"));
-			}
-			context.handleString(s);
-			result = true;
-		}
-	}
-	return result;
-}
-
-function isReservedWorld(s/*Type*/, words/*ARRAY OF CHAR*/){
-	var i = 0;var w = 0;
-	while (true){
-		if (w < words.length && i < JsString.len(s) && words.charCodeAt(w) == JsString.at(s, i) && (i != 0 || w == 0 || words.charCodeAt(w - 1 | 0) == 32)){
-			++w;
-			++i;
-		}
-		else if (w < words.length && (i < JsString.len(s) || words.charCodeAt(w) != 32)){
-			++w;
-			i = 0;
-		} else break;
-	}
-	return i == JsString.len(s);
-}
-
-function ident(stream/*Type*/, context/*Type*/, reservedWords/*ARRAY OF CHAR*/){
-	var result = false;
-	var c = 0;
-	var s = null;
-	if (!Stream.eof(stream)){
-		c = Stream.getChar(stream);
-		if (isLetter(c)){
-			s = JsString.make("");
-			while (true){
-				if (!Stream.eof(stream) && (isLetter(c) || isDigit(c))){
-					s = JsString.appendChar(s, c);
-					c = Stream.getChar(stream);
-				} else break;
-			}
-			if (isLetter(c) || isDigit(c)){
-				s = JsString.appendChar(s, c);
-			}
-			else {
-				Stream.next(stream, -1);
-			}
-			if (!isReservedWorld(s, reservedWords)){
-				if (isReservedWorld(s, jsReservedWords)){
-					s = JsString.appendChar(s, 36);
-				}
-				context.handleIdent(s);
-				result = true;
-			}
-		}
-	}
-	return result;
-}
-
-function skipComment(stream/*Type*/, context/*Type*/){
-	var result = false;
-	if (Stream.peekStr(stream, commentBegin)){
-		Stream.next(stream, commentBegin.length);
-		while (true){
-			if (!Stream.peekStr(stream, commentEnd)){
-				if (!skipComment(stream, context)){
-					Stream.next(stream, 1);
-					if (Stream.eof(stream)){
-						Errors.raise(JsString.make("comment was not closed"));
-					}
-				}
-			} else break;
-		}
-		Stream.next(stream, commentEnd.length);
-		result = true;
-	}
-	return result;
-}
-
-function readSpaces(c/*CHAR*/){
-	return c == 32 || c == 8 || c == 9 || c == 10 || c == 13;
-}
-
-function skipSpaces(stream/*Type*/, context/*Type*/){
-	if (context.isLexem == null || !context.isLexem()){
-		while (true){
-			if (Stream.read(stream, readSpaces) && skipComment(stream, context)){
-			} else break;
-		}
-	}
-}
-
-function separator(stream/*Type*/, context/*Type*/){
-	return Stream.eof(stream) || !isLetter(Stream.peekChar(stream));
-}
-
-function makeLiteral(s/*ARRAY OF CHAR*/){
-	var result = null;
-	result = new Literal();
-	result.s = s;
-	return result;
-}
-
-function literal(l/*Literal*/, stream/*Type*/, context/*Type*/){
-	var result = false;
-	if (Stream.peekStr(stream, l.s)){
-		Stream.next(stream, l.s.length);
-		if (context.isLexem != null && context.isLexem() || !isLetter(l.s.charCodeAt(l.s.length - 1 | 0)) || Stream.eof(stream) || !isLetter(Stream.peekChar(stream)) && !isDigit(Stream.peekChar(stream))){
-			result = handleLiteral(context, l.s);
-		}
-	}
-	return result;
-}
-exports.digit = digit;
-exports.hexDigit = hexDigit;
-exports.point = point;
-exports.string = string;
-exports.ident = ident;
-exports.skipSpaces = skipSpaces;
-exports.separator = separator;
-exports.makeLiteral = makeLiteral;
-exports.literal = literal;

+ 0 - 120
src/js/Module.js

@@ -1,120 +0,0 @@
-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;

+ 0 - 13
src/js/OberonRtl.js

@@ -1,13 +0,0 @@
-var RTL$ = require("rtl.js");
-var JsString = require("js/JsString.js");
-var Type = RTL$.extend({
-	init: function Type(){
-		this.copy = null;
-		this.strCmp = null;
-		this.assignArrayFromString = null;
-		this.setInclL = null;
-		this.setInclR = null;
-		this.assertId = null;
-	}
-});
-exports.Type = Type;

+ 0 - 6
src/js/Object.js

@@ -1,6 +0,0 @@
-var RTL$ = require("rtl.js");
-var Type = RTL$.extend({
-	init: function Type(){
-	}
-});
-exports.Type = Type;

+ 0 - 668
src/js/Operator.js

@@ -1,668 +0,0 @@
-var RTL$ = require("rtl.js");
-var Cast = require("js/Cast.js");
-var Code = require("js/Code.js");
-var Errors = require("js/Errors.js");
-var JsString = require("js/JsString.js");
-var OberonRtl = require("js/OberonRtl.js");
-var Precedence = require("js/CodePrecedence.js");
-var Types = require("js/Types.js");
-var CodeMaker = RTL$.extend({
-	init: function CodeMaker(){
-	}
-});
-var SimpleCodeMaker = CodeMaker.extend({
-	init: function SimpleCodeMaker(){
-		CodeMaker.prototype.init.call(this);
-		this.code = null;
-	}
-});
-var IntCodeMaker = SimpleCodeMaker.extend({
-	init: function IntCodeMaker(){
-		SimpleCodeMaker.prototype.init.call(this);
-	}
-});
-var PredCodeMaker = CodeMaker.extend({
-	init: function PredCodeMaker(){
-		CodeMaker.prototype.init.call(this);
-		this.pred = null;
-	}
-});
-var CastToUint8 = Cast.CastOp.extend({
-	init: function CastToUint8(){
-		Cast.CastOp.prototype.init.call(this);
-	}
-});
-var openArrayChar = null;
-var castOperations = new Cast.Operations();
-var castToUint8 = null;
-
-function binary(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, op/*BinaryOp*/, code/*PCodeMaker*/, precedence/*INTEGER*/, optResultType/*PType*/, optResultPrecedence/*INTEGER*/){
-	var result = null;
-	var leftValue = null;var rightValue = null;var resultValue = null;
-	var leftCode = null;var rightCode = null;var resultCode = null;
-	var resultType = null;
-	var resultPrecedence = 0;
-	var rightExpDeref = null;
-	leftValue = left.constValue();
-	rightValue = right.constValue();
-	if (leftValue != null && rightValue != null){
-		resultValue = op(leftValue, rightValue);
-	}
-	leftCode = Code.adjustPrecedence(Code.derefExpression(left), precedence);
-	rightExpDeref = Code.derefExpression(right);
-	if (precedence != Precedence.none){
-		rightCode = Code.adjustPrecedence(rightExpDeref, precedence - 1 | 0);
-	}
-	else {
-		rightCode = rightExpDeref.code();
-	}
-	resultCode = code.make(leftCode, rightCode, rtl);
-	if (optResultType != null){
-		resultType = optResultType;
-	}
-	else {
-		resultType = left.type();
-	}
-	if (optResultPrecedence != Precedence.none){
-		resultPrecedence = optResultPrecedence;
-	}
-	else {
-		resultPrecedence = precedence;
-	}
-	return Code.makeExpressionWithPrecedence(resultCode, resultType, null, resultValue, resultPrecedence);
-}
-SimpleCodeMaker.prototype.make = function(left/*Type*/, right/*Type*/, rtl/*PType*/){
-	return JsString.concat(JsString.concat(left, this.code), right);
-}
-IntCodeMaker.prototype.make = function(left/*Type*/, right/*Type*/, rtl/*PType*/){
-	return JsString.concat(SimpleCodeMaker.prototype.make.call(this, left, right, rtl), JsString.make(" | 0"));
-}
-PredCodeMaker.prototype.make = function(left/*Type*/, right/*Type*/, rtl/*PType*/){
-	return this.pred(left, right, rtl);
-}
-
-function makeSimpleCodeMaker(code/*ARRAY OF CHAR*/){
-	var result = null;
-	result = new SimpleCodeMaker();
-	result.code = JsString.make(code);
-	return result;
-}
-
-function makeIntCodeMaker(code/*ARRAY OF CHAR*/){
-	var result = null;
-	result = new IntCodeMaker();
-	result.code = JsString.make(code);
-	return result;
-}
-
-function makePredCodeMaker(pred/*CodePredicate*/){
-	var result = null;
-	result = new PredCodeMaker();
-	result.pred = pred;
-	return result;
-}
-
-function binaryWithCodeEx(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, op/*BinaryOp*/, code/*ARRAY OF CHAR*/, precedence/*INTEGER*/, optResultType/*PType*/, optResultPrecedence/*INTEGER*/){
-	return binary(left, right, rtl, op, makeSimpleCodeMaker(code), precedence, optResultType, optResultPrecedence);
-}
-
-function binaryWithCode(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, op/*BinaryOp*/, code/*ARRAY OF CHAR*/, precedence/*INTEGER*/){
-	return binaryWithCodeEx(left, right, rtl, op, code, precedence, null, Precedence.none);
-}
-
-function promoteToWideIfNeeded(e/*PExpression*/){
-	var result = null;
-	if (e.type() != Types.basic().uint8){
-		result = e;
-	}
-	else {
-		result = Code.makeExpressionWithPrecedence(e.code(), Types.basic().integer, e.designator(), e.constValue(), e.maxPrecedence());
-	}
-	return result;
-}
-
-function binaryInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, op/*BinaryOp*/, code/*ARRAY OF CHAR*/, precedence/*INTEGER*/){
-	return promoteToWideIfNeeded(binary(left, right, rtl, op, makeIntCodeMaker(code), precedence, null, Precedence.bitOr));
-}
-
-function binaryPred(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, op/*BinaryOp*/, pred/*CodePredicate*/){
-	return binary(left, right, rtl, op, makePredCodeMaker(pred), Precedence.none, null, Precedence.none);
-}
-
-function unary(e/*PExpression*/, op/*UnaryOp*/, code/*ARRAY OF CHAR*/){
-	var value = null;
-	var resultCode = null;
-	value = e.constValue();
-	if (value != null){
-		value = op(value);
-	}
-	resultCode = JsString.concat(JsString.make(code), Code.adjustPrecedence(Code.derefExpression(e), Precedence.unary));
-	return Code.makeExpression(resultCode, e.type(), null, value);
-}
-
-function castToStr(e/*PExpression*/, rtl/*PType*/){
-	var resultExpression = null;
-	var op = null;
-	var ignored = 0;
-	ignored = Cast.implicit(e.type(), openArrayChar, false, castOperations, {set: function($v){op = $v;}, get: function(){return op;}});
-	if (op != null){
-		resultExpression = op.make(rtl, e);
-	}
-	else {
-		resultExpression = e;
-	}
-	return resultExpression.code();
-}
-
-function opAddReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeRealConst(RTL$.typeGuard(left, Code.RealConst).value + RTL$.typeGuard(right, Code.RealConst).value);
-}
-
-function opAddInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value + RTL$.typeGuard(right, Code.IntConst).value | 0);
-}
-
-function opSubReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeRealConst(RTL$.typeGuard(left, Code.RealConst).value - RTL$.typeGuard(right, Code.RealConst).value);
-}
-
-function opSubInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value - RTL$.typeGuard(right, Code.IntConst).value | 0);
-}
-
-function opMulReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeRealConst(RTL$.typeGuard(left, Code.RealConst).value * RTL$.typeGuard(right, Code.RealConst).value);
-}
-
-function opMulInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value * RTL$.typeGuard(right, Code.IntConst).value | 0);
-}
-
-function opDivReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeRealConst(RTL$.typeGuard(left, Code.RealConst).value / RTL$.typeGuard(right, Code.RealConst).value);
-}
-
-function opDivInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value / RTL$.typeGuard(right, Code.IntConst).value | 0);
-}
-
-function opMod(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value % RTL$.typeGuard(right, Code.IntConst).value);
-}
-
-function opSetUnion(left/*PConst*/, right/*PConst*/){
-	return Code.makeSetConst(RTL$.typeGuard(left, Code.SetConst).value | RTL$.typeGuard(right, Code.SetConst).value);
-}
-
-function opSetDiff(left/*PConst*/, right/*PConst*/){
-	return Code.makeSetConst(RTL$.typeGuard(left, Code.SetConst).value & ~RTL$.typeGuard(right, Code.SetConst).value);
-}
-
-function opSetIntersection(left/*PConst*/, right/*PConst*/){
-	return Code.makeSetConst(RTL$.typeGuard(left, Code.SetConst).value & RTL$.typeGuard(right, Code.SetConst).value);
-}
-
-function opSetSymmetricDiff(left/*PConst*/, right/*PConst*/){
-	return Code.makeSetConst(RTL$.typeGuard(left, Code.SetConst).value ^ RTL$.typeGuard(right, Code.SetConst).value);
-}
-
-function opSetInclL(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.setInclL(RTL$.typeGuard(left, Code.SetConst).value, RTL$.typeGuard(right, Code.SetConst).value) ? 1 : 0);
-}
-
-function opSetInclR(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.setInclR(RTL$.typeGuard(left, Code.SetConst).value, RTL$.typeGuard(right, Code.SetConst).value) ? 1 : 0);
-}
-
-function opOr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value != 0 || RTL$.typeGuard(right, Code.IntConst).value != 0 ? 1 : 0);
-}
-
-function opAnd(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value != 0 && RTL$.typeGuard(right, Code.IntConst).value != 0 ? 1 : 0);
-}
-
-function opEqualInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value == RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opEqualReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value == RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opEqualSet(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.SetConst).value == RTL$.typeGuard(right, Code.SetConst).value ? 1 : 0);
-}
-
-function opNotEqualInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value != RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opNotEqualReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value != RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opNotEqualSet(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.SetConst).value != RTL$.typeGuard(right, Code.SetConst).value ? 1 : 0);
-}
-
-function opLessInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value < RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opLessReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value < RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opGreaterInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value > RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opGreaterReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value > RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opEqLessInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value <= RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opEqLessReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value <= RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opEqGreaterInt(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value >= RTL$.typeGuard(right, Code.IntConst).value ? 1 : 0);
-}
-
-function opEqGreaterReal(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.RealConst).value >= RTL$.typeGuard(right, Code.RealConst).value ? 1 : 0);
-}
-
-function opNot(x/*PConst*/){
-	return Code.makeIntConst(!RTL$.typeGuard(x, Code.IntConst).value != 0 ? 1 : 0);
-}
-
-function opNegateInt(x/*PConst*/){
-	return Code.makeIntConst(-RTL$.typeGuard(x, Code.IntConst).value);
-}
-
-function opNegateReal(x/*PConst*/){
-	return Code.makeRealConst(-RTL$.typeGuard(x, Code.RealConst).value);
-}
-
-function opUnaryPlus(x/*PConst*/){
-	return x;
-}
-
-function opSetComplement(x/*PConst*/){
-	return Code.makeSetConst(~RTL$.typeGuard(x, Code.SetConst).value);
-}
-
-function opLsl(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value << RTL$.typeGuard(right, Code.IntConst).value);
-}
-
-function opAsr(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value >> RTL$.typeGuard(right, Code.IntConst).value);
-}
-
-function opRor(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value >>> RTL$.typeGuard(right, Code.IntConst).value);
-}
-
-function codeSetInclL(left/*Type*/, right/*Type*/, rtl/*PType*/){
-	return rtl.setInclL(left, right);
-}
-
-function codeSetInclR(left/*Type*/, right/*Type*/, rtl/*PType*/){
-	return rtl.setInclR(left, right);
-}
-
-function strCmp(op/*ARRAY OF CHAR*/, left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return Code.makeSimpleExpression(JsString.concat(JsString.concat(rtl.strCmp(castToStr(left, rtl), castToStr(right, rtl)), JsString.make(op)), JsString.make("0")), Types.basic().bool);
-}
-
-function assign(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	var designator = null;
-	var info = null;
-	var leftCode = null;var rightCode = null;
-	var leftType = null;var rightType = null;
-	var isArray = false;
-	var castOperation = null;
-	var castExp = null;
-	var ignored = false;
-	var result = null;
-	
-	function assignArrayFromString(a/*Array*/, s/*String*/){
-		if (Types.arrayLength(a) == Types.openArrayLength){
-			Errors.raise(JsString.concat(JsString.make("string cannot be assigned to open "), a.description()));
-		}
-		else if (Types.stringLen(s) > Types.arrayLength(a)){
-			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.fromInt(Types.arrayLength(a)), JsString.make("-character ARRAY is too small for ")), JsString.fromInt(Types.stringLen(s))), JsString.make("-character string")));
-		}
-		return rtl.assignArrayFromString(leftCode, rightCode);
-	}
-	designator = left.designator();
-	info = designator.info();
-	if (!(info instanceof Types.Variable) || Types.isVariableReadOnly(RTL$.typeGuard(info, Types.Variable))){
-		Errors.raise(JsString.concat(JsString.make("cannot assign to "), info.idType()));
-	}
-	leftCode = left.lval();
-	rightCode = right.code();
-	leftType = left.type();
-	rightType = right.type();
-	isArray = leftType instanceof Types.Array;
-	if (isArray && Types.arrayElementsType(RTL$.typeGuard(leftType, Types.Array)) == Types.basic().ch && rightType instanceof Types.String){
-		result = assignArrayFromString(RTL$.typeGuard(leftType, Types.Array), RTL$.typeGuard(rightType, Types.String));
-	}
-	else {
-		if (Cast.implicit(rightType, leftType, false, castOperations, {set: function($v){castOperation = $v;}, get: function(){return castOperation;}}) != Cast.errNo){
-			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("type mismatch: '"), leftCode), JsString.make("' is '")), leftType.description()), JsString.make("' and cannot be assigned to '")), rightType.description()), JsString.make("' expression")));
-		}
-		if (isArray && rightType instanceof Types.Array && Types.arrayLength(RTL$.typeGuard(leftType, Types.Array)) == Types.openArrayLength){
-			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("'"), leftCode), JsString.make("' is open '")), leftType.description()), JsString.make("' and cannot be assigned")));
-		}
-		if (isArray || rightType instanceof Types.Record){
-			result = rtl.copy(rightCode, leftCode);
-		}
-		else {
-			if (castOperation != null){
-				castExp = castOperation.make(rtl, Code.derefExpression(right));
-			}
-			else {
-				castExp = Code.derefExpression(right);
-			}
-			rightCode = castExp.code();
-			if (info instanceof Types.VariableRef){
-				rightCode = JsString.concat(JsString.concat(JsString.make(".set("), rightCode), JsString.make(")"));
-			}
-			else {
-				rightCode = JsString.concat(JsString.make(" = "), rightCode);
-			}
-			result = JsString.concat(leftCode, rightCode);
-		}
-	}
-	return result;
-}
-
-function inplace(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/, code/*ARRAY OF CHAR*/, altOp/*BinaryProc*/){
-	var designator = null;
-	var rightExp = null;
-	var result = null;
-	designator = left.designator();
-	if (designator.info() instanceof Types.VariableRef){
-		result = assign(left, altOp(left, right, rtl), rtl);
-	}
-	else {
-		rightExp = Code.derefExpression(right);
-		result = JsString.concat(JsString.concat(left.code(), JsString.make(code)), rightExp.code());
-	}
-	return result;
-}
-
-function addReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opAddReal, " + ", Precedence.addSub);
-}
-
-function addInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryInt(left, right, rtl, opAddInt, " + ", Precedence.addSub);
-}
-
-function subReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opSubReal, " - ", Precedence.addSub);
-}
-
-function subInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryInt(left, right, rtl, opSubInt, " - ", Precedence.addSub);
-}
-
-function mulReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opMulReal, " * ", Precedence.mulDivMod);
-}
-
-function mulInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryInt(left, right, rtl, opMulInt, " * ", Precedence.mulDivMod);
-}
-
-function divReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opDivReal, " / ", Precedence.mulDivMod);
-}
-
-function divInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryInt(left, right, rtl, opDivInt, " / ", Precedence.mulDivMod);
-}
-
-function mod(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opMod, " % ", Precedence.mulDivMod);
-}
-
-function setUnion(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opSetUnion, " | ", Precedence.bitOr);
-}
-
-function setDiff(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opSetDiff, " & ~", Precedence.bitAnd);
-}
-
-function setIntersection(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opSetIntersection, " & ", Precedence.bitAnd);
-}
-
-function setSymmetricDiff(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opSetSymmetricDiff, " ^ ", Precedence.bitXor);
-}
-
-function setInclL(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryPred(left, right, rtl, opSetInclL, codeSetInclL);
-}
-
-function setInclR(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryPred(left, right, rtl, opSetInclR, codeSetInclR);
-}
-
-function or(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opOr, " || ", Precedence.or);
-}
-
-function and(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opAnd, " && ", Precedence.and);
-}
-
-function equalInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqualInt, " == ", Precedence.equal);
-}
-
-function equalReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqualReal, " == ", Precedence.equal);
-}
-
-function equalSet(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqualSet, " == ", Precedence.equal);
-}
-
-function equalStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" == ", left, right, rtl);
-}
-
-function notEqualInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opNotEqualInt, " != ", Precedence.equal);
-}
-
-function notEqualReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opNotEqualReal, " != ", Precedence.equal);
-}
-
-function notEqualSet(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opNotEqualSet, " != ", Precedence.equal);
-}
-
-function notEqualStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" != ", left, right, rtl);
-}
-
-function is(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCodeEx(left, right, rtl, null, " instanceof ", Precedence.relational, Types.basic().bool, Precedence.none);
-}
-
-function lessInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opLessInt, " < ", Precedence.relational);
-}
-
-function lessReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opLessReal, " < ", Precedence.relational);
-}
-
-function lessStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" < ", left, right, rtl);
-}
-
-function greaterInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opGreaterInt, " > ", Precedence.relational);
-}
-
-function greaterReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opGreaterReal, " > ", Precedence.relational);
-}
-
-function greaterStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" > ", left, right, rtl);
-}
-
-function eqLessInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqLessInt, " <= ", Precedence.relational);
-}
-
-function eqLessReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqLessReal, " <= ", Precedence.relational);
-}
-
-function eqLessStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" <= ", left, right, rtl);
-}
-
-function eqGreaterInt(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqGreaterInt, " >= ", Precedence.relational);
-}
-
-function eqGreaterReal(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opEqGreaterReal, " >= ", Precedence.relational);
-}
-
-function eqGreaterStr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return strCmp(" >= ", left, right, rtl);
-}
-
-function not(x/*PExpression*/, rtl/*PType*/){
-	return unary(x, opNot, "!");
-}
-
-function negateInt(x/*PExpression*/, rtl/*PType*/){
-	return promoteToWideIfNeeded(unary(x, opNegateInt, "-"));
-}
-
-function negateReal(x/*PExpression*/, rtl/*PType*/){
-	return promoteToWideIfNeeded(unary(x, opNegateReal, "-"));
-}
-
-function unaryPlus(x/*PExpression*/, rtl/*PType*/){
-	return unary(x, opUnaryPlus, "");
-}
-
-function setComplement(x/*PExpression*/, rtl/*PType*/){
-	return unary(x, opSetComplement, "~");
-}
-
-function lsl(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opLsl, " << ", Precedence.shift);
-}
-
-function asr(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opAsr, " >> ", Precedence.shift);
-}
-
-function ror(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return binaryWithCode(left, right, rtl, opRor, " >>> ", Precedence.shift);
-}
-
-function mulInplace(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return inplace(left, right, rtl, " *= ", mulReal);
-}
-
-function divInplace(left/*PExpression*/, right/*PExpression*/, rtl/*PType*/){
-	return inplace(left, right, rtl, " /= ", divReal);
-}
-
-function pow2(e/*PExpression*/){
-	var derefExp = null;
-	derefExp = Code.derefExpression(e);
-	return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.make("Math.pow(2, "), derefExp.code()), JsString.make(")")), Types.basic().real);
-}
-
-function log2(e/*PExpression*/){
-	var derefExp = null;
-	derefExp = Code.derefExpression(e);
-	return Code.makeExpressionWithPrecedence(JsString.concat(JsString.concat(JsString.make("(Math.log("), derefExp.code()), JsString.make(") / Math.LN2) | 0")), Types.basic().integer, null, null, Precedence.bitOr);
-}
-
-function opCastToUint8(left/*PConst*/, right/*PConst*/){
-	return Code.makeIntConst(RTL$.typeGuard(left, Code.IntConst).value * RTL$.typeGuard(right, Code.IntConst).value | 0);
-}
-CastToUint8.prototype.make = function(rtl/*PType*/, e/*PExpression*/){
-	return binaryWithCode(e, Code.makeExpression(JsString.make("0xFF"), Types.basic().integer, null, Code.makeIntConst(255)), rtl, opCastToUint8, " & ", Precedence.bitAnd);
-}
-openArrayChar = Types.makeArray(null, null, Types.basic().ch, Types.openArrayLength);
-castToUint8 = new CastToUint8();
-castOperations.castToUint8 = castToUint8;
-exports.castOperations = function(){return castOperations;};
-exports.binaryWithCode = binaryWithCode;
-exports.assign = assign;
-exports.addReal = addReal;
-exports.addInt = addInt;
-exports.subReal = subReal;
-exports.subInt = subInt;
-exports.mulReal = mulReal;
-exports.mulInt = mulInt;
-exports.divReal = divReal;
-exports.divInt = divInt;
-exports.mod = mod;
-exports.setUnion = setUnion;
-exports.setDiff = setDiff;
-exports.setIntersection = setIntersection;
-exports.setSymmetricDiff = setSymmetricDiff;
-exports.setInclL = setInclL;
-exports.setInclR = setInclR;
-exports.or = or;
-exports.and = and;
-exports.equalInt = equalInt;
-exports.equalReal = equalReal;
-exports.equalSet = equalSet;
-exports.equalStr = equalStr;
-exports.notEqualInt = notEqualInt;
-exports.notEqualReal = notEqualReal;
-exports.notEqualSet = notEqualSet;
-exports.notEqualStr = notEqualStr;
-exports.is = is;
-exports.lessInt = lessInt;
-exports.lessReal = lessReal;
-exports.lessStr = lessStr;
-exports.greaterInt = greaterInt;
-exports.greaterReal = greaterReal;
-exports.greaterStr = greaterStr;
-exports.eqLessInt = eqLessInt;
-exports.eqLessReal = eqLessReal;
-exports.eqLessStr = eqLessStr;
-exports.eqGreaterInt = eqGreaterInt;
-exports.eqGreaterReal = eqGreaterReal;
-exports.eqGreaterStr = eqGreaterStr;
-exports.not = not;
-exports.negateInt = negateInt;
-exports.negateReal = negateReal;
-exports.unaryPlus = unaryPlus;
-exports.setComplement = setComplement;
-exports.lsl = lsl;
-exports.asr = asr;
-exports.ror = ror;
-exports.mulInplace = mulInplace;
-exports.divInplace = divInplace;
-exports.pow2 = pow2;
-exports.log2 = log2;

+ 0 - 787
src/js/Procedure.js

@@ -1,787 +0,0 @@
-var RTL$ = require("rtl.js");
-var Cast = require("js/Cast.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 Language = require("js/Language.js");
-var LanguageContext = require("js/LanguageContext.js");
-var OberonRtl = require("js/OberonRtl.js");
-var Object = require("js/Object.js");
-var Operator = require("js/Operator.js");
-var Precedence = require("js/CodePrecedence.js");
-var Symbols = require("js/Symbols.js");
-var Types = require("js/Types.js");
-var Call = RTL$.extend({
-	init: function Call(){
-	}
-});
-var StdCall = Call.extend({
-	init: function StdCall(){
-		Call.prototype.init.call(this);
-		this.args = null;
-	}
-});
-var CallGenerator = RTL$.extend({
-	init: function CallGenerator(){
-		this.args = null;
-		this.cx = null;
-		this.call = null;
-	}
-});
-var Impl = Types.Procedure.extend({
-	init: function Impl(){
-		Types.Procedure.prototype.init.call(this);
-	}
-});
-var Type = Types.DefinedProcedure.extend({
-	init: function Type(){
-		Types.DefinedProcedure.prototype.init.call(this);
-		this.mArgs = null;
-		this.mResult = null;
-	}
-});
-var Std = Impl.extend({
-	init: function Std(){
-		Impl.prototype.init.call(this);
-		this.call = null;
-	}
-});
-var ArgumentsCode = RTL$.extend({
-	init: function ArgumentsCode(){
-	}
-});
-var GenArgCode = ArgumentsCode.extend({
-	init: function GenArgCode(){
-		ArgumentsCode.prototype.init.call(this);
-		this.code = null;
-		this.cx = null;
-	}
-});
-var predefined = null;
-
-function checkArgument(actual/*PExpression*/, expected/*PProcedureArgument*/, pos/*INTEGER*/, code/*PArgumentsCode*/, types/*PTypes*/){
-	var actualType = null;var expectType = null;
-	var designator = null;
-	var info = null;
-	var result = null;
-	var castErr = 0;
-	expectType = expected.type;
-	if (expectType != null){
-		actualType = actual.type();
-		castErr = types.implicitCast(actualType, expectType, expected.isVar, Operator.castOperations(), {set: function($v){result = $v;}, get: function(){return result;}});
-		if (castErr == Cast.errVarParameter){
-			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("type mismatch for argument "), JsString.fromInt(pos + 1 | 0)), JsString.make(": cannot pass '")), actualType.description()), JsString.make("' as VAR parameter of type '")), expectType.description()), JsString.make("'")));
-		}
-		else if (castErr != Cast.errNo){
-			Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("type mismatch for argument "), JsString.fromInt(pos + 1 | 0)), JsString.make(": '")), actualType.description()), JsString.make("' cannot be converted to '")), expectType.description()), JsString.make("'")));
-		}
-	}
-	if (expected.isVar){
-		designator = actual.designator();
-		if (designator == null){
-			Errors.raise(JsString.make("expression cannot be used as VAR parameter"));
-		}
-		info = designator.info();
-		if (info instanceof Types.Const){
-			Errors.raise(JsString.make("constant cannot be used as VAR parameter"));
-		}
-		if (info instanceof Types.Variable && Types.isVariableReadOnly(RTL$.typeGuard(info, Types.Variable))){
-			Errors.raise(JsString.concat(info.idType(), JsString.make(" cannot be used as VAR parameter")));
-		}
-	}
-	if (code != null){
-		code.write(actual, expected, result);
-	}
-}
-
-function checkArgumentsType(actual/*Type*/, expected/*Type*/, code/*PArgumentsCode*/, types/*PTypes*/){
-	var actualLen = 0;
-	var i = 0;
-	var actualExp = null;
-	var expectedArg = null;
-	actualLen = JsArray.len(actual);
-	while (true){
-		if (i < actualLen){
-			actualExp = JsArray.at(actual, i);
-			expectedArg = JsArray.at(expected, i);
-			checkArgument(RTL$.typeGuard(actualExp, Code.Expression), RTL$.typeGuard(expectedArg, Types.ProcedureArgument), i, code, types);
-			++i;
-		} else break;
-	}
-}
-
-function checkArgumentsCount(actual/*INTEGER*/, expected/*INTEGER*/){
-	if (actual != expected){
-		Errors.raise(JsString.concat(JsString.concat(JsString.fromInt(expected), JsString.make(" argument(s) expected, got ")), JsString.fromInt(actual)));
-	}
-}
-
-function processArguments(actual/*Type*/, expected/*Type*/, code/*PArgumentsCode*/, types/*PTypes*/){
-	checkArgumentsCount(JsArray.len(actual), JsArray.len(expected));
-	checkArgumentsType(actual, expected, code, types);
-}
-
-function checkArguments(actual/*Type*/, expected/*Type*/, types/*PTypes*/){
-	processArguments(actual, expected, null, types);
-}
-
-function initStd(name/*Type*/, call/*PCall*/, result/*Std*/){
-	Types.initProcedure(result, name);
-	result.call = call;
-}
-
-function makeStd(name/*Type*/, call/*PCall*/){
-	var result = null;
-	result = new Std();
-	initStd(name, call, result);
-	return result;
-}
-CallGenerator.prototype.handleArgument = function(e/*PExpression*/){
-	JsArray.add(this.args, e);
-}
-CallGenerator.prototype.end = function(){
-	return this.call.make(this.args, this.cx);
-}
-
-function makeCallGenerator(call/*PCall*/, cx/*PType*/){
-	var result = null;
-	RTL$.assert(cx != null);
-	result = new CallGenerator();
-	result.args = JsArray.make();
-	result.cx = cx;
-	result.call = call;
-	return result;
-}
-GenArgCode.prototype.write = function(actual/*PExpression*/, expected/*PProcedureArgument*/, cast/*PCastOp*/){
-	var e = null;
-	if (expected != null && expected.isVar){
-		actual = Code.refExpression(actual);
-	}
-	else {
-		actual = Code.derefExpression(actual);
-	}
-	if (JsString.len(this.code) != 0){
-		this.code = JsString.concat(this.code, JsString.make(", "));
-	}
-	if (cast != null){
-		e = cast.make(this.cx.rtl(), actual);
-	}
-	else {
-		e = actual;
-	}
-	this.code = JsString.concat(this.code, e.code());
-}
-GenArgCode.prototype.result = function(){
-	return this.code;
-}
-
-function makeProcCallGeneratorWithCustomArgs(cx/*PType*/, id/*Type*/, type/*DefinedProcedure*/, argumentsCode/*PArgumentsCode*/){
-	var CallImpl = Call.extend({
-		init: function CallImpl(){
-			Call.prototype.init.call(this);
-			this.id = null;
-			this.args = null;
-			this.result = null;
-			this.argumentsCode = null;
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var expectedArgs = null;
-		var a = null;
-		var i = 0;
-		expectedArgs = this.args;
-		if (expectedArgs != null){
-			processArguments(args, expectedArgs, this.argumentsCode, cx.types());
-		}
-		else {
-			for (i = 0; i <= JsArray.len(args) - 1 | 0; ++i){
-				a = JsArray.at(args, i);
-				this.argumentsCode.write(RTL$.typeGuard(a, Code.Expression), null, null);
-			}
-		}
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.concat(this.id, JsString.make("(")), this.argumentsCode.result()), JsString.make(")")), this.result);
-	}
-	call = new CallImpl();
-	call.id = id;
-	call.args = type.args();
-	call.result = type.result();
-	call.argumentsCode = argumentsCode;
-	return makeCallGenerator(call, cx);
-}
-
-function makeArgumentsCode(cx/*PType*/){
-	var result = null;
-	result = new GenArgCode();
-	result.code = JsString.makeEmpty();
-	result.cx = cx;
-	return result;
-}
-
-function makeProcCallGenerator(cx/*PType*/, id/*Type*/, type/*DefinedProcedure*/){
-	return makeProcCallGeneratorWithCustomArgs(cx, id, type, makeArgumentsCode(cx));
-}
-Std.prototype.description = function(){
-	return JsString.concat(JsString.make("standard procedure "), Types.typeName(this));
-}
-Std.prototype.callGenerator = function(cx/*PType*/){
-	return makeCallGenerator(this.call, cx);
-}
-
-function makeSymbol(p/*PProcedure*/){
-	return Symbols.makeSymbol(p.name, Types.makeProcedure(p));
-}
-
-function nthArgument(args/*Type*/, i/*INTEGER*/){
-	var arg = null;
-	arg = JsArray.at(args, i);
-	return RTL$.typeGuard(arg, Code.Expression);
-}
-
-function initStdCall(call/*PStdCall*/){
-	call.args = JsArray.make();
-}
-
-function hasArgument(call/*PStdCall*/, type/*PType*/){
-	var a = null;
-	a = new Types.ProcedureArgument();
-	a.type = type;
-	JsArray.add(call.args, a);
-}
-
-function hasVarArgument(call/*PStdCall*/, type/*PType*/){
-	var a = null;
-	a = new Types.ProcedureArgument();
-	a.isVar = true;
-	a.type = type;
-	JsArray.add(call.args, a);
-}
-
-function hasArgumentWithCustomType(call/*PStdCall*/){
-	var a = null;
-	a = new Types.ProcedureArgument();
-	JsArray.add(call.args, a);
-}
-
-function hasVarArgumnetWithCustomType(call/*PStdCall*/){
-	var a = null;
-	a = new Types.ProcedureArgument();
-	a.isVar = true;
-	JsArray.add(call.args, a);
-}
-
-function checkSingleArgument(actual/*Type*/, call/*StdCall*/, types/*PTypes*/){
-	RTL$.assert(JsArray.len(call.args) == 1);
-	checkArguments(actual, call.args, types);
-	RTL$.assert(JsArray.len(actual) == 1);
-	return nthArgument(actual, 0);
-}
-
-function makeNew(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var argType = null;
-		var baseType = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		argType = arg.type();
-		if (!(argType instanceof Types.Pointer)){
-			Errors.raise(JsString.concat(JsString.concat(JsString.make("POINTER variable expected, got '"), argType.description()), JsString.make("'")));
-		}
-		baseType = Types.pointerBase(RTL$.typeGuard(argType, Types.Pointer));
-		if (baseType instanceof Types.NonExportedRecord){
-			Errors.raise(JsString.make("non-exported RECORD type cannot be used in NEW"));
-		}
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(arg.code(), JsString.make(" = ")), baseType.initializer(cx)), null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasVarArgumnetWithCustomType(call);
-	return makeSymbol(makeStd(JsString.make("NEW"), call));
-}
-
-function makeLen(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var argType = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		argType = arg.type();
-		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("'")));
-		}
-		return Code.makeSimpleExpression(JsString.concat(arg.code(), JsString.make(".length")), Types.basic().integer);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgumentWithCustomType(call);
-	return makeSymbol(makeStd(JsString.make("LEN"), call));
-}
-
-function makeOdd(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var code = null;
-		var constValue = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		code = Code.adjustPrecedence(arg, Precedence.bitAnd);
-		constValue = arg.constValue();
-		if (constValue != null){
-			constValue = Code.makeIntConst(RTL$.typeGuard(constValue, Code.IntConst).value & 1 ? 1 : 0);
-		}
-		return Code.makeExpressionWithPrecedence(JsString.concat(code, JsString.make(" & 1")), Types.basic().bool, null, constValue, Precedence.bitAnd);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(JsString.make("ODD"), call));
-}
-
-function makeAssert(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var rtl = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		rtl = cx.rtl();
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.concat(rtl.assertId(), JsString.make("(")), arg.code()), JsString.make(")")), null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgument(call, Types.basic().bool);
-	return makeSymbol(makeStd(JsString.make("ASSERT"), call));
-}
-
-function setBitImpl(name/*ARRAY OF CHAR*/, bitOp/*BinaryOpStr*/){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-			this.name = null;
-			this.bitOp = null;
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var x = null;var y = null;
-		var yValue = 0;
-		var value = null;
-		var valueCodeExp = null;
-		var valueCode = null;
-		var comment = null;
-		checkArguments(args, this.args, cx.types());
-		RTL$.assert(JsArray.len(args) == 2);
-		x = nthArgument(args, 0);
-		y = nthArgument(args, 1);
-		value = y.constValue();
-		if (value == null){
-			valueCodeExp = Operator.lsl(Code.makeExpression(JsString.make("1"), Types.basic().integer, null, Code.makeIntConst(1)), y, cx.rtl());
-			valueCode = valueCodeExp.code();
-		}
-		else {
-			yValue = RTL$.typeGuard(value, Code.IntConst).value;
-			if (yValue < 0 || yValue > 31){
-				Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.make("value (0..31) expected as a second argument of "), this.name), JsString.make(", got ")), JsString.fromInt(yValue)));
-			}
-			comment = JsString.make("bit: ");
-			if (y.isTerm()){
-				comment = JsString.concat(comment, JsString.fromInt(yValue));
-			}
-			else {
-				comment = JsString.concat(comment, Code.adjustPrecedence(y, Precedence.shift));
-			}
-			yValue = 1 << yValue;
-			valueCode = JsString.concat(JsString.concat(JsString.concat(JsString.fromInt(yValue), JsString.make("/*")), comment), JsString.make("*/"));
-		}
-		return Code.makeSimpleExpression(this.bitOp(Code.adjustPrecedence(x, Precedence.assignment), valueCode), null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	call.name = JsString.make(name);
-	call.bitOp = bitOp;
-	hasVarArgument(call, Types.basic().set);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(call.name, call));
-}
-
-function checkVariableArgumentsCount(min/*INTEGER*/, max/*INTEGER*/, actual/*Type*/){
-	var len = 0;
-	len = JsArray.len(actual);
-	if (len < min){
-		Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.make("at least "), JsString.fromInt(min)), JsString.make(" argument expected, got ")), JsString.fromInt(len)));
-	}
-	else if (len > max){
-		Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.make("at most "), JsString.fromInt(max)), JsString.make(" arguments expected, got ")), JsString.fromInt(len)));
-	}
-}
-
-function incImpl(name/*ARRAY OF CHAR*/, unary/*ARRAY OF CHAR*/, incOp/*BinaryOpStr*/){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-			this.name = null;
-			this.unary = null;
-			this.incOp = null;
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var x = null;var y = null;
-		var code = null;
-		var value = null;
-		var valueCode = null;
-		checkVariableArgumentsCount(1, 2, args);
-		checkArgumentsType(args, this.args, null, cx.types());
-		x = nthArgument(args, 0);
-		if (JsArray.len(args) == 1){
-			code = JsString.concat(this.unary, x.code());
-		}
-		else {
-			y = nthArgument(args, 1);
-			value = y.constValue();
-			if (value == null){
-				valueCode = y.code();
-			}
-			else {
-				valueCode = JsString.fromInt(RTL$.typeGuard(value, Code.IntConst).value);
-				if (!y.isTerm()){
-					valueCode = JsString.concat(JsString.concat(JsString.concat(valueCode, JsString.make("/*")), y.code()), JsString.make("*/"));
-				}
-			}
-			code = this.incOp(x.code(), valueCode);
-		}
-		return Code.makeSimpleExpression(code, null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	call.name = JsString.make(name);
-	call.unary = JsString.make(unary);
-	call.incOp = incOp;
-	hasVarArgument(call, Types.basic().integer);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(call.name, call));
-}
-
-function inclOp(x/*Type*/, y/*Type*/){
-	return JsString.concat(JsString.concat(x, JsString.make(" |= ")), y);
-}
-
-function exclOp(x/*Type*/, y/*Type*/){
-	return JsString.concat(JsString.concat(JsString.concat(x, JsString.make(" &= ~(")), y), JsString.make(")"));
-}
-
-function incOp(x/*Type*/, y/*Type*/){
-	return JsString.concat(JsString.concat(x, JsString.make(" += ")), y);
-}
-
-function decOp(x/*Type*/, y/*Type*/){
-	return JsString.concat(JsString.concat(x, JsString.make(" -= ")), y);
-}
-
-function makeAbs(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var argType = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		argType = arg.type();
-		if (!JsArray.contains(Types.numeric(), argType)){
-			Errors.raise(JsString.concat(JsString.concat(JsString.make("type mismatch: expected numeric type, got '"), argType.description()), JsString.make("'")));
-		}
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.make("Math.abs("), arg.code()), JsString.make(")")), argType);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgumentWithCustomType(call);
-	return makeSymbol(makeStd(JsString.make("ABS"), call));
-}
-
-function makeFloor(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(JsString.make("Math.floor("), arg.code()), JsString.make(")")), Types.basic().integer);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgument(call, Types.basic().real);
-	return makeSymbol(makeStd(JsString.make("FLOOR"), call));
-}
-
-function makeFlt(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var value = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		value = arg.constValue();
-		if (value != null){
-			value = Code.makeRealConst(RTL$.typeGuard(value, Code.IntConst).value);
-		}
-		return Code.makeExpressionWithPrecedence(arg.code(), Types.basic().real, null, value, arg.maxPrecedence());
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(JsString.make("FLT"), call));
-}
-
-function bitShiftImpl(name/*ARRAY OF CHAR*/, op/*BinaryOp*/){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-			this.name = null;
-			this.op = null;
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var x = null;var y = null;
-		checkArguments(args, this.args, cx.types());
-		RTL$.assert(JsArray.len(args) == 2);
-		x = nthArgument(args, 0);
-		y = nthArgument(args, 1);
-		return this.op(x, y, cx.rtl());
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	call.name = JsString.make(name);
-	call.op = op;
-	hasArgument(call, Types.basic().integer);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(call.name, call));
-}
-
-function makeOrd(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		var argType = null;
-		var value = null;
-		var code = null;
-		var ch = 0;
-		var result = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		argType = arg.type();
-		if (argType == Types.basic().ch || argType == Types.basic().set){
-			value = arg.constValue();
-			if (value != null && argType == Types.basic().set){
-				value = Code.makeIntConst(RTL$.typeGuard(value, Code.SetConst).value);
-			}
-			result = Code.makeExpression(arg.code(), Types.basic().integer, null, value);
-		}
-		else if (argType == Types.basic().bool){
-			code = JsString.concat(Code.adjustPrecedence(arg, Precedence.conditional), JsString.make(" ? 1 : 0"));
-			result = Code.makeExpressionWithPrecedence(code, Types.basic().integer, null, arg.constValue(), Precedence.conditional);
-		}
-		else if (argType instanceof Types.String && Types.stringAsChar(RTL$.typeGuard(argType, Types.String), {set: function($v){ch = $v;}, get: function(){return ch;}})){
-			result = Code.makeExpression(JsString.fromInt(ch), Types.basic().integer, null, Code.makeIntConst(ch));
-		}
-		else {
-			Errors.raise(JsString.concat(JsString.concat(JsString.make("ORD function expects CHAR or BOOLEAN or SET as an argument, got '"), argType.description()), JsString.make("'")));
-		}
-		return result;
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgumentWithCustomType(call);
-	return makeSymbol(makeStd(JsString.make("ORD"), call));
-}
-
-function makeChr(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var arg = null;
-		arg = checkSingleArgument(args, this, cx.types());
-		return Code.makeSimpleExpression(arg.code(), Types.basic().ch);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(JsString.make("CHR"), call));
-}
-
-function makePack(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var x = null;var y = null;
-		checkArguments(args, this.args, cx.types());
-		x = nthArgument(args, 0);
-		y = nthArgument(args, 1);
-		return Code.makeSimpleExpression(Operator.mulInplace(x, Operator.pow2(y), cx.rtl()), null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasVarArgument(call, Types.basic().real);
-	hasArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(JsString.make("PACK"), call));
-}
-
-function makeUnpk(){
-	var CallImpl = StdCall.extend({
-		init: function CallImpl(){
-			StdCall.prototype.init.call(this);
-		}
-	});
-	var call = null;
-	CallImpl.prototype.make = function(args/*Type*/, cx/*Type*/){
-		var x = null;var y = null;
-		checkArguments(args, this.args, cx.types());
-		x = nthArgument(args, 0);
-		y = nthArgument(args, 1);
-		return Code.makeSimpleExpression(JsString.concat(JsString.concat(Operator.assign(y, Operator.log2(x), cx.rtl()), JsString.make("; ")), Operator.divInplace(x, Operator.pow2(y), cx.rtl())), null);
-	}
-	call = new CallImpl();
-	initStdCall(call);
-	hasVarArgument(call, Types.basic().real);
-	hasVarArgument(call, Types.basic().integer);
-	return makeSymbol(makeStd(JsString.make("UNPK"), call));
-}
-
-function dumpProcArgs(proc/*Type*/){
-	var result = null;
-	var len = 0;
-	var i = 0;
-	var arg = null;
-	len = JsArray.len(proc.mArgs);
-	if (len == 0){
-		if (proc.mResult != null){
-			result = JsString.make("()");
-		}
-		else {
-			result = JsString.makeEmpty();
-		}
-	}
-	else {
-		result = JsString.make("(");
-		for (i = 0; i <= len - 1 | 0; ++i){
-			if (i != 0){
-				result = JsString.concat(result, JsString.make(", "));
-			}
-			arg = JsArray.at(proc.mArgs, i);
-			result = JsString.concat(result, RTL$.typeGuard(arg, Types.ProcedureArgument).type.description());
-		}
-		result = JsString.concat(result, JsString.make(")"));
-	}
-	return result;
-}
-Type.prototype.description = function(){
-	var result = null;
-	result = Types.typeName(this);
-	if (result == null){
-		result = JsString.concat(JsString.make("PROCEDURE"), dumpProcArgs(this));
-		if (this.mResult != null){
-			result = JsString.concat(JsString.concat(result, JsString.make(": ")), this.mResult.description());
-		}
-	}
-	return result;
-}
-Type.prototype.callGenerator = function(cx/*PType*/, id/*Type*/){
-	return makeProcCallGenerator(cx, id, this);
-}
-Type.prototype.define = function(args/*Type*/, result/*PType*/){
-	this.mArgs = args;
-	this.mResult = result;
-}
-Type.prototype.args = function(){
-	return this.mArgs;
-}
-Type.prototype.result = function(){
-	return this.mResult;
-}
-
-function make(name/*Type*/){
-	var result = null;
-	result = new Type();
-	result.name = name;
-	return result;
-}
-predefined = JsArray.make();
-JsArray.add(predefined, makeNew());
-JsArray.add(predefined, makeLen());
-JsArray.add(predefined, makeOdd());
-JsArray.add(predefined, makeAssert());
-JsArray.add(predefined, setBitImpl("INCL", inclOp));
-JsArray.add(predefined, setBitImpl("EXCL", exclOp));
-JsArray.add(predefined, incImpl("INC", "++", incOp));
-JsArray.add(predefined, incImpl("DEC", "--", decOp));
-JsArray.add(predefined, makeAbs());
-JsArray.add(predefined, makeFloor());
-JsArray.add(predefined, makeFlt());
-JsArray.add(predefined, bitShiftImpl("LSL", Operator.lsl));
-JsArray.add(predefined, bitShiftImpl("ASR", Operator.asr));
-JsArray.add(predefined, bitShiftImpl("ROR", Operator.ror));
-JsArray.add(predefined, makeOrd());
-JsArray.add(predefined, makeChr());
-JsArray.add(predefined, makePack());
-JsArray.add(predefined, makeUnpk());
-exports.Call = Call;
-exports.StdCall = StdCall;
-exports.CallGenerator = CallGenerator;
-exports.Type = Type;
-exports.Std = Std;
-exports.predefined = function(){return predefined;};
-exports.checkArgumentsCount = checkArgumentsCount;
-exports.initStd = initStd;
-exports.makeCallGenerator = makeCallGenerator;
-exports.makeProcCallGeneratorWithCustomArgs = makeProcCallGeneratorWithCustomArgs;
-exports.makeArgumentsCode = makeArgumentsCode;
-exports.makeProcCallGenerator = makeProcCallGenerator;
-exports.makeSymbol = makeSymbol;
-exports.initStdCall = initStdCall;
-exports.hasArgumentWithCustomType = hasArgumentWithCustomType;
-exports.checkSingleArgument = checkSingleArgument;
-exports.make = make;

+ 0 - 229
src/js/Scope.js

@@ -1,229 +0,0 @@
-var RTL$ = require("rtl.js");
-var Errors = require("js/Errors.js");
-var JsArray = require("js/JsArray.js");
-var JsMap = require("js/JsMap.js");
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var Procedures = require("js/Procedure.js");
-var ScopeBase = require("js/ScopeBase.js");
-var Symbols = require("js/Symbols.js");
-var Types = require("js/Types.js");
-var Type = ScopeBase.Type.extend({
-	init: function Type(){
-		ScopeBase.Type.prototype.init.call(this);
-		this.stdSymbols = null;
-		this.symbols = null;
-		this.unresolved = null;
-		this.finalizers = null;
-	}
-});
-var Procedure = Type.extend({
-	init: function Procedure(){
-		Type.prototype.init.call(this);
-	}
-});
-var CompiledModule = Types.Module.extend({
-	init: function CompiledModule(){
-		Types.Module.prototype.init.call(this);
-		this.exports = null;
-	}
-});
-var Module = Type.extend({
-	init: function Module(){
-		Type.prototype.init.call(this);
-		this.symbol = null;
-		this.exports = null;
-	}
-});
-var Finalizer = Object.Type.extend({
-	init: function Finalizer(){
-		Object.Type.prototype.init.call(this);
-		this.proc = null;
-		this.closure = null;
-	}
-});
-
-function addSymbolForType(t/*PBasicType*/, result/*Type*/){
-	var name = null;
-	name = Types.typeName(t);
-	JsMap.put(result, name, Symbols.makeSymbol(name, Types.makeTypeId(t)));
-}
-
-function makeStdSymbols(){
-	var result = null;
-	var i = 0;
-	var proc = null;
-	
-	function addSymbol(t/*PBasicType*/){
-		addSymbolForType(t, result);
-	}
-	result = JsMap.make();
-	addSymbol(Types.basic().bool);
-	addSymbol(Types.basic().ch);
-	addSymbol(Types.basic().integer);
-	addSymbol(Types.basic().uint8);
-	addSymbol(Types.basic().real);
-	addSymbol(Types.basic().set);
-	for (i = 0; i <= JsArray.len(Procedures.predefined()) - 1 | 0; ++i){
-		proc = JsArray.at(Procedures.predefined(), i);
-		JsMap.put(result, RTL$.typeGuard(proc, Symbols.Symbol).id(), proc);
-	}
-	return result;
-}
-
-function init(scope/*Type*/, stdSymbols/*Type*/){
-	scope.stdSymbols = stdSymbols;
-	scope.symbols = JsMap.make();
-	scope.unresolved = JsArray.makeStrings();
-	scope.finalizers = JsArray.make();
-}
-
-function makeCompiledModule(name/*Type*/){
-	var result = null;
-	result = new CompiledModule();
-	Types.initModule(result, name);
-	result.exports = JsMap.make();
-	return result;
-}
-
-function makeModule(name/*Type*/, stdSymbols/*Type*/){
-	var result = null;
-	result = new Module();
-	init(result, stdSymbols);
-	result.exports = JsMap.make();
-	result.symbol = Symbols.makeSymbol(name, makeCompiledModule(name));
-	result.addSymbol(result.symbol, false);
-	return result;
-}
-
-function addUnresolved(s/*Type*/, id/*Type*/){
-	if (!JsArray.containsString(s.unresolved, id)){
-		JsArray.addString(s.unresolved, id);
-	}
-}
-
-function resolve(s/*Type*/, symbol/*PSymbol*/){
-	var id = null;
-	var i = 0;
-	var info = null;
-	var type = null;
-	id = symbol.id();
-	i = JsArray.stringsIndexOf(s.unresolved, id);
-	if (i != -1){
-		info = symbol.info();
-		type = RTL$.typeGuard(info, Types.TypeId).type();
-		if (type != null && !(type instanceof Types.Record)){
-			Errors.raise(JsString.concat(JsString.concat(JsString.make("'"), id), JsString.make("' must be of RECORD type because it was used before in the declation of POINTER")));
-		}
-		JsArray.removeString(s.unresolved, i);
-	}
-}
-
-function unresolved(s/*Type*/){
-	return s.unresolved;
-}
-Type.prototype.close = function(){
-	var i = 0;
-	var p = null;
-	var finalizer = null;
-	if (this.finalizers != null){
-		for (i = 0; i <= JsArray.len(this.finalizers) - 1 | 0; ++i){
-			p = JsArray.at(this.finalizers, i);
-			finalizer = RTL$.typeGuard(p, Finalizer);
-			finalizer.proc(finalizer.closure);
-		}
-		this.finalizers = null;
-	}
-}
-Type.prototype.addFinalizer = function(proc/*FinalizerProc*/, closure/*PType*/){
-	var f = null;
-	f = new Finalizer();
-	f.proc = proc;
-	f.closure = closure;
-	JsArray.add(this.finalizers, f);
-}
-
-function close(s/*Type*/){
-	return s.unresolved;
-}
-Type.prototype.addSymbol = function(s/*PSymbol*/, exported/*BOOLEAN*/){
-	var id = null;
-	id = s.id();
-	if (this.findSymbol(id) != null){
-		Errors.raise(JsString.concat(JsString.concat(JsString.make("'"), id), JsString.make("' already declared")));
-	}
-	JsMap.put(this.symbols, id, s);
-}
-Type.prototype.findSymbol = function(id/*Type*/){
-	var result = null;
-	var void$ = false;
-	if (!JsMap.find(this.symbols, id, {set: function($v){result = $v;}, get: function(){return result;}})){
-		void$ = JsMap.find(this.stdSymbols, id, {set: function($v){result = $v;}, get: function(){return result;}});
-	}
-	return RTL$.typeGuard(result, Symbols.Symbol);
-}
-Procedure.prototype.addSymbol = function(s/*PSymbol*/, exported/*BOOLEAN*/){
-	var info = null;
-	if (exported){
-		info = s.info();
-		Errors.raise(JsString.concat(JsString.concat(JsString.concat(JsString.concat(JsString.make("cannot export from within procedure: "), info.idType()), JsString.make(" '")), s.id()), JsString.make("'")));
-	}
-	Type.prototype.addSymbol.call(this, s, exported);
-}
-
-function makeProcedure(stdSymbols/*Type*/){
-	var result = null;
-	result = new Procedure();
-	init(result, stdSymbols);
-	return result;
-}
-
-function addExport(id/*Type*/, value/*PType*/, closure/*VAR Type*/){
-	var symbol = null;
-	var info = null;
-	symbol = RTL$.typeGuard(value, Symbols.Symbol);
-	info = symbol.info();
-	if (info instanceof Types.Variable){
-		symbol = Symbols.makeSymbol(id, Types.makeExportedVariable(RTL$.typeGuard(info, Types.Variable)));
-	}
-	JsMap.put(RTL$.typeGuard(closure, CompiledModule).exports, id, symbol);
-}
-
-function defineExports(m/*CompiledModule*/, exports/*Type*/){
-	JsMap.forEach(exports, addExport, m);
-}
-CompiledModule.prototype.findSymbol = function(id/*Type*/){
-	var s = null;
-	var result = null;
-	if (JsMap.find(this.exports, id, {set: function($v){s = $v;}, get: function(){return s;}})){
-		result = Symbols.makeFound(RTL$.typeGuard(s, Symbols.Symbol), null);
-	}
-	return result;
-}
-Module.prototype.addSymbol = function(s/*PSymbol*/, exported/*BOOLEAN*/){
-	Type.prototype.addSymbol.call(this, s, exported);
-	if (exported){
-		JsMap.put(this.exports, s.id(), s);
-	}
-}
-
-function moduleSymbol(m/*Module*/){
-	return m.symbol;
-}
-
-function moduleExports(m/*Module*/){
-	return m.exports;
-}
-exports.Procedure = Procedure;
-exports.Module = Module;
-exports.addSymbolForType = addSymbolForType;
-exports.makeStdSymbols = makeStdSymbols;
-exports.makeModule = makeModule;
-exports.addUnresolved = addUnresolved;
-exports.resolve = resolve;
-exports.unresolved = unresolved;
-exports.close = close;
-exports.makeProcedure = makeProcedure;
-exports.defineExports = defineExports;
-exports.moduleSymbol = moduleSymbol;
-exports.moduleExports = moduleExports;

+ 0 - 7
src/js/ScopeBase.js

@@ -1,7 +0,0 @@
-var RTL$ = require("rtl.js");
-var Object = require("js/Object.js");
-var Type = RTL$.extend({
-	init: function Type(){
-	}
-});
-exports.Type = Type;

+ 0 - 95
src/js/Stream.js

@@ -1,95 +0,0 @@
-var RTL$ = require("rtl.js");
-var JsString = require("js/JsString.js");
-var kCR = "\n";
-var Type = RTL$.extend({
-	init: function Type(){
-		this.s = null;
-		this.pos = 0;
-	}
-});
-
-function make(text/*Type*/){
-	var result = null;
-	result = new Type();
-	result.s = text;
-	return result;
-}
-
-function eof(self/*Type*/){
-	return self.pos == JsString.len(self.s);
-}
-
-function pos(self/*Type*/){
-	return self.pos;
-}
-
-function setPos(self/*Type*/, pos/*INTEGER*/){
-	RTL$.assert(pos <= JsString.len(self.s));
-	self.pos = pos;
-}
-
-function next(self/*Type*/, n/*INTEGER*/){
-	RTL$.assert((self.pos + n | 0) <= JsString.len(self.s));
-	self.pos = self.pos + n | 0;
-}
-
-function peekChar(self/*Type*/){
-	RTL$.assert(!eof(self));
-	return JsString.at(self.s, self.pos);
-}
-
-function getChar(self/*Type*/){
-	var result = 0;
-	RTL$.assert(!eof(self));
-	result = JsString.at(self.s, self.pos);
-	++self.pos;
-	return result;
-}
-
-function peekStr(self/*Type*/, s/*ARRAY OF CHAR*/){
-	var result = false;
-	var i = 0;
-	if (s.length <= (JsString.len(self.s) - self.pos | 0)){
-		while (true){
-			if (i < s.length && s.charCodeAt(i) == JsString.at(self.s, self.pos + i | 0)){
-				++i;
-			} else break;
-		}
-		result = i == s.length;
-	}
-	return result;
-}
-
-function read(self/*Type*/, f/*ReaderProc*/){
-	while (true){
-		if (!eof(self) && f(peekChar(self))){
-			next(self, 1);
-		} else break;
-	}
-	return !eof(self);
-}
-
-function lineNumber(self/*Type*/){
-	var line = 0;
-	var lastPos = 0;
-	lastPos = JsString.indexOf(self.s, 10);
-	while (true){
-		if (lastPos != -1 && lastPos < self.pos){
-			++line;
-			lastPos = JsString.indexOfFrom(self.s, 10, lastPos + 1 | 0);
-		} else break;
-	}
-	return line + 1 | 0;
-}
-exports.kCR = kCR;
-exports.Type = Type;
-exports.make = make;
-exports.eof = eof;
-exports.pos = pos;
-exports.setPos = setPos;
-exports.next = next;
-exports.peekChar = peekChar;
-exports.getChar = getChar;
-exports.peekStr = peekStr;
-exports.read = read;
-exports.lineNumber = lineNumber;

+ 0 - 65
src/js/Symbols.js

@@ -1,65 +0,0 @@
-var RTL$ = require("rtl.js");
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var ScopeBase = require("js/ScopeBase.js");
-var Types = require("js/Types.js");
-var Symbol = Object.Type.extend({
-	init: function Symbol(){
-		Object.Type.prototype.init.call(this);
-		this.mId = null;
-		this.mInfo = null;
-	}
-});
-var FoundSymbol = RTL$.extend({
-	init: function FoundSymbol(){
-		this.mSymbol = null;
-		this.mScope = null;
-	}
-});
-Symbol.prototype.id = function(){
-	return this.mId;
-}
-Symbol.prototype.info = function(){
-	return this.mInfo;
-}
-Symbol.prototype.isModule = function(){
-	return this.mInfo instanceof Types.Module;
-}
-Symbol.prototype.isVariable = function(){
-	return this.mInfo instanceof Types.Variable;
-}
-Symbol.prototype.isConst = function(){
-	return this.mInfo instanceof Types.Const;
-}
-Symbol.prototype.isType = function(){
-	return this.mInfo instanceof Types.TypeId;
-}
-Symbol.prototype.isProcedure = function(){
-	return this.mInfo instanceof Types.ProcedureId;
-}
-FoundSymbol.prototype.scope = function(){
-	return this.mScope;
-}
-FoundSymbol.prototype.symbol = function(){
-	return this.mSymbol;
-}
-
-function makeSymbol(id/*Type*/, info/*PId*/){
-	var result = null;
-	result = new Symbol();
-	result.mId = id;
-	result.mInfo = info;
-	return result;
-}
-
-function makeFound(s/*PSymbol*/, scope/*PType*/){
-	var result = null;
-	result = new FoundSymbol();
-	result.mSymbol = s;
-	result.mScope = scope;
-	return result;
-}
-exports.Symbol = Symbol;
-exports.FoundSymbol = FoundSymbol;
-exports.makeSymbol = makeSymbol;
-exports.makeFound = makeFound;

+ 0 - 643
src/js/Types.js

@@ -1,643 +0,0 @@
-var RTL$ = require("rtl.js");
-var Context = require("js/Context.js");
-var Errors = require("js/Errors.js");
-var JS = GLOBAL;
-var JsArray = require("js/JsArray.js");
-var JsMap = require("js/JsMap.js");
-var JsString = require("js/JsString.js");
-var Object = require("js/Object.js");
-var ScopeBase = require("js/ScopeBase.js");
-var openArrayLength = 0;
-var Id = Object.Type.extend({
-	init: function Id(){
-		Object.Type.prototype.init.call(this);
-	}
-});
-var Type = Object.Type.extend({
-	init: function Type(){
-		Object.Type.prototype.init.call(this);
-	}
-});
-var StorageType = Type.extend({
-	init: function StorageType(){
-		Type.prototype.init.call(this);
-	}
-});
-var TypeId = Id.extend({
-	init: function TypeId(){
-		Id.prototype.init.call(this);
-		this.mType = null;
-	}
-});
-var ForwardTypeId = TypeId.extend({
-	init: function ForwardTypeId(){
-		TypeId.prototype.init.call(this);
-		this.resolve = null;
-	}
-});
-var LazyTypeId = TypeId.extend({
-	init: function LazyTypeId(){
-		TypeId.prototype.init.call(this);
-	}
-});
-var Const = Id.extend({
-	init: function Const(){
-		Id.prototype.init.call(this);
-		this.type = null;
-		this.value = undefined;
-	}
-});
-var Variable = Id.extend({
-	init: function Variable(){
-		Id.prototype.init.call(this);
-		this.type = null;
-		this.readOnly = false;
-	}
-});
-var VariableRef = Variable.extend({
-	init: function VariableRef(){
-		Variable.prototype.init.call(this);
-	}
-});
-var ExportedVariable = Variable.extend({
-	init: function ExportedVariable(){
-		Variable.prototype.init.call(this);
-	}
-});
-var ProcedureId = Id.extend({
-	init: function ProcedureId(){
-		Id.prototype.init.call(this);
-		this.type = null;
-	}
-});
-var String = Type.extend({
-	init: function String(){
-		Type.prototype.init.call(this);
-		this.s = null;
-	}
-});
-var NamedType = StorageType.extend({
-	init: function NamedType(){
-		StorageType.prototype.init.call(this);
-		this.name = null;
-	}
-});
-var Array = NamedType.extend({
-	init: function Array(){
-		NamedType.prototype.init.call(this);
-		this.mInitializer = null;
-		this.elementsType = null;
-		this.len = 0;
-	}
-});
-var Pointer = NamedType.extend({
-	init: function Pointer(){
-		NamedType.prototype.init.call(this);
-		this.base = null;
-	}
-});
-var Procedure = NamedType.extend({
-	init: function Procedure(){
-		NamedType.prototype.init.call(this);
-	}
-});
-var DefinedProcedure = Procedure.extend({
-	init: function DefinedProcedure(){
-		Procedure.prototype.init.call(this);
-	}
-});
-var ProcedureArgument = Object.Type.extend({
-	init: function ProcedureArgument(){
-		Object.Type.prototype.init.call(this);
-		this.type = null;
-		this.isVar = false;
-	}
-});
-var BasicType = NamedType.extend({
-	init: function BasicType(){
-		NamedType.prototype.init.call(this);
-		this.mInitializer = null;
-	}
-});
-var Field = RTL$.extend({
-	init: function Field(){
-		this.id = null;
-		this.exported = null;
-	}
-});
-var Record = NamedType.extend({
-	init: function Record(){
-		NamedType.prototype.init.call(this);
-		this.fields = null;
-		this.base = null;
-		this.cons = null;
-		this.scope = null;
-		this.notExported = null;
-	}
-});
-var NonExportedRecord = Record.extend({
-	init: function NonExportedRecord(){
-		Record.prototype.init.call(this);
-	}
-});
-var Nil = Type.extend({
-	init: function Nil(){
-		Type.prototype.init.call(this);
-	}
-});
-var Module = Id.extend({
-	init: function Module(){
-		Id.prototype.init.call(this);
-		this.name = null;
-	}
-});
-var anonymous$1 = RTL$.extend({
-	init: function anonymous$1(){
-		this.bool = null;
-		this.ch = null;
-		this.integer = null;
-		this.uint8 = null;
-		this.real = null;
-		this.set = null;
-	}
-});
-var basic = new anonymous$1();
-var numeric = null;
-var nil = null;
-TypeId.prototype.description = function(){
-	var t = null;
-	t = this.type();
-	return JsString.concat(JsString.make("type "), t.description());
-}
-TypeId.prototype.type = function(){
-	return this.mType;
-}
-
-function finalizeRecord(closure/*PType*/){
-	RTL$.typeGuard(closure, Record).finalize();
-}
-Record.prototype.finalize = function(){
-	var i = 0;
-	for (i = 0; i <= JsArray.stringsLen(this.notExported) - 1 | 0; ++i){
-		JsMap.erase(this.fields, JsArray.stringsAt(this.notExported, i));
-	}
-	this.notExported = null;
-}
-
-function initRecord(r/*PRecord*/, name/*Type*/, cons/*Type*/, scope/*PType*/){
-	r.name = name;
-	r.cons = cons;
-	r.scope = scope;
-	r.fields = JsMap.make();
-	r.notExported = JsArray.makeStrings();
-	scope.addFinalizer(finalizeRecord, r);
-}
-
-function makeNonExportedRecord(cons/*Type*/, scope/*PType*/, base/*PRecord*/){
-	var result = null;
-	result = new NonExportedRecord();
-	initRecord(result, null, cons, scope);
-	result.base = base;
-	return result;
-}
-TypeId.prototype.strip = function(){
-	var r = null;
-	if (this.mType instanceof Record){
-		r = RTL$.typeGuard(this.mType, Record);
-		this.mType = makeNonExportedRecord(r.cons, r.scope, r.base);
-	}
-	else {
-		this.mType = null;
-	}
-}
-
-function makeForwardTypeId(resolve/*ResolveTypeCallback*/){
-	var result = null;
-	result = new ForwardTypeId();
-	result.resolve = resolve;
-	return result;
-}
-ForwardTypeId.prototype.type = function(){
-	if (this.mType == null){
-		this.mType = this.resolve();
-	}
-	return this.mType;
-}
-
-function defineTypeId(tId/*VAR LazyTypeId*/, t/*PType*/){
-	tId.mType = t;
-}
-
-function typeName(type/*NamedType*/){
-	return type.name;
-}
-ProcedureId.prototype.idType = function(){
-	return JsString.make("procedure");
-}
-String.prototype.description = function(){
-	var prefix = null;
-	if (JsString.len(this.s) == 1){
-		prefix = JsString.make("single-");
-	}
-	else {
-		prefix = JsString.make("multi-");
-	}
-	return JsString.concat(prefix, JsString.make("character string"));
-}
-
-function stringValue(s/*String*/){
-	return s.s;
-}
-
-function stringLen(s/*String*/){
-	return JsString.len(s.s);
-}
-
-function stringAsChar(s/*String*/, c/*VAR CHAR*/){
-	var result = false;
-	result = stringLen(s) == 1;
-	if (result){
-		c.set(JsString.at(s.s, 0));
-	}
-	return result;
-}
-Const.prototype.idType = function(){
-	return JsString.make("constant");
-}
-
-function constType(c/*Const*/){
-	return c.type;
-}
-
-function constValue(c/*Const*/){
-	return c.value;
-}
-Variable.prototype.idType = function(){
-	var result = null;
-	if (this.readOnly){
-		result = JsString.make("read-only variable");
-	}
-	else {
-		result = JsString.make("variable");
-	}
-	return result;
-}
-
-function variableType(v/*Variable*/){
-	return v.type;
-}
-
-function procedureType(p/*ProcedureId*/){
-	return p.type;
-}
-
-function isVariableReadOnly(v/*Variable*/){
-	return v.readOnly;
-}
-ExportedVariable.prototype.idType = function(){
-	return JsString.make("imported variable");
-}
-TypeId.prototype.idType = function(){
-	return JsString.make("type");
-}
-BasicType.prototype.description = function(){
-	return this.name;
-}
-BasicType.prototype.initializer = function(cx/*Type*/){
-	return this.mInitializer;
-}
-Nil.prototype.description = function(){
-	return JsString.make("NIL");
-}
-
-function isInt(t/*PType*/){
-	return t == basic.integer || t == basic.uint8;
-}
-
-function intsDescription(){
-	return JsString.make("'INTEGER' or 'BYTE'");
-}
-
-function isString(t/*PType*/){
-	return t instanceof Array && RTL$.typeGuard(t, Array).elementsType == basic.ch || t instanceof String;
-}
-
-function moduleName(m/*Module*/){
-	return m.name;
-}
-
-function makeBasic(name/*ARRAY OF CHAR*/, initializer/*ARRAY OF CHAR*/){
-	var result = null;
-	result = new BasicType();
-	result.name = JsString.make(name);
-	result.mInitializer = JsString.make(initializer);
-	return result;
-}
-Record.prototype.description = function(){
-	var result = null;
-	if (this.name != null){
-		result = this.name;
-	}
-	else {
-		result = JsString.make("anonymous RECORD");
-	}
-	return result;
-}
-Record.prototype.initializer = function(cx/*Type*/){
-	return JsString.concat(JsString.concat(JsString.concat(JsString.make("new "), cx.qualifyScope(this.scope)), this.cons), JsString.make("()"));
-}
-Record.prototype.addField = function(f/*Field*/, type/*PType*/){
-	if (JsMap.has(this.fields, f.id())){
-		Errors.raise(JsString.concat(JsString.concat(JsString.make("duplicated field: '"), f.id()), JsString.make("'")));
-	}
-	if (this.base != null && this.base.findSymbol(f.id()) != null){
-		Errors.raise(JsString.concat(JsString.concat(JsString.make("base record already has field: '"), f.id()), JsString.make("'")));
-	}
-	JsMap.put(this.fields, f.id(), type);
-	if (!f.exported()){
-		JsArray.addString(this.notExported, f.id());
-	}
-}
-Record.prototype.findSymbol = function(id/*Type*/){
-	var result = null;
-	if (!JsMap.find(this.fields, id, {set: function($v){result = $v;}, get: function(){return result;}}) && this.base != null){
-		result = this.base.findSymbol(id);
-	}
-	return result;
-}
-
-function recordBase(r/*Record*/){
-	return r.base;
-}
-
-function setRecordBase(r/*Record*/, type/*PRecord*/){
-	r.base = type;
-}
-
-function recordScope(r/*Record*/){
-	return r.scope;
-}
-
-function recordConstructor(r/*Record*/){
-	return r.cons;
-}
-
-function recordOwnFields(r/*Record*/){
-	return r.fields;
-}
-
-function pointerBase(p/*Pointer*/){
-	var result = null;
-	result = p.base.type();
-	return RTL$.typeGuard(result, Record);
-}
-Pointer.prototype.description = function(){
-	var base = null;
-	var result = null;
-	if (this.name != null){
-		result = this.name;
-	}
-	else {
-		base = pointerBase(this);
-		result = JsString.concat(JsString.make("POINTER TO "), base.description());
-	}
-	return result;
-}
-Pointer.prototype.initializer = function(cx/*Type*/){
-	return JsString.make("null");
-}
-
-function foldArrayDimensions(a/*Array*/, sizes/*VAR Type*/, of/*VAR Type*/){
-	if (a.len != openArrayLength && a.elementsType instanceof Array){
-		foldArrayDimensions(RTL$.typeGuard(a.elementsType, Array), sizes, of);
-		sizes.set(JsString.concat(JsString.concat(JsString.fromInt(a.len), JsString.make(", ")), sizes.get()));
-	}
-	else {
-		if (a.len != openArrayLength){
-			sizes.set(JsString.fromInt(a.len));
-		}
-		of.set(a.elementsType.description());
-	}
-}
-Array.prototype.description = function(){
-	var result = null;
-	var sizes = null;var of = null;
-	if (this.elementsType == null){
-		result = this.name;
-	}
-	else {
-		foldArrayDimensions(this, {set: function($v){sizes = $v;}, get: function(){return sizes;}}, {set: function($v){of = $v;}, get: function(){return of;}});
-		if (sizes == null){
-			sizes = JsString.make("");
-		}
-		else {
-			sizes = JsString.concat(JsString.make(" "), sizes);
-		}
-		result = JsString.concat(JsString.concat(JsString.concat(JsString.make("ARRAY"), sizes), JsString.make(" OF ")), of);
-	}
-	return result;
-}
-Array.prototype.initializer = function(cx/*Type*/){
-	return this.mInitializer;
-}
-
-function arrayElementsType(a/*Array*/){
-	return a.elementsType;
-}
-
-function arrayLength(a/*Array*/){
-	return a.len;
-}
-Procedure.prototype.initializer = function(cx/*Type*/){
-	return JsString.make("null");
-}
-Procedure.prototype.description = function(){
-	return this.name;
-}
-ProcedureArgument.prototype.description = function(){
-	var result = null;
-	if (this.isVar){
-		result = JsString.make("VAR ");
-	}
-	else {
-		result = JsString.makeEmpty();
-	}
-	return JsString.concat(result, this.type.description());
-}
-
-function makeProcedureArgument(type/*PType*/, isVar/*BOOLEAN*/){
-	var result = null;
-	result = new ProcedureArgument();
-	result.type = type;
-	result.isVar = isVar;
-	return result;
-}
-Module.prototype.idType = function(){
-	return JsString.make("MODULE");
-}
-
-function makeTypeId(type/*PType*/){
-	var result = null;
-	result = new TypeId();
-	result.mType = type;
-	return result;
-}
-
-function makeLazyTypeId(){
-	var result = null;
-	result = new LazyTypeId();
-	return result;
-}
-
-function makeString(s/*Type*/){
-	var result = null;
-	result = new String();
-	result.s = s;
-	return result;
-}
-
-function makeArray(name/*Type*/, initializer/*Type*/, elementsType/*PType*/, len/*INTEGER*/){
-	var result = null;
-	result = new Array();
-	result.name = name;
-	result.mInitializer = initializer;
-	result.elementsType = elementsType;
-	result.len = len;
-	return result;
-}
-
-function makePointer(name/*Type*/, base/*PTypeId*/){
-	var result = null;
-	result = new Pointer();
-	result.name = name;
-	result.base = base;
-	return result;
-}
-
-function makeRecord(name/*Type*/, cons/*Type*/, scope/*PType*/){
-	var result = null;
-	result = new Record();
-	initRecord(result, name, cons, scope);
-	return result;
-}
-
-function makeConst(type/*PType*/, value/*JS.var*/){
-	var result = null;
-	result = new Const();
-	result.type = type;
-	result.value = value;
-	return result;
-}
-
-function makeVariable(type/*PType*/, readOnly/*BOOLEAN*/){
-	var result = null;
-	result = new Variable();
-	result.type = type;
-	result.readOnly = readOnly;
-	return result;
-}
-
-function makeVariableRef(type/*PType*/){
-	var result = null;
-	result = new VariableRef();
-	result.type = type;
-	result.readOnly = false;
-	return result;
-}
-
-function makeExportedVariable(v/*Variable*/){
-	var result = null;
-	result = new ExportedVariable();
-	result.type = v.type;
-	result.readOnly = true;
-	return result;
-}
-
-function makeProcedure(type/*PType*/){
-	var result = null;
-	result = new ProcedureId();
-	result.type = type;
-	return result;
-}
-
-function initProcedure(p/*Procedure*/, name/*Type*/){
-	p.name = name;
-}
-
-function initModule(m/*Module*/, name/*Type*/){
-	m.name = name;
-}
-basic.bool = makeBasic("BOOLEAN", "false");
-basic.ch = makeBasic("CHAR", "0");
-basic.integer = makeBasic("INTEGER", "0");
-basic.uint8 = makeBasic("BYTE", "0");
-basic.real = makeBasic("REAL", "0");
-basic.set = makeBasic("SET", "0");
-numeric = JsArray.make();
-JsArray.add(numeric, basic.integer);
-JsArray.add(numeric, basic.uint8);
-JsArray.add(numeric, basic.real);
-nil = new Nil();
-exports.openArrayLength = openArrayLength;
-exports.Id = Id;
-exports.Type = Type;
-exports.StorageType = StorageType;
-exports.TypeId = TypeId;
-exports.ForwardTypeId = ForwardTypeId;
-exports.Const = Const;
-exports.Variable = Variable;
-exports.VariableRef = VariableRef;
-exports.ProcedureId = ProcedureId;
-exports.String = String;
-exports.NamedType = NamedType;
-exports.Array = Array;
-exports.Pointer = Pointer;
-exports.Procedure = Procedure;
-exports.DefinedProcedure = DefinedProcedure;
-exports.ProcedureArgument = ProcedureArgument;
-exports.BasicType = BasicType;
-exports.Record = Record;
-exports.NonExportedRecord = NonExportedRecord;
-exports.Module = Module;
-exports.basic = function(){return basic;};
-exports.numeric = function(){return numeric;};
-exports.nil = function(){return nil;};
-exports.initRecord = initRecord;
-exports.makeForwardTypeId = makeForwardTypeId;
-exports.defineTypeId = defineTypeId;
-exports.typeName = typeName;
-exports.stringValue = stringValue;
-exports.stringLen = stringLen;
-exports.stringAsChar = stringAsChar;
-exports.constType = constType;
-exports.constValue = constValue;
-exports.variableType = variableType;
-exports.procedureType = procedureType;
-exports.isVariableReadOnly = isVariableReadOnly;
-exports.isInt = isInt;
-exports.intsDescription = intsDescription;
-exports.isString = isString;
-exports.moduleName = moduleName;
-exports.makeBasic = makeBasic;
-exports.recordBase = recordBase;
-exports.setRecordBase = setRecordBase;
-exports.recordScope = recordScope;
-exports.recordConstructor = recordConstructor;
-exports.recordOwnFields = recordOwnFields;
-exports.pointerBase = pointerBase;
-exports.arrayElementsType = arrayElementsType;
-exports.arrayLength = arrayLength;
-exports.makeProcedureArgument = makeProcedureArgument;
-exports.makeTypeId = makeTypeId;
-exports.makeLazyTypeId = makeLazyTypeId;
-exports.makeString = makeString;
-exports.makeArray = makeArray;
-exports.makePointer = makePointer;
-exports.makeRecord = makeRecord;
-exports.makeConst = makeConst;
-exports.makeVariable = makeVariable;
-exports.makeVariableRef = makeVariableRef;
-exports.makeExportedVariable = makeExportedVariable;
-exports.makeProcedure = makeProcedure;
-exports.initProcedure = initProcedure;
-exports.initModule = initModule;

+ 1 - 1
test/test_compile.cmd

@@ -1,2 +1,2 @@
-SET NODE_PATH=.;%~dp0../src;%~dp0../src/js;%~dp0../src/eberon
+SET NODE_PATH=.;%~dp0../src;%~dp0../bin
 "C:\Program Files\nodejs\node.exe" test_compile.js %*

+ 1 - 1
test/test_unit.cmd

@@ -1,2 +1,2 @@
-SET NODE_PATH=.;%~dp0../src;%~dp0../src/oberon;%~dp0../src/eberon;%~dp0../src/js
+SET NODE_PATH=.;%~dp0../src;%~dp0../bin
 "C:\Program Files\nodejs\node.exe" test_unit.js %*

+ 1 - 1
test/test_unit_common.js

@@ -7,7 +7,7 @@ var Errors = require("js/Errors.js");
 var oc = require("oc.js");
 var RTL = require("rtl_code.js").RTL;
 var Scope = require("js/Scope.js");
-var Stream = require("Stream.js");
+var Stream = require("js/Stream.js");
 var Test = require("test.js");
 
 var TestError = Test.TestError;