Commit f385f5d7 authored by Sven Gestegård Robertz's avatar Sven Gestegård Robertz
Browse files

Hacked java TypeDefParser to parse intentions

parent eccd4e90
......@@ -34,12 +34,12 @@ public class Decoder
theSecondInt.register(decoder, this);
intAndRef.register(decoder, this);
doavoid.registerSampleRef(decoder);
// this.tdp = TypeDefParser.registerTypeDefParser(decoder);
this.tdp = TypeDefParser.registerTypeDefParser(decoder);
// TypeDef.register(decoder, this);
// TypeBinding.register(decoder, this);
// tdp.addListener(this);
tdp.addListener(this);
try {
System.out.println("Running decoder.");
......@@ -67,8 +67,12 @@ public class Decoder
public void onTypeDef(TypeDefParser.ParsedTypeDef d) {
System.out.println("ontype_def: ");
System.out.print((d.isSampleDef()?"sample ":"typedef ")+d);
System.out.println(" "+d.getName()+";");
if(d != null) {
System.out.print((d.isSampleDef()?"sample ":"typedef ")+d);
System.out.println(" "+d.getName()+";");
} else {
System.out.println(" null???");
}
//for(byte b: d.getSignature()) {
// System.out.print(Integer.toHexString(b)+" ");
//}
......
......@@ -96,11 +96,12 @@ run:
@echo "************ running python encoder: *****************"
@PYTHONPATH=${LCDIR}/lib/python:${GENDIR} ./example_encoder.py encoded_data_p LabComm2014
@echo "************ running Java decoder: *****************"
@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
@echo "************ running C decoder: *****************"
@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
@echo "WARNING! python encoded data only decoded by python decoder, pending intention implementation"
# @echo "************ running Java decoder: *****************"
# @java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
#
# @echo "************ running C decoder: *****************"
# @LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
@echo "************ running python decoder (from wiki_example):"
PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
......@@ -144,18 +145,19 @@ runwcs: build ExampleEncoder.exe ExampleDecoder.exe
@echo "************ running python encoder: *****************"
@PYTHONPATH=${LCDIR}/lib/python:${GENDIR} ./example_encoder.py encoded_data_p LabComm2014
@echo "************ running Java decoder: *****************"
@java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
@echo "************ running C decoder: *****************"
@LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
@echo "WARNING! python encoded data only decoded by python decoder, pending intention implementation"
# @echo "************ running Java decoder: *****************"
# @java -cp .:${LCDIR}/lib/java/labcomm2014.jar:${GENDIR} Decoder encoded_data_p
#
# @echo "************ running C decoder: *****************"
# @LD_LIBRARY_PATH=${LCDIR}/lib/c/ ./example_decoder encoded_data_p
#
# @echo "************ running C# decoder: *****************"
# @mono ./ExampleDecoder.exe encoded_data_p
#
@echo "************ running python decoder (from wiki_example):"
PYTHONPATH=${LCDIR}/lib/python ../wiki_example/example_decoder.py encoded_data_p LabComm2014
@echo "************ running C# decoder: *****************"
@mono ./ExampleDecoder.exe encoded_data_p
@echo "************ running C# encoder: *****************"
@mono ./ExampleEncoder.exe encoded_data_cs
......
......@@ -76,7 +76,7 @@ public class TDDecoder
// }
public void onTypeDef(TypeDefParser.ParsedTypeDef d) {
if(d.isSampleDef()){
if(d != null && d.isSampleDef()){
System.out.println("onTypeDef (sample): ");
ASTbuilder v = new ASTbuilder();
Specification p = v.makeSpecification((TypeDefParser.ParsedSampleDef) d);
......
typedef struct {
int val;
(foo:bar) int val;
} coord;
typedef int anInt;
typedef void avoid;
sample avoid doavoid;
sample (function:trigger)(foo:bar) avoid doavoid;
sample struct {
int x;
sample (a:b) "a struct with an int and a ref" struct {
(c:d)(e:f) int x;
sample reference;
} intAndRef;
......
......@@ -76,6 +76,7 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
}
public void handle_TypeDef(TypeDef d) throws java.io.IOException {
System.out.println("handle_TypeDef: "+d.getIndex());
typeDefs.put(d.getIndex(), d);
}
......@@ -87,6 +88,7 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
typeBindings.put(d.getSampleIndex(), d.getTypeIndex());
td = getTypeDefForIndex(d.getSampleIndex());
}
System.out.println("handle_TypeBinding: "+d.getSampleIndex());
ParsedSampleDef result = parseSignature(td);
sampleDefs.add(result);
......@@ -619,8 +621,14 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
}
private ParsedField parseParsedField(ParserState in) throws IOException {
String intentions = in.decodeString();
if(intentions.length()>0) {
System.out.println("parseParsedField intentions ("+intentions);
} else {
System.out.println("no intentions");
}
String name = in.decodeString();
return new ParsedField(name, parseType(in));
return new ParsedField(name, parseType(in, false));
}
private ParsedType lookupType(int tag, ParserState in) {
......@@ -639,20 +647,28 @@ public class TypeDefParser implements TypeDef.Handler, TypeBinding.Handler {
}
private ParsedSampleDef parseSampleTypeDef(ParserState in) throws IOException {
ParsedTypeDef td = parseTypeDef(in);
ParsedTypeDef td = parseTypeDef(in, true);
return new ParsedSampleDef(td);
}
private ParsedTypeDef parseTypeDef(ParserState in) throws IOException {
return parseTypeDef(in, false);
}
private ParsedTypeDef parseTypeDef(ParserState in, boolean parseIntentions) throws IOException {
ParsedTypeDef result = in.newTypeDef();
result.setType(parseType(in));
result.setType(parseType(in, parseIntentions));
return result;
}
private ParsedType parseType(ParserState in) throws IOException {
String intentions = in.decodeString();
if(intentions.length()>0) {
System.out.println("parseType intentions ("+intentions);
private ParsedType parseType(ParserState in, boolean parseIntentions) throws IOException {
if(parseIntentions) {
String intentions = in.decodeString();
if(intentions.length()>0) {
System.out.println("parseType intentions ("+intentions);
} else {
System.out.println("no intentions");
}
} else {
System.out.println("no intentions");
System.out.println("not parsing intentions");
}
int tag = in.decodePacked32();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment