Explorar el Código

Conditional compilation of skipped cells (introduced feature "Runtime = "A2")

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6926 8c9fc860-2736-0410-a75d-ab315db34111
felixf hace 9 años
padre
commit
9e11c6357c
Se han modificado 3 ficheros con 61 adiciones y 30 borrados
  1. 3 1
      source/FoxGlobal.Mod
  2. 40 29
      source/FoxSemanticChecker.Mod
  3. 18 0
      source/FoxSyntaxTree.Mod

+ 3 - 1
source/FoxGlobal.Mod

@@ -60,6 +60,7 @@ CONST
 	StringTRM*="TRM";
 	StringTRMS*="TRMS";
 	StringBackend*="Backend";
+	StringRuntime*="Runtime";
 
 	(* traps *)
 	WithTrap* = 1;
@@ -189,7 +190,7 @@ VAR
 	NameWinAPI-,NameC-,NameMovable-,NameUntraced-,NameDelegate-,NameInterrupt-, NamePcOffset-, NameNoPAF-,NameEntry-, NameExit-, NameFixed-,NameFictive-, NameAligned-,NameStackAligned-,
 	NameExclusive-,NameActive-,NamePriority-,NameSafe-,NameRealtime-, NameDynamic-, NameDataMemorySize-, NameCodeMemorySize-
 	, NameChannelWidth-, NameChannelDepth-, NameChannelModule-, NameVector-, NameFloatingPoint-, NameNoMul-,NameNonBlockingIO-, NameTRM-, NameTRMS-, NameEngine-, NameFinal-, NameAbstract-,
-	NameBackend-, NameFrequencyDivider-, NameRegister-,NameNoReturn-,NamePlain-,NameUnsafe-,NameDisposable-,NameUnchecked-,NameUncooperative-: SyntaxTree.Identifier;
+	NameBackend-, NameRuntime-, NameFrequencyDivider-, NameRegister-,NameNoReturn-,NamePlain-,NameUnsafe-,NameDisposable-,NameUnchecked-,NameUncooperative-: SyntaxTree.Identifier;
 
 	identifiers: ARRAY 2 OF ARRAY end OF SyntaxTree.Identifier;
 
@@ -1692,6 +1693,7 @@ TYPE
 		NameTRM := SyntaxTree.NewIdentifier(StringTRM);
 		NameTRMS := SyntaxTree.NewIdentifier(StringTRMS);
 		NameBackend := SyntaxTree.NewIdentifier(StringBackend);
+		NameRuntime := SyntaxTree.NewIdentifier(StringRuntime);
 		NameEngine := SyntaxTree.NewIdentifier(StringEngine);
 		NameFinal := SyntaxTree.NewIdentifier(StringFinal);
 		NameAbstract := SyntaxTree.NewIdentifier(StringAbstract);

+ 40 - 29
source/FoxSemanticChecker.Mod

@@ -869,6 +869,14 @@ TYPE
 		VAR svalue: ARRAY 32 OF CHAR; position: LONGINT;
 		BEGIN
 			IF cellsAreObjects THEN RETURN FALSE END;
+			IF HasStringValue(x.modifiers, Global.NameRuntime, position, svalue) THEN
+				IF  svalue = "A2" THEN 
+					RETURN TRUE 
+				END;
+			END;
+			RETURN FALSE; 
+			(*
+			(*IF cellsAreObjects THEN RETURN FALSE END;*)
 			IF (backendName = "TRM") & x.isCellNet THEN  RETURN TRUE END;
 			IF HasStringValue(x.modifiers,Global.NameBackend,position,svalue) THEN 
 				IF svalue[0] = "~" THEN
@@ -880,10 +888,11 @@ TYPE
 					RETURN TRUE;
 				END;
 			END;
-			IF x.baseType # NIL THEN
+			IF (x.baseType # NIL) & (x.baseType.resolved IS SyntaxTree.CellType) THEN
 				RETURN SkipImplementation(x.baseType.resolved(SyntaxTree.CellType));
 			END;
 			RETURN FALSE;
+			*)
 		END SkipImplementation;
 
 		PROCEDURE CheckModifiers(modifiers: SyntaxTree.Modifier; checkUse: BOOLEAN);
@@ -1242,7 +1251,7 @@ TYPE
 				x.SetState(SyntaxTree.Resolved);
 
 				IF (x.cellScope.bodyProcedure = NIL) & (~isEngine)THEN
-					Error(x.position, Diagnostics.Invalid, "Forbidden empty Body.");
+					Warning(x.position, "Forbidden empty Body.");
 				ELSIF (x.cellScope.bodyProcedure # NIL) & (isEngine)THEN
 					Warning(x.position, "Non-empty body for an engine?");
 				END;
@@ -8340,6 +8349,7 @@ TYPE
 				parameter := scope(SyntaxTree.ProcedureScope).ownerProcedure.type.resolved(SyntaxTree.ProcedureType).returnParameter;
 				IF parameter # NIL THEN Register(parameter, currentScope, FALSE); END;
 			ELSIF scope IS SyntaxTree.CellScope THEN
+				DeclareCell(scope(SyntaxTree.CellScope).ownerCell);
 				IF~skipImplementation THEN
 					import := scope(SyntaxTree.CellScope).firstImport;
 					WHILE(import # NIL) DO
@@ -8353,10 +8363,13 @@ TYPE
 						import := import.nextImport;
 					END;
 				END;
-				DeclareCell(scope(SyntaxTree.CellScope).ownerCell);
 			END;
 			IF error THEN RETURN END;
 
+			IF skipImplementation THEN
+				scope.Clear;
+			END;
+		
 			(* constants *)
 			constant := scope.firstConstant;
 			WHILE (constant # NIL) DO
@@ -8378,39 +8391,37 @@ TYPE
 				Register(procedure, currentScope, procedure IS SyntaxTree.Operator); procedure := procedure.nextProcedure;
 			END;
 
-			IF ~skipImplementation THEN
-				(* now process all symbols without any presumption on the order *)
-				symbol := scope.firstSymbol;
-				WHILE(symbol # NIL) DO
-					IF ~(symbol IS SyntaxTree.Parameter) OR (symbol(SyntaxTree.Parameter).ownerType IS SyntaxTree.CellType) THEN
-						ResolveSymbol(symbol);
-					END;
-					symbol := symbol.nextSymbol;
+			(* now process all symbols without any presumption on the order *)
+			symbol := scope.firstSymbol;
+			WHILE(symbol # NIL) DO
+				IF ~(symbol IS SyntaxTree.Parameter) OR (symbol(SyntaxTree.Parameter).ownerType IS SyntaxTree.CellType) THEN
+					ResolveSymbol(symbol);
 				END;
+				symbol := symbol.nextSymbol;
+			END;
 
-				IF (scope IS SyntaxTree.ProcedureScope) & scope(SyntaxTree.ProcedureScope).ownerProcedure.type.isRealtime THEN
-					symbol := scope.firstSymbol;
-					WHILE symbol # NIL DO
-						IF (symbol IS SyntaxTree.Variable) OR (symbol IS SyntaxTree.Parameter) THEN
-							IF (symbol.type IS SyntaxTree.PointerType) OR (symbol.type IS SyntaxTree.QualifiedType) THEN
-								pointerFixes.Add(symbol, currentScope);
-							END;
-							IF ~symbol.type.resolved.isRealtime THEN
-								Error(symbol.position,Diagnostics.Invalid,"symbol has no realtime type");
-							END;
+			IF (scope IS SyntaxTree.ProcedureScope) & scope(SyntaxTree.ProcedureScope).ownerProcedure.type.isRealtime THEN
+				symbol := scope.firstSymbol;
+				WHILE symbol # NIL DO
+					IF (symbol IS SyntaxTree.Variable) OR (symbol IS SyntaxTree.Parameter) THEN
+						IF (symbol.type IS SyntaxTree.PointerType) OR (symbol.type IS SyntaxTree.QualifiedType) THEN
+							pointerFixes.Add(symbol, currentScope);
+						END;
+						IF ~symbol.type.resolved.isRealtime THEN
+							Error(symbol.position,Diagnostics.Invalid,"symbol has no realtime type");
 						END;
-						symbol := symbol.nextSymbol
 					END;
+					symbol := symbol.nextSymbol
 				END;
+			END;
 
-				IF ~error & ~system.GenerateVariableOffsets(scope) THEN
-					Error(Diagnostics.Invalid,Diagnostics.Invalid,"problems during offset computation in module");
-				END;
+			IF ~error & ~system.GenerateVariableOffsets(scope) THEN
+				Error(Diagnostics.Invalid,Diagnostics.Invalid,"problems during offset computation in module");
+			END;
 
-				IF  (scope.ownerModule # NIL) THEN
-					(* add scope to global list of all scopes, very handy for code generation and for checking implementations *)
-					scope.ownerModule.AddScope(scope);
-				END;
+			IF  (scope.ownerModule # NIL) THEN
+				(* add scope to global list of all scopes, very handy for code generation and for checking implementations *)
+				scope.ownerModule.AddScope(scope);
 			END;
 
 			phase := prevPhase;

+ 18 - 0
source/FoxSyntaxTree.Mod

@@ -4501,6 +4501,14 @@ TYPE
 			END;
 			nextScope := NIL;
 		END InitScope;
+		
+		PROCEDURE Clear*;
+		BEGIN
+			firstConstant := NIL; lastConstant := NIL; numberConstants := 0;
+			firstTypeDeclaration := NIL; lastTypeDeclaration := NIL; numberTypeDeclarations := 0;
+			firstVariable := NIL; lastVariable := NIL; numberVariables := 0;
+			firstProcedure := NIL; lastProcedure := NIL; numberProcedures := 0;
+		END Clear;
 
 		(** Enter a symbol in the scope, aplhabetically sorted, duplicate = TRUE if multiply identifier *)
 		PROCEDURE EnterSymbol*(symbol: Symbol; VAR duplicate: BOOLEAN);
@@ -4847,7 +4855,17 @@ TYPE
 			ownerCell := NIL;
 			bodyProcedure := NIL;
 			constructor := NIL;
+			firstImport := NIL; lastImport := NIL; numberImports := 0; 
 		END InitCellScope;
+		
+		PROCEDURE Clear*;
+		BEGIN
+			Clear^;
+			firstImport := NIL; lastImport := NIL; numberImports := 0; 
+			constructor := NIL;
+			bodyProcedure := NIL;
+		END Clear;
+		
 
 		PROCEDURE SetOwnerCell*(owner: CellType);
 		BEGIN