Pārlūkot izejas kodu

Patched bug with dynamic strings passed as string property

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6989 8c9fc860-2736-0410-a75d-ab315db34111
felixf 8 gadi atpakaļ
vecāks
revīzija
5bf7bac9fa
1 mainītis faili ar 17 papildinājumiem un 18 dzēšanām
  1. 17 18
      source/FoxIntermediateBackend.Mod

+ 17 - 18
source/FoxIntermediateBackend.Mod

@@ -7153,8 +7153,7 @@ TYPE
 				ELSIF SemanticChecker.IsStringType(property.type) THEN 
 					ASSERT(SemanticChecker.IsStringType(value.type));
 					Designate(value, op);
-					Emit(Push(property.position, op.tag));
-					Emit(Push(property.position, op.op));
+					PushString(op, value.type);
 					ReleaseOperand(op);
 					CallThis(position,"ActiveCellsRuntime","AddStringProperty",7);
 				ELSIF (property.type.resolved IS SyntaxTree.IntegerType) THEN
@@ -7248,8 +7247,7 @@ TYPE
 			IF SemanticChecker.IsStringType(modifier.expression.type) THEN 
 				ASSERT(SemanticChecker.IsStringType(value.type));
 				Designate(value, op);
-				Emit(Push(modifier.position, op.tag));
-				Emit(Push(modifier.position, op.op));
+				PushString(op, value.type);
 				ReleaseOperand(op);
 				CallThisChecked(position,"ActiveCellsRuntime","AddPortStringProperty",4,FALSE);
 			ELSIF (modifier.expression.type.resolved IS SyntaxTree.IntegerType) THEN
@@ -7283,6 +7281,21 @@ TYPE
 			END;
 		END PushPort;
 
+		PROCEDURE PushString(op: Operand; actualType: SyntaxTree.Type);
+		VAR tmp: IntermediateCode.Operand;
+		BEGIN
+			actualType := actualType.resolved;
+			IF actualType IS SyntaxTree.StringType THEN
+				Emit(Push(position,IntermediateCode.Immediate(addressType,actualType(SyntaxTree.StringType).length)));
+			ELSIF actualType(SyntaxTree.ArrayType).form = SyntaxTree.Static THEN
+				Emit(Push(position,IntermediateCode.Immediate(addressType,actualType(SyntaxTree.ArrayType).staticLength)));
+			ELSE
+				tmp := op.tag;
+				IntermediateCode.MakeMemory(tmp,addressType);
+				Emit(Push(position,tmp));
+			END;
+			Emit(Push(position,op.op))
+		END PushString;
 
 		PROCEDURE VisitBuiltinCallDesignator(x: SyntaxTree.BuiltinCallDesignator);
 		VAR
@@ -7362,20 +7375,6 @@ TYPE
 				END;
 			END CallBodies;
 
-			PROCEDURE PushString(op: Operand; actualType: SyntaxTree.Type);
-			BEGIN
-				actualType := actualType.resolved;
-				IF actualType IS SyntaxTree.StringType THEN
-					Emit(Push(position,IntermediateCode.Immediate(addressType,actualType(SyntaxTree.StringType).length)));
-				ELSIF actualType(SyntaxTree.ArrayType).form = SyntaxTree.Static THEN
-					Emit(Push(position,IntermediateCode.Immediate(addressType,actualType(SyntaxTree.ArrayType).staticLength)));
-				ELSE
-					tmp := op.tag;
-					IntermediateCode.MakeMemory(tmp,addressType);
-					Emit(Push(position,tmp));
-				END;
-				Emit(Push(position,op.op))
-			END PushString;
 
 			PROCEDURE PushTD(type: SyntaxTree.Type);
 			VAR op: IntermediateCode.Operand;