break;
case FORM_RECORD:
- printf("%%%s", type->name);
+ if (type->name)
+ {
+ printf("%%%s", type->name);
+ }
+ else
+ {
+ printf("{ ");
+ for (Field* field = type->fields; field; field = field->next)
+ {
+ emit_type(field->type);
+ if (field->next)
+ {
+ printf(", ");
+ }
+ }
+ printf(" }");
+ }
break;
case FORM_PROC:
SsaNode* ssa_fieldref(Parser* p, SsaNode* record, char* fname)
{
+#if 1
(void)p, (void)record, (void)fname;
assert(!"record field references unimplemented");
return NULL;
+#else
+ if (record->mode == MODE_MEMORY && record->code == '[')
+ {
+ record = load(p, record);
+ }
+ index = load(p, index);
+ SsaNode* node = ssa_node('[', MODE_MEMORY);
+ node->type = array->type->base;
+ node->left = array;
+ node->right = index;
+ return node;
+#endif
}
SsaNode* ssa_index(Parser* p, SsaNode* array, SsaNode* index)
module Module
+type
+ FooRec = record
+ a : Int
+ b : record
+ c : Int
+ end
+ d : array 5 of Int
+ end
+
var
vBool* : Bool
vInt* : Int
vReal : Real
vIntArray : array 42 of Int
vIntArray2 : array 5 of array 5 of Int
-# vRec : record
-# a : Int
-# b : array 5 of Int
-# end
+ vRec1 : FooRec
+ vRec2 : record
+ a : Int
+ b : array 5 of Int
+ end
procedure TestReturnVoid()
begin
vIntArray2[0][1] = vIntArray2[1][1] + vIntArray2[2][1];
end
-#procedure TestRecordAccess()
-#begin
-#end
+procedure TestRecordAccess()
+begin
+# vRec2.a = vRec2.a + vRec2.a;
+end
-#import
-# Foo
-# Bar3 = Bar2
-#
-#const
-# A* = true
-# B* = 42
-# C* = 42.0
-# D = -B
-# E = -C
-# F = not A
-# G = B + 2 - 2 * 2
-# H = false or A
-#
-#type
-# TypeA* = Int
-# TypeB* = array 5*B of Int
-# TypeC* = array 5 of array 10 of Int
-# TypeD* = record
-# x,y : Int
-# label : array 10 of Int
-# dim : record
-# w,h : Int
-# end
-# end
-# TypeE* = record
-# i : Int
-# a : array 5 of Int
-# end
-# TypeF* = array 5 of TypeE
-#
-#var
-# a* : Bool
-# b* : Int
-# c : Int
-# d : Real
-# e : Real
-# f : array 5 of array 10 of Int
-# g : TypeD
-# h : array 5 of Int
-# i : TypeF
-# j : TypeA
-#
-##procedure Foo*(e : Int, z : Int, q1 : TypeD, q2 : array 5 of Int) : Int
-## const FOO = 2
-## type foo = Int
-## var
-## z1 : Int
-## q : array 5 of array 10 of Int
-##begin
-### e = q;
-## c = 1;
-## z1 = 2;
-## return z1;
-##end
-#
-##procedure Bar*(a : Int) : Int
-##begin
-## a = 42;
-## return a;
-##end
-##
-##procedure Baz*(a : Int)
-##begin
-## if (1 > 2) then
-## 42;
-## else
-## 24;
-## end
-##end
-#
+procedure TestNestedRecordAccess()
begin
-## # Unary ops
-## b = +b;
-## b = -b;
-##
-## # Function calls
-## c = Foo(1,2);
-## e[0] = 1;
-## Foo(1,2);
-## e[2][1] = 1 + e[2][1];
-## e[b] = 1;
-## e[1][2] = 1;
-## c = e[1][c];
-## c = f.dim.w;
-## f.dim.h = 0;
-## f.label[0] = 42;
-#
-## c = 4;
-## g[c] = 42;
-## e[0][9] = 42;
-#
-## c = Bar(42);
-## c = 42;
-## c = 24;
-#
-## Bar(Foo.testint);
-## Bar(Bar2.testint);
-## Bar(Bar3.testint);
+# vRec2.a.b = vRec2.a.b + vRec2.a.b;
end
+
+#begin
+#end