Browse Source

Fixed the way the self pointer is pushed in function calls. This fixes a bug that broke channel instantiation in active cells.

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6756 8c9fc860-2736-0410-a75d-ab315db34111
skoster 9 years ago
parent
commit
b258bbbd8c
1 changed files with 7 additions and 4 deletions
  1. 7 4
      source/FoxIntermediateBackend.Mod

+ 7 - 4
source/FoxIntermediateBackend.Mod

@@ -10551,7 +10551,8 @@ TYPE
 		END StatementSequence;
 		END StatementSequence;
 
 
 		PROCEDURE PushSelfPointer;
 		PROCEDURE PushSelfPointer;
-		VAR scope: SyntaxTree.Scope;  op: Operand; moduleSection: IntermediateCode.Section; moduleOffset, parametersSize: LONGINT;
+		VAR scope: SyntaxTree.Scope;  op: Operand; moduleSection: IntermediateCode.Section; moduleOffset, parametersSize: LONGINT; procedure: SyntaxTree.Procedure;
+			procedureType: SyntaxTree.ProcedureType;
 		BEGIN
 		BEGIN
 			scope := currentScope;
 			scope := currentScope;
 			WHILE(scope.outerScope IS SyntaxTree.ProcedureScope) DO
 			WHILE(scope.outerScope IS SyntaxTree.ProcedureScope) DO
@@ -10572,9 +10573,11 @@ TYPE
 				END;
 				END;
 			ELSE
 			ELSE
 				GetBaseRegister(op.op,currentScope,scope);
 				GetBaseRegister(op.op,currentScope,scope);
-				parametersSize := ProcedureParametersSize(system,scope(SyntaxTree.ProcedureScope).ownerProcedure);
-				IntermediateCode.AddOffset(op.op,ToMemoryUnits(system,addressType.sizeInBits)+parametersSize);
-				IF backend.cooperative OR PreciseGCSupport THEN
+				procedure := scope(SyntaxTree.ProcedureScope).ownerProcedure;
+				procedureType := procedure.type(SyntaxTree.ProcedureType);
+				parametersSize := ProcedureParametersSize(system,procedure);
+				IntermediateCode.AddOffset(op.op,ToMemoryUnits(system,addressType.sizeInBits)*(procedureType.parametersOffset+1)+parametersSize);
+				IF backend.cooperative THEN
 					IntermediateCode.AddOffset(op.op,ToMemoryUnits(system,addressType.sizeInBits));
 					IntermediateCode.AddOffset(op.op,ToMemoryUnits(system,addressType.sizeInBits));
 				END;
 				END;
 				IntermediateCode.MakeMemory(op.op,addressType);
 				IntermediateCode.MakeMemory(op.op,addressType);