Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sven Gestegård Robertz
LabComm
Commits
8f7951aa
Commit
8f7951aa
authored
Dec 06, 2013
by
Sven Gestegård Robertz
Browse files
versions for both with and without typedef
parent
047ba252
Changes
9
Hide whitespace changes
Inline
Side-by-side
examples/dynamic/dynamic_type.sh
0 → 100644
View file @
8f7951aa
#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
examples/dynamic/handlers2.txt
View file @
8f7951aa
foo:handler(foo
_t
value) {
foo:handler(foo value) {
test.HandlerContext ctx = (test.HandlerContext)context;
test.HandlerContext ctx = (test.HandlerContext)context;
System.out.println("foo handler from handlers2.txt");
System.out.println("foo handler from handlers2.txt");
System.out.println("using context "+ctx.str);
System.out.println("using context "+ctx.str);
...
...
examples/dynamic/handlers_type.txt
0 → 100644
View file @
8f7951aa
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;
}###
examples/dynamic/simple.lc
View file @
8f7951aa
typedef
struct {
sample
struct {
int x;
int x;
int y;
int y;
int z;
int z;
} foo_t;
} foo;
sample foo_t foo;
sample int bar;
sample int bar;
examples/dynamic/simple_type.lc
0 → 100644
View file @
8f7951aa
typedef struct {
int x;
int y;
int z;
} foo_t;
sample foo_t foo;
sample int bar;
examples/dynamic/test/DynamicPart.java
View file @
8f7951aa
...
@@ -302,9 +302,15 @@ public class DynamicPart {
...
@@ -302,9 +302,15 @@ public class DynamicPart {
*/
*/
private
void
encodeTest
(
InRAMCompiler
irc
,
HandlerContext
ctxt
,
String
tmpFile
)
{
private
void
encodeTest
(
InRAMCompiler
irc
,
HandlerContext
ctxt
,
String
tmpFile
)
{
try
{
try
{
Class
ft
=
irc
.
load
(
TYPE_NAME_FOO
);
Class
fc
=
irc
.
load
(
SAMPLE_NAME_FOO
);
Class
fc
=
irc
.
load
(
SAMPLE_NAME_FOO
);
Class
bc
=
irc
.
load
(
SAMPLE_NAME_BAR
);
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 */
/* create sample class and instance objects */
Object
fv
=
ft
.
newInstance
();
Object
fv
=
ft
.
newInstance
();
...
...
examples/dynamic/test/StaticDecoder.java
View file @
8f7951aa
package
test
;
package
test
;
import
gen.foo_t
;
import
gen.foo
;
import
gen.foo
;
import
gen.bar
;
import
gen.bar
;
...
@@ -32,7 +31,7 @@ public class StaticDecoder implements foo.Handler, bar.Handler
...
@@ -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
);
System
.
out
.
println
(
"Got foo, x="
+
d
.
x
+
", y="
+
d
.
y
+
", z="
+
d
.
z
);
}
}
...
...
examples/dynamic/test/StaticEncoder.java
View file @
8f7951aa
...
@@ -4,7 +4,6 @@ import java.io.FileOutputStream;
...
@@ -4,7 +4,6 @@ import java.io.FileOutputStream;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
se.lth.control.labcomm.LabCommEncoderChannel
;
import
se.lth.control.labcomm.LabCommEncoderChannel
;
import
gen.foo_t
;
import
gen.foo
;
import
gen.foo
;
import
gen.bar
;
import
gen.bar
;
...
@@ -21,7 +20,7 @@ public class StaticEncoder {
...
@@ -21,7 +20,7 @@ public class StaticEncoder {
}
}
public
void
doEncode
()
throws
java
.
io
.
IOException
{
public
void
doEncode
()
throws
java
.
io
.
IOException
{
foo
_t
f
=
new
foo
_t
();
foo
f
=
new
foo
();
f
.
x
=
17
;
f
.
x
=
17
;
f
.
y
=
42
;
f
.
y
=
42
;
f
.
z
=
37
;
f
.
z
=
37
;
...
...
examples/dynamic/test_type.sh
0 → 100644
View file @
8f7951aa
#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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment