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

versions for both with and without typedef

parent 047ba252
#dummy script to test the on-the-fly compilation
java -jar ../../compiler/labComm.jar --java=gen --javapackage=gen simple.lc
javac -cp .:gen:../../lib/java/labcomm.jar gen/*.java
# compile static encoder and decoder
javac -cp .:gen:../../lib/java/labcomm.jar test/StaticEncoder.java
javac -cp .:gen:../../lib/java/labcomm.jar test/StaticDecoder.java
# compile dynamic part
javac -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test/DynamicPart.java
javac test/HandlerContext.java
# run static encoder
java -cp .:gen:../../lib/java//labcomm.jar test.StaticEncoder encoded_data
# run dynamic part
java -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test.DynamicPart simple_type.lc handlers_type.txt encoded_data dynamic_out
# run static decoder
java -cp .:gen:../../lib/java//labcomm.jar test.StaticDecoder dynamic_out
foo:handler(foo_t value) {
foo:handler(foo value) {
test.HandlerContext ctx = (test.HandlerContext)context;
System.out.println("foo handler from handlers2.txt");
System.out.println("using context "+ctx.str);
......
foo:handler(foo_t value) {
test.HandlerContext ctx = (test.HandlerContext)context;
System.out.println("foo handler from handlers_type.txt");
System.out.println("using context "+ctx.str);
ctx.x = value.x + 1000;
ctx.y = value.y + 1000;
ctx.z = value.z + 1000;
System.out.println(value.x);
System.out.println(value.y);
System.out.println(value.z);
for(int i=0; i<value.x; i++){
System.out.print("."+(value.x-i));
}
System.out.println();
}###
bar:handler(int value) {
System.out.println("bar:"+value);
test.HandlerContext ctx = (test.HandlerContext)context;
ctx.bar = value + 1000;
}###
typedef struct {
sample struct {
int x;
int y;
int z;
} foo_t;
sample foo_t foo;
} foo;
sample int bar;
typedef struct {
int x;
int y;
int z;
} foo_t;
sample foo_t foo;
sample int bar;
......@@ -302,9 +302,15 @@ public class DynamicPart {
*/
private void encodeTest(InRAMCompiler irc, HandlerContext ctxt, String tmpFile) {
try {
Class ft = irc.load(TYPE_NAME_FOO);
Class fc = irc.load(SAMPLE_NAME_FOO);
Class bc = irc.load(SAMPLE_NAME_BAR);
Class ft; // hack for both cases with and w/o typedef
try {
ft = irc.load(TYPE_NAME_FOO);
} catch (ClassNotFoundException e) {
System.out.println("** encodeTest: defaulting to sample==type");
ft = fc;
}
/* create sample class and instance objects */
Object fv = ft.newInstance();
......
package test;
import gen.foo_t;
import gen.foo;
import gen.bar;
......@@ -32,7 +31,7 @@ public class StaticDecoder implements foo.Handler, bar.Handler
}
public void handle_foo(foo_t d) throws java.io.IOException {
public void handle_foo(foo d) throws java.io.IOException {
System.out.println("Got foo, x="+d.x+", y="+d.y+", z="+d.z);
}
......
......@@ -4,7 +4,6 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import se.lth.control.labcomm.LabCommEncoderChannel;
import gen.foo_t;
import gen.foo;
import gen.bar;
......@@ -21,7 +20,7 @@ public class StaticEncoder {
}
public void doEncode() throws java.io.IOException {
foo_t f = new foo_t();
foo f = new foo();
f.x = 17;
f.y = 42;
f.z = 37;
......
#dummy script to test the on-the-fly compilation
javac -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test/TestLabcommGen.java
javac test/HandlerContext.java
java -cp .:../../compiler/labComm.jar:../../lib/java/labcomm.jar:../../lib/tools/beaver.jar:../../lib/tools/beaver-rt.jar:../../lib/tools/jastadd2.jar:../../lib/tools/JFlex.jar:../../lib/tools/proj.jar test.TestLabcommGen simple_type.lc handlers_type.txt encoded_data
Markdown is supported
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