Browse Source

Patched exporting of ports for ActiveCells3 -- problem was the overlay of port parameters by hidden variables -- requires cleanup

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6351 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 years ago
parent
commit
bda94f50c8
1 changed files with 11 additions and 2 deletions
  1. 11 2
      source/FoxSemanticChecker.Mod

+ 11 - 2
source/FoxSemanticChecker.Mod

@@ -191,14 +191,21 @@ TYPE
 		PROCEDURE Find(inScope: SyntaxTree.Scope; name: SyntaxTree.Identifier; traverse: BOOLEAN): SyntaxTree.Symbol;
 		PROCEDURE Find(inScope: SyntaxTree.Scope; name: SyntaxTree.Identifier; traverse: BOOLEAN): SyntaxTree.Symbol;
 		VAR
 		VAR
 			scope,baseScope: SyntaxTree.Scope;
 			scope,baseScope: SyntaxTree.Scope;
-			symbol: SyntaxTree.Symbol;
+			symbol, s: SyntaxTree.Symbol;
 			ownerRecord,base: SyntaxTree.RecordType;
 			ownerRecord,base: SyntaxTree.RecordType;
 		BEGIN
 		BEGIN
 			scope := inScope;
 			scope := inScope;
+			symbol := NIL;
+
 			WHILE (scope # NIL) & (symbol = NIL) DO
 			WHILE (scope # NIL) & (symbol = NIL) DO
 				symbol := scope.FindSymbol(name);
 				symbol := scope.FindSymbol(name);
+				s := NIL;
+				IF (symbol # NIL) & (symbol.access * SyntaxTree.Public = {}) & (symbol.scope IS SyntaxTree.CellScope) (* hidden copies of parameters *) THEN
+					s := symbol.scope(SyntaxTree.CellScope).ownerCell.FindParameter(name);
+				END;
 
 
 				IF (symbol # NIL) & (symbol IS SyntaxTree.Parameter) & (symbol.scope IS SyntaxTree.CellScope) THEN (* ok, symbol auto-export in scope *)
 				IF (symbol # NIL) & (symbol IS SyntaxTree.Parameter) & (symbol.scope IS SyntaxTree.CellScope) THEN (* ok, symbol auto-export in scope *)
+				ELSIF s # NIL THEN (* hidden variable shadows port parameter *)
 				ELSE
 				ELSE
 					WHILE (symbol # NIL) & (symbol.scope.ownerModule # currentScope.ownerModule) & (symbol.access * SyntaxTree.Public = {}) DO
 					WHILE (symbol # NIL) & (symbol.scope.ownerModule # currentScope.ownerModule) & (symbol.access * SyntaxTree.Public = {}) DO
 						(* found symbol in different module, but is it not exported, can we go on searching in record base scopes ? *)
 						(* found symbol in different module, but is it not exported, can we go on searching in record base scopes ? *)
@@ -3591,7 +3598,6 @@ TYPE
 				IF (left.type # NIL) & IsPointerType(left.type.resolved) THEN
 				IF (left.type # NIL) & IsPointerType(left.type.resolved) THEN
 					left := NewDereferenceDesignator(selectorDesignator.position,left);
 					left := NewDereferenceDesignator(selectorDesignator.position,left);
 				END;
 				END;
-
 				scope := NIL;
 				scope := NIL;
 				IF left.type = NIL THEN
 				IF left.type = NIL THEN
 					Error(selectorDesignator.position,Diagnostics.Invalid,"field on nil typed designator");
 					Error(selectorDesignator.position,Diagnostics.Invalid,"field on nil typed designator");
@@ -3635,6 +3641,9 @@ TYPE
 					ELSE
 					ELSE
 						Error(selectorDesignator.position,Diagnostics.Invalid,"undeclared identifier (selector)");
 						Error(selectorDesignator.position,Diagnostics.Invalid,"undeclared identifier (selector)");
 						IF VerboseErrorMessage THEN
 						IF VerboseErrorMessage THEN
+							D.Str("IDENT = "); D.Str0(selectorDesignator.identifier); D.Ln; 
+							Printout.Info("scope", scope);
+							Printout.Info("left", left);
 							Printout.Info("undeclared identifier",selectorDesignator);
 							Printout.Info("undeclared identifier",selectorDesignator);
 							Printout.Info("left resolved designator",left);
 							Printout.Info("left resolved designator",left);
 						END
 						END