Vladislav Folts 9 éve
szülő
commit
60a0cd80e4

BIN
bin/compiled.zip


+ 1 - 8
src/eberon/EberonContextType.ob

@@ -33,7 +33,6 @@ TYPE
     END;
 
     Map* = RECORD(ContextType.DeclarationHandle)
-        type: Types.PStorageType;
     END;
 
     MethodDeclMsg = RECORD(ContextHierarchy.Message)
@@ -213,7 +212,7 @@ END;
 
 PROCEDURE Map.setType(type: Types.PStorageType);
 BEGIN
-    SELF.type := type;
+    SELF.parent()^(ContextType.HandleSymbolAsType).setType(NEW EberonMap.Type(type));
 END;
 
 (* anonymous types can be used in map declaration *)
@@ -225,12 +224,6 @@ PROCEDURE Map.typeName(): STRING;
     RETURN "";
 END;
 
-PROCEDURE Map.endParse(): BOOLEAN;
-BEGIN
-    SELF.parent()^(ContextType.HandleSymbolAsType).setType(NEW EberonMap.Type(SELF.type));
-    RETURN TRUE;
-END;
-
 PROCEDURE MethodDeclMsg.MethodDeclMsg(id: Context.PIdentdefInfo; type: Procedure.PType)
     | id(id),
       type(type);

+ 1 - 8
src/ob/ContextType.ob

@@ -25,7 +25,6 @@ TYPE
         PROCEDURE doMakeType*(elementsType: Types.PStorageType; init: STRING; length: INTEGER): Types.PStorageType;
 
         dimensions: POINTER TO ArrayDimensions;
-        type: Types.PStorageType;
     END;
 
     ArrayDimensions* = RECORD(ContextExpression.ExpressionHandler) 
@@ -166,7 +165,7 @@ BEGIN
         type := SELF.doMakeType(type, arrayInit, length);
     END;
 
-    SELF.type := type;
+    SELF.parent()(PHandleSymbolAsType).setType(type);
 END;
 
 PROCEDURE Array.isAnonymousDeclaration(): BOOLEAN;
@@ -196,12 +195,6 @@ PROCEDURE Array.doMakeType(elementsType: Types.PStorageType; init: STRING; lengt
     RETURN SELF.root().language().types.makeStaticArray(elementsType, init, length);
 END;
 
-PROCEDURE Array.endParse(): BOOLEAN;
-BEGIN
-    SELF.parent()(PHandleSymbolAsType).setType(SELF.type);
-    RETURN TRUE;
-END;
-
 PROCEDURE ArrayDimensions.handleExpression(e: Expression.PType);
 BEGIN
     type <- e.type();

+ 4 - 3
test/test_unit.js

@@ -145,7 +145,8 @@ return {
          ["T = RECORD a: ARRAY 3 OF ARRAY 5 OF T END", "recursive field definition: 'a'"],
          ["T = RECORD r: RECORD rr: T END END", "recursive field definition: 'r'"],
          ["T = RECORD (T) END", "recursive inheritance: 'T'"],
-         ["T = RECORD r: RECORD (T) END END", "recursive field definition: 'r'"]
+         ["T = RECORD r: RECORD (T) END END", "recursive field definition: 'r'"],
+         ["T = RECORD p: PROCEDURE(): T END", "procedure cannot return T"]
          )
     ),
 "record cannot have forward type as a base": testWithGrammar(
@@ -200,8 +201,8 @@ return {
          "T = PROCEDURE(a: INTEGER; b: BOOLEAN)",
          "T = PROCEDURE(): T"),
     fail(["T = PROCEDURE(): A;", "procedure cannot return ARRAY 3 OF INTEGER"],
-         ["T = PROCEDURE(): R;", "procedure cannot return R"]
-         //TODO:["T = ARRAY 3 OF PROCEDURE(): T;", "test"]
+         ["T = PROCEDURE(): R;", "procedure cannot return R"],
+         ["T = ARRAY 3 OF PROCEDURE(): T;", "procedure cannot return ARRAY 3 OF PROCEDURE"]
         )
     ),
 "POINTER declaration": testWithGrammar(

+ 1 - 1
test/test_unit_eberon.js

@@ -1352,7 +1352,7 @@ exports.suite = {
              "TYPE M = MAP OF PROCEDURE;",
              "TYPE M = MAP OF PROCEDURE();",
              "TYPE M = MAP OF PROCEDURE(): INTEGER;",
-             //TODO:"TYPE M = MAP OF PROCEDURE(): M;",
+             "TYPE M = MAP OF PROCEDURE(): M;",
              "TYPE M = MAP OF RECORD END;",
              "TYPE M = MAP OF POINTER TO RECORD END;",
              "TYPE M = MAP OF MAP OF INTEGER;",