diff --git a/compiler/CS_CodeGen.jrag b/compiler/CS_CodeGen.jrag index 2b45d0d42a32ae7131639be3ff70ab4c7d7b53c6..23bda607e5673003037ac2cc08c2e52c34ba386d 100644 --- a/compiler/CS_CodeGen.jrag +++ b/compiler/CS_CodeGen.jrag @@ -429,11 +429,11 @@ aspect CS_Class { } public void ArrayType.CS_emitEncoder(CS_env env, String name) { + env.print_block_begin(); int baseDepth = env.getDepth(); for (int i = 0 ; i < getNumExp() ; i++) { String limit = getExp(i).CS_emitEncoder(env, name + ".GetLength(" + i + ")"); - env.print_block_begin(); env.println("int i_" + (baseDepth + i) + "_max = " + limit + ";"); } String index = null; @@ -448,8 +448,8 @@ aspect CS_Class { getType().CS_emitEncoder(env, name + "[" + index + "]"); for (int i = 0 ; i < getNumExp() ; i++) { env.print_for_end(); - env.print_block_end(); } + env.print_block_end(); } public String Exp.CS_emitEncoder(CS_env env, String name) { @@ -539,7 +539,7 @@ aspect CS_Class { } env.print("i_" + (baseDepth + i) + "_max"); } - env.println("]"); + env.print("]"); getType().CS_emitTypeSuffix(env); env.println(";"); @@ -592,22 +592,6 @@ aspect CS_Class { } } - public void Type.CS_emitNew(CS_env env, String size) { - throw new Error(this.getClass().getName() + - ".CS_emitNew(CS_env env, String size)" + - " not declared"); - } - - public void ArrayType.CS_emitNew(CS_env env, String size, int depth) { - env.print("new "); - getType().CS_emitTypePrefix(env); - env.print("[" + size + "]"); - getType().CS_emitTypeSuffix(env); - for (int i = 1 ; i < depth ; i++) { - env.print("[]"); - } - } - public void Type.CS_emitTypePrefix(CS_env env) { throw new Error(this.getClass().getName() + ".CS_emitTypePrefix(CS_env env)" + @@ -647,12 +631,12 @@ aspect CS_Class { } public void ArrayType.CS_emitTypeSuffix(CS_env env){ - getType().CS_emitTypeSuffix(env); env.print("["); for (int i = 1 ; i < getNumExp() ; i++) { env.print(","); } env.print("]"); + getType().CS_emitTypeSuffix(env); } public boolean Type.CS_needInstance() { @@ -703,7 +687,7 @@ aspect CS_Class { public void StructType.CS_emitInstance(CS_env env) { if (CS_Depth() > 0) { - env.println("public static class " + CS_structName() + " {"); + env.println("public class " + CS_structName() + " {"); env.indent(); } for (int i = 0 ; i < getNumField() ; i++) { @@ -751,12 +735,13 @@ aspect CS_Class { } public void ArrayType.CS_emitType(CS_env env){ - getType().CS_emitType(env); + getType().CS_emitTypePrefix(env); env.print("["); for (int i = 1 ; i < getNumExp() ; i++) { env.print(","); } env.print("]"); + getType().CS_emitTypeSuffix(env); } public void StructType.CS_emitType(CS_env env){ diff --git a/test/Makefile b/test/Makefile index 4133a659abf9a2242086707d4cbfbd660638ffcf..3ada01961e7442ca7ed518db79d9e1e3220db34d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,4 +1,4 @@ -TESTS=basic simple +TESTS=basic simple nested LABCOMM_JAR=../compiler/labComm.jar LABCOMM=java -jar $(LABCOMM_JAR) diff --git a/test/nested.lc b/test/nested.lc index ba62c9d0846aacc0d3abcb3d36a469ac8e0cbb94..26f0ac82d09b9fdd851454f0079b4913778be6da 100644 --- a/test/nested.lc +++ b/test/nested.lc @@ -1,6 +1,8 @@ -typedef int int_array_ss[1][_, 3, _][5]; -sample struct { int aa; boolean bb; int_array_ss ias; } struct_array_ss[1][_][_]; - +sample int s_array_array_array[1][1, 1][1, 1, 1]; +sample struct { + int b[1][1, 1]; + int c[1][_, 1, _][_,_]; +} struct_array_ss[1]; typedef int int_t; typedef int int_array_t[1][2][3,4]; typedef struct { int a; } struct_t; @@ -18,3 +20,4 @@ sample int_array_t int_array_t_s; sample struct_t struct_t_s; sample struct_array_t struct_array_t_s; sample struct_struct_t struct_struct_t_s; + diff --git a/test/test_encoder_decoder.py b/test/test_encoder_decoder.py index 9b9aa9b29e15d4ec15ab2a1123d8cc297f0df91e..96aaec8c8596c65e56492be3b4f9cf605f788636 100755 --- a/test/test_encoder_decoder.py +++ b/test/test_encoder_decoder.py @@ -142,7 +142,7 @@ def get_signatures(path): with fp as fp: m = imp.load_module('signatures', fp, pathname, description) pass - return m.signatures + return m.sample class Test: @@ -250,46 +250,4 @@ if __name__ == "__main__": for lc in args.lc: run(lc, args) pass - exit(0) - - - print os.getcwd(), sys.argv - if not os.path.exists("gen"): - os.makedirs("gen") - if len(sys.argv) > 1: - files = [s[0:-3] for s in sys.argv[1:] if s.endswith('.lc')] - else: - files = [s[0:-3] for s in os.listdir(".") if s.endswith('.lc')] - - for f in files: - cscode.test_program("gen/csharp/test_%s.cs" % f, - "gen/%s.typeinfo" % f) - - - sys.path.insert(0, "../lib/python") - import labcomm; - sys.path.insert(0, "gen/python") - for f in files: - print f - h = hexwriter("gen/%s.vec" % f) - encoder = labcomm.Encoder(h) - signatures = [] - i = __import__(f) - for k in dir(i): - v = getattr(i, k) - try: - s = v.signature - except: - s = None - if s: - signatures.append(s) - encoder.add_decl(s) - for s in signatures: - for e in generate(s): - encoder.encode(e[1], s) - - h.flush() - - ccode.gen(f, signatures) - - + pass