diff --git a/compiler/2014/FlatSignature.jrag b/compiler/2014/FlatSignature.jrag index 2a9ca4dd9c48fadfabceecebf215e808d10e0597..b96c119ce386f0a0d2b7e9e2c1edb001050e5f27 100644 --- a/compiler/2014/FlatSignature.jrag +++ b/compiler/2014/FlatSignature.jrag @@ -21,9 +21,9 @@ aspect FlatSignature { getType().flatSignature(list); } - public void SampleRefType.flatSignature(SignatureList list) { - list.addInt(LABCOMM_SAMPLE_REF, "sample"); - } +// public void SampleRefType.flatSignature(SignatureList list) { +// list.addInt(LABCOMM_SAMPLE_REF, "sample"); +// } public void VoidType.flatSignature(SignatureList list) { list.addInt(LABCOMM_STRUCT, "void"); @@ -96,9 +96,9 @@ aspect FlatSignature { return getType().signatureComment() + " '" + getName() +"'"; } - public String SampleRefType.signatureComment() { - return "sample"; - } +// public String SampleRefType.signatureComment() { +// return "sample"; +// } public String PrimType.signatureComment() { return getName(); diff --git a/compiler/2014/LabComm.ast b/compiler/2014/LabComm.ast index bbadfad29470c33ce030c2016173ef7794986cf7..d3d5e592fc95cb38bf9fd3844d8b3ad2d3cb9081 100644 --- a/compiler/2014/LabComm.ast +++ b/compiler/2014/LabComm.ast @@ -21,7 +21,7 @@ Field ::= Type <Name:String>; abstract Type; VoidType : Type; -SampleRefType : Type; +//SampleRefType : Type; PrimType : Type ::= <Name:String> <Token:int>; UserType : Type ::= <Name:String>; StructType : Type ::= Field*; diff --git a/compiler/2014/PrettyPrint.jrag b/compiler/2014/PrettyPrint.jrag index a7fa877109c55e7ad17f64ab1385f8d9638ad662..3808c952309d375c828023c199472d2e6b9e43de 100644 --- a/compiler/2014/PrettyPrint.jrag +++ b/compiler/2014/PrettyPrint.jrag @@ -68,9 +68,9 @@ aspect PrettyPrint { out.print("void"); } - public void SampleRefType.ppPrefix(PrintStream out) { - out.print("sample"); - } +// public void SampleRefType.ppPrefix(PrintStream out) { +// out.print("sample"); +// } public void PrimType.ppPrefix(PrintStream out) { out.print(getName()); diff --git a/compiler/2014/Signature.jrag b/compiler/2014/Signature.jrag index fb232b9e01528dc43e023bf0e50aca4ae4b832eb..b32e53580aa900e31357333904aeeb115180bcf0 100644 --- a/compiler/2014/Signature.jrag +++ b/compiler/2014/Signature.jrag @@ -174,9 +174,9 @@ aspect Signature { list.addInt(0, null); } - public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) { - list.addInt(LABCOMM_SAMPLE_REF, "sample"); - } +// public void SampleRefType.genSigLineForDecl(SignatureList list, boolean decl) { +// list.addInt(LABCOMM_SAMPLE_REF, "sample"); +// } public void PrimType.genSigLineForDecl(SignatureList list, boolean decl) { list.addInt(getToken(), null); } diff --git a/examples/user_types/Decoder.java b/examples/user_types/Decoder.java index 9d15143946894d37afc12bf8124913846d44bb2a..29069b1cfb9d456f65b1c0f598f67a17a77e695c 100644 --- a/examples/user_types/Decoder.java +++ b/examples/user_types/Decoder.java @@ -16,7 +16,8 @@ public class Decoder twoInts.Handler, theFirstInt.Handler, theSecondInt.Handler, - doavoid.Handler + doavoid.Handler, + intAndRef.Handler { private DecoderChannel decoder; @@ -31,6 +32,8 @@ public class Decoder twoLines.register(decoder, this); theFirstInt.register(decoder, this); theSecondInt.register(decoder, this); + intAndRef.register(decoder, this); + doavoid.registerSampleRef(decoder); this.tdp = TypeDefParser.registerTypeDefParser(decoder); // TypeDef.register(decoder, this); // TypeBinding.register(decoder, this); @@ -92,6 +95,10 @@ public class Decoder System.out.println("Got theSecondInt: "+d); } + public void handle_intAndRef(intAndRef d) throws java.io.IOException { + System.out.println("Got intAndRef: "+d.x+", "+d.reference); + } + public void handle_twoLines(twoLines d) throws java.io.IOException { System.out.print("Got twoLines: "); System.out.println("Line l1: "+genLine(d.l1)); diff --git a/examples/user_types/Encoder.java b/examples/user_types/Encoder.java index ac8add67670eac6560fc282c8177b87e2c5941a6..d5687a2ce1d86b9643cddc58921373618b80b7bd 100644 --- a/examples/user_types/Encoder.java +++ b/examples/user_types/Encoder.java @@ -21,16 +21,25 @@ public class Encoder twoLines.register(encoder); theFirstInt.register(encoder); theSecondInt.register(encoder); + intAndRef.register(encoder); + doavoid.registerSampleRef(encoder); } public void doEncode() throws java.io.IOException { + System.out.println("Encoding doavoid"); + doavoid.encode(encoder); + + intAndRef iar = new intAndRef(); + iar.x = 17; + iar.reference = doavoid.class; + + System.out.println("Encoding intAndRef"); + intAndRef.encode(encoder, iar); + twoInts ti = new twoInts(); ti.a = 12; ti.b = 21; - System.out.println("Encoding doavoid"); - doavoid.encode(encoder); - System.out.println("Encoding twoInts"); twoInts.encode(encoder, ti); diff --git a/examples/user_types/ExampleDecoder.cs b/examples/user_types/ExampleDecoder.cs index ec0f096ae1c7e03a47eea6115940e8fac5826426..95b1fca4e2bf1d0adc4bad67823137b03980163c 100644 --- a/examples/user_types/ExampleDecoder.cs +++ b/examples/user_types/ExampleDecoder.cs @@ -11,7 +11,8 @@ namespace user_types twoInts.Handler, theFirstInt.Handler, theSecondInt.Handler, - doavoid.Handler + doavoid.Handler, + intAndRef.Handler { DecoderChannel dec; @@ -23,6 +24,8 @@ namespace user_types theFirstInt.register(dec, this); theSecondInt.register(dec, this); doavoid.register(dec, this); + intAndRef.register(dec, this); + doavoid.registerSampleRef(dec); try { Console.WriteLine("Running decoder."); @@ -71,6 +74,11 @@ namespace user_types Console.WriteLine("Got a void."); } + void intAndRef.Handler.handle(intAndRef d) + { + Console.WriteLine("Got intAndRef: "+d.x+" : "+d.reference); + } + static void Main(string[] args) { new Decoder(new FileStream(args[0], FileMode.Open)); diff --git a/examples/user_types/TDDecoder.java b/examples/user_types/TDDecoder.java index a68984292b9931266fb17ee2355cdcbe82536250..be6e7eb4a614d0be092f7fa14e0b9a93cb53e8b2 100644 --- a/examples/user_types/TDDecoder.java +++ b/examples/user_types/TDDecoder.java @@ -26,7 +26,8 @@ public class TDDecoder twoInts.Handler, theFirstInt.Handler, theSecondInt.Handler, - doavoid.Handler + doavoid.Handler, + intAndRef.Handler { private DecoderChannel decoder; @@ -41,6 +42,8 @@ public class TDDecoder theFirstInt.register(decoder, this); theSecondInt.register(decoder, this); doavoid.register(decoder, this); + intAndRef.register(decoder, this); + doavoid.registerSampleRef(decoder); this.tdp = TypeDefParser.registerTypeDefParser(decoder); // TypeDef.register(decoder, this); // TypeBinding.register(decoder, this); @@ -84,7 +87,7 @@ public class TDDecoder //FileOutputStream f = new FileOutputStream("/tmp/foopp"+d.getName()+".txt"); //PrintStream out = new PrintStream(f); p.pp(System.out); - p.C_genC(System.out, new Vector(), "lcname", "prefix", 2014); + //p.C_genC(System.out, new Vector(), "lcname", "prefix", 2014); //p.J_gen(out, "testpackage", 2014); //out.close(); } catch (Throwable e) { @@ -125,6 +128,10 @@ public class TDDecoder System.out.println("Got a void."); } + public void handle_intAndRef(intAndRef d) throws java.io.IOException { + System.out.println("Got intAndRef: "+d.x+", "+d.reference); + } + public void handle_twoLines(twoLines d) throws java.io.IOException { System.out.print("Got twoLines: "); System.out.println("Line l1: "+genLine(d.l1)); diff --git a/examples/user_types/example_decoder.c b/examples/user_types/example_decoder.c index 27281587c6de88019e758555606ae099794db1c3..b727f8a47d85007db2bd3c05141c9d5da150ad5a 100644 --- a/examples/user_types/example_decoder.c +++ b/examples/user_types/example_decoder.c @@ -12,6 +12,10 @@ static void handle_test_doavoid(test_doavoid *v,void *context) { printf("Got a void.\n"); } +static void handle_test_intAndRef(test_intAndRef *v,void *context) { + printf("Got intAndRef. (%d : %s) \n", v->x, v->reference->name); +} + static void handle_test_twoInts(test_twoInts *v,void *context) { printf("Got twoInts. (%d,%d) \n", v->a, v->b); } @@ -58,6 +62,9 @@ int main(int argc, char *argv[]) { } labcomm_decoder_register_test_doavoid(decoder, handle_test_doavoid, context); + labcomm_decoder_register_test_intAndRef(decoder, handle_test_intAndRef, context); + labcomm_decoder_sample_ref_register(decoder,labcomm_signature_test_doavoid ); + labcomm_decoder_register_test_twoInts(decoder, handle_test_twoInts, context); labcomm_decoder_register_test_theFirstInt(decoder, handle_test_theFirstInt, context); labcomm_decoder_register_test_theSecondInt(decoder, handle_test_theSecondInt, context); diff --git a/examples/user_types/test.lc b/examples/user_types/test.lc index f882abb7874413ef12d9dcadb7493895cf86f8d1..75497b4df01e761d47efba7dd95cc7bb1611fcf9 100644 --- a/examples/user_types/test.lc +++ b/examples/user_types/test.lc @@ -7,6 +7,11 @@ typedef int anInt; typedef void avoid; sample avoid doavoid; +sample struct { + int x; + sample reference; +} intAndRef; + typedef struct { coord x; coord y; diff --git a/lib/java/se/lth/control/labcomm/TypeDefParser.java b/lib/java/se/lth/control/labcomm/TypeDefParser.java index 90c7f1dca3585ecc9ee00ac326095d7662d83e62..5a12cf3e9195cbaad2b87a1d244d1455129cec62 100644 --- a/lib/java/se/lth/control/labcomm/TypeDefParser.java +++ b/lib/java/se/lth/control/labcomm/TypeDefParser.java @@ -181,7 +181,7 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { void visit(SampleSymbol s); void visit(NameSymbol s); void visit(PrimitiveType t); - void visit(SampleRefType t); + //void visit(SampleRefType t); void visit(ParsedStructType t); void visit(ParsedField t); void visit(ArrayType t); @@ -227,14 +227,14 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { public abstract class ParsedType extends ParsedSymbol{ } - public class SampleRefType extends ParsedType { - public void accept(ParsedSymbolVisitor v) { - v.visit(this); - } - - public String toString() { - return "sample";} - } +// public class SampleRefType extends ParsedType { +// public void accept(ParsedSymbolVisitor v) { +// v.visit(this); +// } +// +// public String toString() { +// return "sample";} +// } public class PrimitiveType extends ParsedType { private final String name; @@ -274,6 +274,9 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { case Constant.STRING: this.name = "string"; break; + case Constant.SAMPLE: + this.name = "sample"; + break; default: this.name = "??? unknown tag 0x"+Integer.toHexString(tag); } @@ -643,8 +646,8 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler { TypeDef td = typeDefs.get(tag); result = new ParsedUserType(td.getName()); in.pushType(tag); - } else if(tag == Constant.SAMPLE) { - result = new SampleRefType(); +// } else if(tag == Constant.SAMPLE) { +// result = new SampleRefType(); } else { result = new PrimitiveType(tag); } diff --git a/lib/java/se/lth/control/labcomm/TypeDefVisitor.java b/lib/java/se/lth/control/labcomm/TypeDefVisitor.java index 63733e84494c0e678b1d803912b35b9c0ed54468..96a09919e242b71448d50c0e95ff708e7241fb2c 100644 --- a/lib/java/se/lth/control/labcomm/TypeDefVisitor.java +++ b/lib/java/se/lth/control/labcomm/TypeDefVisitor.java @@ -23,7 +23,7 @@ import se.lth.control.labcomm2014.compiler.TypeDecl; import se.lth.control.labcomm2014.compiler.SampleDecl; import se.lth.control.labcomm2014.compiler.Type; import se.lth.control.labcomm2014.compiler.VoidType; -import se.lth.control.labcomm2014.compiler.SampleRefType; +//import se.lth.control.labcomm2014.compiler.SampleRefType; import se.lth.control.labcomm2014.compiler.PrimType; import se.lth.control.labcomm2014.compiler.UserType; import se.lth.control.labcomm2014.compiler.StructType; @@ -69,9 +69,9 @@ public class TypeDefVisitor implements TypeDefParser.ParsedSymbolVisitor { typeStack.push(new PrimType(t.getName(), t.getTag())); } - public void visit(TypeDefParser.SampleRefType t){ - typeStack.push(new SampleRefType()); - } +// public void visit(TypeDefParser.SampleRefType t){ +// typeStack.push(new SampleRefType()); +// } public void visit(TypeDefParser.ParsedStructType t){ if(t.isVoid()) {