diff cbackend.rhope @ 91:bcdc326b3d6e

Added basic support for list literals in compiler. Updated todo list.
author Mike Pavone <pavone@retrodev.com>
date Sat, 31 Jul 2010 17:17:23 -0400
parents f69987c58fa8
children e73a93fb5de1
line wrap: on
line diff
--- a/cbackend.rhope	Sat Jul 31 15:08:15 2010 -0400
+++ b/cbackend.rhope	Sat Jul 31 17:17:23 2010 -0400
@@ -1252,7 +1252,7 @@
 _Set Consts C Program[text,value,name,type reg:out]
 {
 	valtype <- Type Of[value]
-	[("String","Worker Literal")]Find[valtype]
+	[("String","Worker Literal","List")]Find[valtype]
 	{
 		out <- text
 	}{
@@ -1261,19 +1261,37 @@
 	}
 }
 
+_Set List Els[text,el,index,type reg:out]
+{
+	out <- [[text]Append[
+		[["\tinout[1] = "
+		]Append[Const Construct C[index,type reg]]
+		]Append[
+			[[";\n\tinout[2] = "
+			]Append[Const Construct C[el, type reg]]
+			]Append[";\n"]
+		]]]Append["\trhope(FUNC_Set, inout, 3, 3);\n"]
+}
+
 _Set Late Consts C[text,value,name,type reg:out]
 {
 	valtype <- Type Of[value]
-	[("String","Worker Literal")]Find[valtype]
+	[("String","Worker Literal","List")]Find[valtype]
 	{
-		Const Construct C[value,type reg]
-		{ init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
+		If[[valtype]=["List"]]
+		{
+			out <- [Fold[["_Set List Els"]Set Input[3, type reg], "\trhope(FUNC_List, inout, 0, 1);\n", value]
+				]Append[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = inout[0];\n"]]
+		}{
+			Const Construct C[value,type reg]
+			{ init <- [text]Append[ [[[["\t_const_"]Append[Escape Rhope Name[name]]]Append[" = "]]Append[~]]Append[";\n"] ] }
 		
-		If[[valtype]=["Worker Literal"]]
-		{
-			out <- Fold[[["_Set Worker Params C"]Set Input[3, type reg]]Set Input[4, Escape Rhope Name[name]], init, [value]Args >>]
-		}{
-			out <- Val[init]
+			If[[valtype]=["Worker Literal"]]
+			{
+				out <- Fold[[["_Set Worker Params C"]Set Input[3, type reg]]Set Input[4, Escape Rhope Name[name]], init, [value]Args >>]
+			}{
+				out <- Val[init]
+			}
 		}
 	}{
 		out <- text
@@ -1442,7 +1460,7 @@
 	DispatchVar
 	FuncDef(Build)
 	FuncDef(BlueprintSP_Of)
-	FuncDef(ID)
+	FuncDef(ID)
 	FuncDef(BlueprintSP_FromSP_ID)\n"]
 		]Append[Fold["Local Pointers", "", [program]Functions >>]]
 		]Append["
@@ -1533,7 +1551,7 @@
 	blueprint * bp;
 	int numret;
 	int idx;
-	object * inout[2];
+	object * inout[3];
 	register_builtin_types();\n\n"]
 		]Append[ [[program]Type Registry >>]Type Inits[[program]Method Registry >>, [program]Field Registry >>] ]
 		]Append[Fold[["_Set Consts C Program"]Set Input[3, [program]Type Registry >>], "", constants]]