Quellcode durchsuchen

Extra check for exported types. Not needed in current understanding.

Vladislav Folts vor 11 Jahren
Ursprung
Commit
528748baab
2 geänderte Dateien mit 18 neuen und 0 gelöschten Zeilen
  1. 16 0
      src/context.js
  2. 2 0
      test/test_unit.js

+ 16 - 0
src/context.js

@@ -486,6 +486,12 @@ exports.FormalParametersProcDecl = exports.FormalParameters.extend({
         exports.FormalParameters.prototype.addArgument.call(this, name, arg);
         this.parent().addArgument(name, arg);
     },
+    /*
+    handleSymbol: function(s){
+        exports.FormalParameters.prototype.handleSymbol.call(this, s);
+        this.parent().checkResultType(s);
+    },
+    */
     endParse: function(){
         exports.FormalParameters.prototype.endParse.call(this);
         this.parent().endParameters();
@@ -540,6 +546,16 @@ exports.ProcDecl = ChainedContext.extend({
         code.write(")");
         code.openScope();
     },
+    /*
+    checkResultType: function(s){
+        if (this.__id.exported()){
+            if (!s.scope().exports()[s.symbol().id()])
+                throw new Errors.Error(
+                    "exported PROCEDURE '" + this.__id.id()
+                    + "' uses non-exported type '" + s.symbol().id() + "'");
+        }
+    },
+    */
     handleReturn: function(type){
         var result = this.__type.result();
         if (!result)

+ 2 - 0
test/test_unit.js

@@ -1272,6 +1272,8 @@ var testSuite = {
           "cannot export anonymous RECORD field: 'r'"],
          ["PROCEDURE p*; VAR i*: INTEGER; END p;",
           "cannot export from within procedure: variable 'i'"]
+         //["TYPE PT = POINTER TO RECORD END; PROCEDURE p*(): PT; RETURN NIL END p;",
+         //"exported PROCEDURE 'p' uses non-exported type 'PT'"]
          )
     ),
 "import JS": testWithGrammar(