|
@@ -106,21 +106,23 @@ TYPE
|
|
END;
|
|
END;
|
|
PField* = POINTER TO Field;
|
|
PField* = POINTER TO Field;
|
|
|
|
|
|
|
|
+ PStorageType* = POINTER TO StorageType;
|
|
|
|
+
|
|
RecordField* = RECORD(Field)
|
|
RecordField* = RECORD(Field)
|
|
- PROCEDURE RecordField*(identdef: Context.PIdentdefInfo; type: PType);
|
|
|
|
|
|
+ PROCEDURE RecordField*(identdef: Context.PIdentdefInfo; type: PStorageType);
|
|
|
|
|
|
PROCEDURE identdef*(): Context.PIdentdefInfo;
|
|
PROCEDURE identdef*(): Context.PIdentdefInfo;
|
|
|
|
|
|
mIdentdef: Context.PIdentdefInfo;
|
|
mIdentdef: Context.PIdentdefInfo;
|
|
- mType: PType;
|
|
|
|
|
|
+ mType: PStorageType;
|
|
END;
|
|
END;
|
|
PRecordField* = POINTER TO RecordField;
|
|
PRecordField* = POINTER TO RecordField;
|
|
|
|
|
|
StorageType* = RECORD(Type)
|
|
StorageType* = RECORD(Type)
|
|
PROCEDURE initializer*(cx: Context.Type): STRING;
|
|
PROCEDURE initializer*(cx: Context.Type): STRING;
|
|
PROCEDURE denote*(id: STRING; isReadObly: BOOLEAN): PField;
|
|
PROCEDURE denote*(id: STRING; isReadObly: BOOLEAN): PField;
|
|
|
|
+ PROCEDURE isScalar*(): BOOLEAN;
|
|
END;
|
|
END;
|
|
- PStorageType* = POINTER TO StorageType;
|
|
|
|
|
|
|
|
NamedType* = RECORD(StorageType)
|
|
NamedType* = RECORD(StorageType)
|
|
PROCEDURE NamedType(name: STRING);
|
|
PROCEDURE NamedType(name: STRING);
|
|
@@ -129,9 +131,9 @@ TYPE
|
|
END;
|
|
END;
|
|
|
|
|
|
Array* = RECORD(NamedType)
|
|
Array* = RECORD(NamedType)
|
|
- PROCEDURE Array*(elementsType: PType);
|
|
|
|
|
|
+ PROCEDURE Array*(elementsType: PStorageType);
|
|
|
|
|
|
- elementsType-: PType
|
|
|
|
|
|
+ elementsType-: PStorageType
|
|
END;
|
|
END;
|
|
PArray* = POINTER TO Array;
|
|
PArray* = POINTER TO Array;
|
|
|
|
|
|
@@ -140,7 +142,7 @@ TYPE
|
|
POpenArray* = POINTER TO OpenArray;
|
|
POpenArray* = POINTER TO OpenArray;
|
|
|
|
|
|
StaticArray* = RECORD(Array)
|
|
StaticArray* = RECORD(Array)
|
|
- PROCEDURE StaticArray*(initializer: STRING; elementsType: PType; len: INTEGER);
|
|
|
|
|
|
+ PROCEDURE StaticArray*(initializer: STRING; elementsType: PStorageType; len: INTEGER);
|
|
|
|
|
|
PROCEDURE length*(): INTEGER;
|
|
PROCEDURE length*(): INTEGER;
|
|
|
|
|
|
@@ -190,6 +192,8 @@ TYPE
|
|
|
|
|
|
PBasicType* = POINTER TO BasicType;
|
|
PBasicType* = POINTER TO BasicType;
|
|
|
|
|
|
|
|
+ FieldsMap = MAP OF PField;
|
|
|
|
+
|
|
Record* = RECORD(NamedType)
|
|
Record* = RECORD(NamedType)
|
|
PROCEDURE Record*(name: STRING; cons: STRING; scope: ScopeBase.PType);
|
|
PROCEDURE Record*(name: STRING; cons: STRING; scope: ScopeBase.PType);
|
|
|
|
|
|
@@ -199,7 +203,7 @@ TYPE
|
|
PROCEDURE codeForNew*(cx: Context.Type): STRING;
|
|
PROCEDURE codeForNew*(cx: Context.Type): STRING;
|
|
PROCEDURE finalize*();
|
|
PROCEDURE finalize*();
|
|
|
|
|
|
- fields-: MAP OF PField;
|
|
|
|
|
|
+ fields-: FieldsMap;
|
|
base-: PRecord;
|
|
base-: PRecord;
|
|
cons-: STRING;
|
|
cons-: STRING;
|
|
scope-: ScopeBase.PType;
|
|
scope-: ScopeBase.PType;
|
|
@@ -261,6 +265,14 @@ BEGIN
|
|
SELF.notExported.clear();
|
|
SELF.notExported.clear();
|
|
END Record.finalize;
|
|
END Record.finalize;
|
|
|
|
|
|
|
|
+PROCEDURE Record.isScalar(): BOOLEAN;
|
|
|
|
+ RETURN FALSE;
|
|
|
|
+END;
|
|
|
|
+
|
|
|
|
+PROCEDURE recordOwnFields*(r: Record): FieldsMap;
|
|
|
|
+ RETURN r.fields;
|
|
|
|
+END;
|
|
|
|
+
|
|
PROCEDURE Record.Record(name: STRING; cons: STRING; scope: ScopeBase.PType)
|
|
PROCEDURE Record.Record(name: STRING; cons: STRING; scope: ScopeBase.PType)
|
|
| SUPER(name),
|
|
| SUPER(name),
|
|
cons(cons),
|
|
cons(cons),
|
|
@@ -404,6 +416,10 @@ PROCEDURE BasicType.initializer(cx: Context.Type): STRING;
|
|
RETURN SELF.mInitializer
|
|
RETURN SELF.mInitializer
|
|
END BasicType.initializer;
|
|
END BasicType.initializer;
|
|
|
|
|
|
|
|
+PROCEDURE BasicType.isScalar(): BOOLEAN;
|
|
|
|
+ RETURN TRUE;
|
|
|
|
+END;
|
|
|
|
+
|
|
PROCEDURE Nil.description(): STRING;
|
|
PROCEDURE Nil.description(): STRING;
|
|
RETURN "NIL"
|
|
RETURN "NIL"
|
|
END Nil.description;
|
|
END Nil.description;
|
|
@@ -546,6 +562,10 @@ BEGIN
|
|
RETURN existingField(base^, id, d^)
|
|
RETURN existingField(base^, id, d^)
|
|
END;
|
|
END;
|
|
|
|
|
|
|
|
+PROCEDURE Pointer.isScalar(): BOOLEAN;
|
|
|
|
+ RETURN TRUE;
|
|
|
|
+END;
|
|
|
|
+
|
|
PROCEDURE foldArrayDimensions(VAR a: Array; dimToStr: ArrayDimensionDescriptionCallback; VAR sizes, of: STRING);
|
|
PROCEDURE foldArrayDimensions(VAR a: Array; dimToStr: ArrayDimensionDescriptionCallback; VAR sizes, of: STRING);
|
|
BEGIN
|
|
BEGIN
|
|
elementsType <- a.elementsType;
|
|
elementsType <- a.elementsType;
|
|
@@ -587,7 +607,11 @@ END arrayDescription;
|
|
|
|
|
|
PROCEDURE Array.description(): STRING;
|
|
PROCEDURE Array.description(): STRING;
|
|
RETURN arrayDescription(SELF, arrayDimensionDescription)
|
|
RETURN arrayDescription(SELF, arrayDimensionDescription)
|
|
-END Array.description;
|
|
|
|
|
|
+END;
|
|
|
|
+
|
|
|
|
+PROCEDURE Array.isScalar(): BOOLEAN;
|
|
|
|
+ RETURN FALSE;
|
|
|
|
+END;
|
|
|
|
|
|
PROCEDURE StorageType.denote(id: STRING; isReadObly: BOOLEAN): PField;
|
|
PROCEDURE StorageType.denote(id: STRING; isReadObly: BOOLEAN): PField;
|
|
BEGIN
|
|
BEGIN
|
|
@@ -604,24 +628,20 @@ PROCEDURE StaticArray.initializer(cx: Context.Type): STRING;
|
|
RETURN SELF.mInitializer
|
|
RETURN SELF.mInitializer
|
|
END StaticArray.initializer;
|
|
END StaticArray.initializer;
|
|
|
|
|
|
-PROCEDURE arrayElementsType*(a: Array): PType;
|
|
|
|
|
|
+PROCEDURE arrayElementsType*(a: Array): PStorageType;
|
|
RETURN a.elementsType
|
|
RETURN a.elementsType
|
|
END arrayElementsType;
|
|
END arrayElementsType;
|
|
|
|
|
|
-PROCEDURE arrayBaseElementsType*(a: Array): PType;
|
|
|
|
|
|
+PROCEDURE arrayBaseElementsType*(a: Array): PStorageType;
|
|
VAR
|
|
VAR
|
|
- result: PType;
|
|
|
|
|
|
+ result: PStorageType;
|
|
BEGIN
|
|
BEGIN
|
|
result := a.elementsType;
|
|
result := a.elementsType;
|
|
WHILE result IS PArray DO
|
|
WHILE result IS PArray DO
|
|
result := result(PArray).elementsType;
|
|
result := result(PArray).elementsType;
|
|
END;
|
|
END;
|
|
- RETURN result
|
|
|
|
-END arrayBaseElementsType;
|
|
|
|
-
|
|
|
|
-PROCEDURE isScalar*(VAR t: Type): BOOLEAN;
|
|
|
|
- RETURN ~(t IS Array) & ~(t IS Record)
|
|
|
|
-END isScalar;
|
|
|
|
|
|
+ RETURN result;
|
|
|
|
+END;
|
|
|
|
|
|
PROCEDURE StaticArray.length(): INTEGER;
|
|
PROCEDURE StaticArray.length(): INTEGER;
|
|
RETURN SELF.len
|
|
RETURN SELF.len
|
|
@@ -635,6 +655,10 @@ PROCEDURE Procedure.description(): STRING;
|
|
RETURN SELF.name
|
|
RETURN SELF.name
|
|
END Procedure.description;
|
|
END Procedure.description;
|
|
|
|
|
|
|
|
+PROCEDURE Procedure.isScalar(): BOOLEAN;
|
|
|
|
+ RETURN TRUE;
|
|
|
|
+END;
|
|
|
|
+
|
|
PROCEDURE DefinedProcedure.designatorCode(id: STRING): STRING;
|
|
PROCEDURE DefinedProcedure.designatorCode(id: STRING): STRING;
|
|
RETURN id
|
|
RETURN id
|
|
END DefinedProcedure.designatorCode;
|
|
END DefinedProcedure.designatorCode;
|
|
@@ -674,7 +698,7 @@ PROCEDURE NamedType.NamedType(name: STRING)
|
|
| name(name);
|
|
| name(name);
|
|
END;
|
|
END;
|
|
|
|
|
|
-PROCEDURE Array.Array(elementsType: PType)
|
|
|
|
|
|
+PROCEDURE Array.Array(elementsType: PStorageType)
|
|
| SUPER(""),
|
|
| SUPER(""),
|
|
elementsType(elementsType);
|
|
elementsType(elementsType);
|
|
BEGIN
|
|
BEGIN
|
|
@@ -682,7 +706,7 @@ END;
|
|
|
|
|
|
PROCEDURE StaticArray.StaticArray(
|
|
PROCEDURE StaticArray.StaticArray(
|
|
initializer: STRING;
|
|
initializer: STRING;
|
|
- elementsType: PType;
|
|
|
|
|
|
+ elementsType: PStorageType;
|
|
len: INTEGER ) |
|
|
len: INTEGER ) |
|
|
SUPER(elementsType),
|
|
SUPER(elementsType),
|
|
mInitializer(initializer),
|
|
mInitializer(initializer),
|
|
@@ -745,12 +769,12 @@ BEGIN
|
|
RETURN result;
|
|
RETURN result;
|
|
END;
|
|
END;
|
|
|
|
|
|
-PROCEDURE mangleField*(id: STRING; type: PType): STRING;
|
|
|
|
|
|
+PROCEDURE mangleField*(id: STRING; type: PStorageType): STRING;
|
|
BEGIN
|
|
BEGIN
|
|
result <- id;
|
|
result <- id;
|
|
- IF isScalar(type^)
|
|
|
|
|
|
+ IF type.isScalar()
|
|
OR ((type IS PArray)
|
|
OR ((type IS PArray)
|
|
- & isScalar(arrayBaseElementsType(type^)^)) THEN
|
|
|
|
|
|
+ & arrayBaseElementsType(type^).isScalar()) THEN
|
|
result := mangleJSProperty(result);
|
|
result := mangleJSProperty(result);
|
|
ELSE
|
|
ELSE
|
|
result := "$" + result;
|
|
result := "$" + result;
|
|
@@ -786,7 +810,7 @@ PROCEDURE RecordField.asVar(isReadOnly: BOOLEAN; cx: Context.Type): PId;
|
|
RETURN makeVariable(SELF.mType, isReadOnly);
|
|
RETURN makeVariable(SELF.mType, isReadOnly);
|
|
END;
|
|
END;
|
|
|
|
|
|
-PROCEDURE RecordField.RecordField(identdef: Context.PIdentdefInfo; type: PType)
|
|
|
|
|
|
+PROCEDURE RecordField.RecordField(identdef: Context.PIdentdefInfo; type: PStorageType)
|
|
| mIdentdef(identdef),
|
|
| mIdentdef(identdef),
|
|
mType(type);
|
|
mType(type);
|
|
END;
|
|
END;
|