2
0
Vladislav Folts 10 жил өмнө
parent
commit
5ff5c6c381

BIN
bin/compiled.zip


+ 2 - 2
src/ob/ContextDesignator.ob

@@ -19,8 +19,8 @@ TYPE
     END;
     PQIdentHandler* = POINTER TO QIdentHandler;
 
-    Type* = RECORD(QIdentHandler)
-        PROCEDURE handleExpression*(e: Expression.PType);
+    Type* = RECORD(ContextExpression.ExpressionHandler)
+        PROCEDURE handleQIdent(q: ContextHierarchy.QIdent);
         PROCEDURE handleTypeCast(type: Types.PType);
 
         PROCEDURE doCheckIndexType*(type: Types.PType);

+ 1 - 3
src/ob/ContextExpression.ob

@@ -35,7 +35,6 @@ TYPE
         PROCEDURE handleSimpleExpression(e: Expression.PType);
         PROCEDURE doRelationOperation*(left, right: Expression.PType; relation: STRING): BinaryOperatorCx;
 
-        expressionHandler: PExpressionHandler;
         relOps: PRelationOps;
         expression: Expression.PType;
         relation: STRING;
@@ -493,7 +492,6 @@ END;
 
 PROCEDURE ExpressionNode.ExpressionNode(parent: PExpressionHandler; ops: PRelationOps)
     | SUPER(parent),
-      expressionHandler(parent),
       relOps(ops);
 BEGIN
     IF ops = NIL THEN
@@ -617,7 +615,7 @@ BEGIN
         Errors.raise("procedure returning no result cannot be used in an expression");
     END;
 
-    parent <- SELF.expressionHandler;
+    parent <- SELF.parent()(PExpressionHandler);
     parent.codeGenerator().write(SELF.expression.code());
     parent.handleExpression(SELF.expression);
 

+ 0 - 1
test/test_unit.js

@@ -113,7 +113,6 @@ return {
             handleIdent: function(id){this.__ident = id;},
             ident: function() {return this.__ident;},
             getResult: function() {return this.__ident;},
-            currentScope: function(){return {close: function(){}};}
         });
         function makeContext() {return new IdentDeclarationContext();}
 

+ 14 - 7
test/test_unit_common.js

@@ -2,6 +2,7 @@
 
 var Class = require("rtl.js").Class;
 var Code = require("js/Code.js");
+var ContextExpression = require("js/ContextExpression.js");
 var ContextHierarchy = require("js/ContextHierarchy.js");
 var ContextType = require("js/ContextType.js");
 var Errors = require("js/Errors.js");
@@ -27,8 +28,8 @@ var TestModuleGenerator = Class.extend({
     epilog: function(){return undefined;}
 });
 
-var TestContext = Class.extend.call(ContextHierarchy.Root, {
-    init: function TestContext(language){
+var TestContextRoot = Class.extend.call(ContextHierarchy.Root, {
+    init: function TestContextRoot(language){
         var rtl = new makeRTL(language.rtl);
         ContextHierarchy.Root.call(
                 this,
@@ -45,10 +46,16 @@ var TestContext = Class.extend.call(ContextHierarchy.Root, {
         if (msg instanceof ContextType.DescribeScopeMsg)
             msg.result = new ContextType.ScopeInfo("test", 0);
     },
-    handleExpression: function(){},
     handleLiteral: function(){}
 });
 
+var TestContext = Class.extend.call(ContextExpression.ExpressionHandler, {
+    init: function TestContext(language){
+        ContextExpression.ExpressionHandler.call(this, new TestContextRoot(language));
+    },
+    handleExpression: function(){}
+});
+
 function makeContext(language){return new TestContext(language);}
 
 function testWithSetup(setup, pass, fail){
@@ -116,7 +123,8 @@ function parseUsingGrammar(parser, language, s, cxFactory){
     var baseContext = makeContext(language);
     var context = cxFactory ? cxFactory(baseContext) : baseContext;
     parseInContext(parser, s, context);
-    context.currentScope().close();
+    if (context.root)
+        context.root().currentScope().close();
 }
 
 function setupParser(parser, language, contextFactory){
@@ -160,9 +168,8 @@ function testWithGrammar(parser, language, pass, fail){
 var TestContextWithModule = TestContext.extend({
     init: function(module, language){
         TestContext.prototype.init.call(this, language);
-        this.__module = module;
-    },
-    findModule: function(){return this.__module;}
+        this.root().findModule = function(){return module;};
+    }
 });
 
 function testWithModule(src, language, pass, fail){