Pārlūkot izejas kodu

patched problem with returning string as static array of char
added test

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8442 8c9fc860-2736-0410-a75d-ab315db34111

felixf 6 gadi atpakaļ
vecāks
revīzija
1aab642d53
2 mainītis faili ar 12 papildinājumiem un 1 dzēšanām
  1. 2 1
      source/FoxIntermediateBackend.Mod
  2. 10 0
      source/Oberon.Execution.Test

+ 2 - 1
source/FoxIntermediateBackend.Mod

@@ -11805,10 +11805,11 @@ TYPE
 						Emit(Return(position,res.op));
 						Emit(Return(position,res.op));
 						ReleaseOperand(res);
 						ReleaseOperand(res);
 					END;
 					END;
-				ELSIF (type IS SyntaxTree.RecordType) OR (type IS SyntaxTree.ArrayType) OR (type IS SyntaxTree.RangeType) OR (type IS SyntaxTree.ComplexType) OR type.IsPointer()
+				ELSIF (type IS SyntaxTree.RecordType) OR (type IS SyntaxTree.ArrayType) OR (type IS SyntaxTree.RangeType) OR (type IS SyntaxTree.ComplexType) OR (type IS SyntaxTree.StringType) OR type.IsPointer()
 				THEN
 				THEN
 					(* return using structured return parameter *)
 					(* return using structured return parameter *)
 					ASSERT((type IS SyntaxTree.RecordType) OR (type IS SyntaxTree.RangeType) OR (type IS SyntaxTree.ComplexType) OR (type IS SyntaxTree.ArrayType) & (type(SyntaxTree.ArrayType).form = SyntaxTree.Static)
 					ASSERT((type IS SyntaxTree.RecordType) OR (type IS SyntaxTree.RangeType) OR (type IS SyntaxTree.ComplexType) OR (type IS SyntaxTree.ArrayType) & (type(SyntaxTree.ArrayType).form = SyntaxTree.Static)
+						OR (type IS SyntaxTree.StringType)
 						OR SemanticChecker.IsPointerType(type));
 						OR SemanticChecker.IsPointerType(type));
 					(* parameter := currentScope(SyntaxTree.ProcedureScope).FindParameter(Global.ReturnParameterName); *)
 					(* parameter := currentScope(SyntaxTree.ProcedureScope).FindParameter(Global.ReturnParameterName); *)
 					parameter :=procedureType.returnParameter;
 					parameter :=procedureType.returnParameter;

+ 10 - 0
source/Oberon.Execution.Test

@@ -7872,3 +7872,13 @@ positive: index operators on objects
 		Test;
 		Test;
 	END Test.
 	END Test.
 
 
+positive: return string as static array of char
+	MODULE Test;
+	PROCEDURE Test(): ARRAY 32 OF CHAR;
+	BEGIN
+		RETURN "Hello";
+	END Test;
+	BEGIN
+		ASSERT(Test() = "Hello"); 
+	END Test.
+