Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LabComm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Gestegård Robertz
LabComm
Commits
031d8eff
Commit
031d8eff
authored
May 14, 2013
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Corrected C# code generation to correctly handle arrays of arrays.
parent
4cc58e6c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
compiler/CS_CodeGen.jrag
+7
-22
7 additions, 22 deletions
compiler/CS_CodeGen.jrag
test/Makefile
+1
-1
1 addition, 1 deletion
test/Makefile
test/nested.lc
+6
-3
6 additions, 3 deletions
test/nested.lc
test/test_encoder_decoder.py
+2
-44
2 additions, 44 deletions
test/test_encoder_decoder.py
with
16 additions
and
70 deletions
compiler/CS_CodeGen.jrag
+
7
−
22
View file @
031d8eff
...
...
@@ -429,11 +429,11 @@ aspect CS_Class {
}
public void ArrayType.CS_emitEncoder(CS_env env, String name) {
env.print_block_begin();
int baseDepth = env.getDepth();
for (int i = 0 ; i < getNumExp() ; i++) {
String limit = getExp(i).CS_emitEncoder(env,
name + ".GetLength(" + i + ")");
env.print_block_begin();
env.println("int i_" + (baseDepth + i) + "_max = " + limit + ";");
}
String index = null;
...
...
@@ -448,8 +448,8 @@ aspect CS_Class {
getType().CS_emitEncoder(env, name + "[" + index + "]");
for (int i = 0 ; i < getNumExp() ; i++) {
env.print_for_end();
env.print_block_end();
}
env.print_block_end();
}
public String Exp.CS_emitEncoder(CS_env env, String name) {
...
...
@@ -539,7 +539,7 @@ aspect CS_Class {
}
env.print("i_" + (baseDepth + i) + "_max");
}
env.print
ln
("]");
env.print("]");
getType().CS_emitTypeSuffix(env);
env.println(";");
...
...
@@ -592,22 +592,6 @@ aspect CS_Class {
}
}
public void Type.CS_emitNew(CS_env env, String size) {
throw new Error(this.getClass().getName() +
".CS_emitNew(CS_env env, String size)" +
" not declared");
}
public void ArrayType.CS_emitNew(CS_env env, String size, int depth) {
env.print("new ");
getType().CS_emitTypePrefix(env);
env.print("[" + size + "]");
getType().CS_emitTypeSuffix(env);
for (int i = 1 ; i < depth ; i++) {
env.print("[]");
}
}
public void Type.CS_emitTypePrefix(CS_env env) {
throw new Error(this.getClass().getName() +
".CS_emitTypePrefix(CS_env env)" +
...
...
@@ -647,12 +631,12 @@ aspect CS_Class {
}
public void ArrayType.CS_emitTypeSuffix(CS_env env){
getType().CS_emitTypeSuffix(env);
env.print("[");
for (int i = 1 ; i < getNumExp() ; i++) {
env.print(",");
}
env.print("]");
getType().CS_emitTypeSuffix(env);
}
public boolean Type.CS_needInstance() {
...
...
@@ -703,7 +687,7 @@ aspect CS_Class {
public void StructType.CS_emitInstance(CS_env env) {
if (CS_Depth() > 0) {
env.println("public
static
class " + CS_structName() + " {");
env.println("public class " + CS_structName() + " {");
env.indent();
}
for (int i = 0 ; i < getNumField() ; i++) {
...
...
@@ -751,12 +735,13 @@ aspect CS_Class {
}
public void ArrayType.CS_emitType(CS_env env){
getType().CS_emitType(env);
getType().CS_emitType
Prefix
(env);
env.print("[");
for (int i = 1 ; i < getNumExp() ; i++) {
env.print(",");
}
env.print("]");
getType().CS_emitTypeSuffix(env);
}
public void StructType.CS_emitType(CS_env env){
...
...
This diff is collapsed.
Click to expand it.
test/Makefile
+
1
−
1
View file @
031d8eff
TESTS
=
basic simple
TESTS
=
basic simple
nested
LABCOMM_JAR
=
../compiler/labComm.jar
LABCOMM
=
java
-jar
$(
LABCOMM_JAR
)
...
...
This diff is collapsed.
Click to expand it.
test/nested.lc
+
6
−
3
View file @
031d8eff
typedef int int_array_ss[1][_, 3, _][5];
sample struct { int aa; boolean bb; int_array_ss ias; } struct_array_ss[1][_][_];
sample int s_array_array_array[1][1, 1][1, 1, 1];
sample struct {
int b[1][1, 1];
int c[1][_, 1, _][_,_];
} struct_array_ss[1];
typedef int int_t;
typedef int int_array_t[1][2][3,4];
typedef struct { int a; } struct_t;
...
...
@@ -18,3 +20,4 @@ sample int_array_t int_array_t_s;
sample struct_t struct_t_s;
sample struct_array_t struct_array_t_s;
sample struct_struct_t struct_struct_t_s;
This diff is collapsed.
Click to expand it.
test/test_encoder_decoder.py
+
2
−
44
View file @
031d8eff
...
...
@@ -142,7 +142,7 @@ def get_signatures(path):
with
fp
as
fp
:
m
=
imp
.
load_module
(
'
signatures
'
,
fp
,
pathname
,
description
)
pass
return
m
.
s
ignatures
return
m
.
s
ample
class
Test
:
...
...
@@ -250,46 +250,4 @@ if __name__ == "__main__":
for
lc
in
args
.
lc
:
run
(
lc
,
args
)
pass
exit
(
0
)
print
os
.
getcwd
(),
sys
.
argv
if
not
os
.
path
.
exists
(
"
gen
"
):
os
.
makedirs
(
"
gen
"
)
if
len
(
sys
.
argv
)
>
1
:
files
=
[
s
[
0
:
-
3
]
for
s
in
sys
.
argv
[
1
:]
if
s
.
endswith
(
'
.lc
'
)]
else
:
files
=
[
s
[
0
:
-
3
]
for
s
in
os
.
listdir
(
"
.
"
)
if
s
.
endswith
(
'
.lc
'
)]
for
f
in
files
:
cscode
.
test_program
(
"
gen/csharp/test_%s.cs
"
%
f
,
"
gen/%s.typeinfo
"
%
f
)
sys
.
path
.
insert
(
0
,
"
../lib/python
"
)
import
labcomm
;
sys
.
path
.
insert
(
0
,
"
gen/python
"
)
for
f
in
files
:
print
f
h
=
hexwriter
(
"
gen/%s.vec
"
%
f
)
encoder
=
labcomm
.
Encoder
(
h
)
signatures
=
[]
i
=
__import__
(
f
)
for
k
in
dir
(
i
):
v
=
getattr
(
i
,
k
)
try
:
s
=
v
.
signature
except
:
s
=
None
if
s
:
signatures
.
append
(
s
)
encoder
.
add_decl
(
s
)
for
s
in
signatures
:
for
e
in
generate
(
s
):
encoder
.
encode
(
e
[
1
],
s
)
h
.
flush
()
ccode
.
gen
(
f
,
signatures
)
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment