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
6c90d315
Commit
6c90d315
authored
Feb 11, 2015
by
Sven Gestegård Robertz
Browse files
commented out unused SampleRefType in compiler, and added ref tests in examples/user_types
parent
7d7fd2be
Changes
12
Hide whitespace changes
Inline
Side-by-side
compiler/2014/FlatSignature.jrag
View file @
6c90d315
...
...
@@ -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();
...
...
compiler/2014/LabComm.ast
View file @
6c90d315
...
...
@@ -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*;
...
...
compiler/2014/PrettyPrint.jrag
View file @
6c90d315
...
...
@@ -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());
...
...
compiler/2014/Signature.jrag
View file @
6c90d315
...
...
@@ -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);
}
...
...
examples/user_types/Decoder.java
View file @
6c90d315
...
...
@@ -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
));
...
...
examples/user_types/Encoder.java
View file @
6c90d315
...
...
@@ -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
);
...
...
examples/user_types/ExampleDecoder.cs
View file @
6c90d315
...
...
@@ -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
));
...
...
examples/user_types/TDDecoder.java
View file @
6c90d315
...
...
@@ -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
));
...
...
examples/user_types/example_decoder.c
View file @
6c90d315
...
...
@@ -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
);
...
...
examples/user_types/test.lc
View file @
6c90d315
...
...
@@ -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;
...
...
lib/java/se/lth/control/labcomm/TypeDefParser.java
View file @
6c90d315
...
...
@@ -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
);
}
...
...
lib/java/se/lth/control/labcomm/TypeDefVisitor.java
View file @
6c90d315
...
...
@@ -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
())
{
...
...
Write
Preview
Markdown
is supported
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