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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sven Gestegård Robertz
LabComm
Commits
2bb0383a
Commit
2bb0383a
authored
10 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Made compiler generate both typedef and signatures for python
to simplify implementation/use of orca.
parent
de9e61b3
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
compiler/2014/Python_CodeGen.jrag
+71
-9
71 additions, 9 deletions
compiler/2014/Python_CodeGen.jrag
with
71 additions
and
9 deletions
compiler/2014/Python_CodeGen.jrag
+
71
−
9
View file @
2bb0383a
...
...
@@ -105,29 +105,29 @@ aspect PythonTypes {
public void Program.Python_genTypes(Python_env env) {
for (int i = 0 ; i < getNumDecl() ; i++) {
getDecl(i).Python_genSignature(env);
getDecl(i).Python_genSignature
AndTypedef
(env);
}
}
public void Decl.Python_genSignature(Python_env env) {
public void Decl.Python_genSignature
AndTypedef
(Python_env env) {
throw new Error(this.getClass().getName() +
".Python_genSignature(Python_env env)" +
".Python_genSignature
AndTypedef
(Python_env env)" +
" not declared");
}
public void TypeDecl.Python_genSignature(Python_env env) {
public void TypeDecl.Python_genSignature
AndTypedef
(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("
signature
= labcomm2014.typedef('" + getName() + "',");
env.println("
typedef
= labcomm2014.typedef('" + getName() + "',");
env.indent();
getType().Python_gen
Signature
(env);
getType().Python_gen
Typedef
(env);
env.unindent();
env.println(")");
env.unindent();
env.println();
}
public void SampleDecl.Python_genSignature(Python_env env) {
public void SampleDecl.Python_genSignature
AndTypedef
(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm2014.sample('" + getName() + "', ");
...
...
@@ -135,13 +135,17 @@ aspect PythonTypes {
getType().Python_genSignature(env);
env.unindent();
env.println(")");
env.println("typedef = labcomm2014.sample('" + getName() + "', ");
env.indent();
getType().Python_genTypedef(env);
env.unindent();
env.println(")");
env.unindent();
env.println();
}
public void UserType.Python_genSignature(Python_env env) {
env.println(getName() + ".signature");
// lookupType(getName()).getType().Python_genSignature(env);
lookupType(getName()).getType().Python_genSignature(env);
}
public void Type.Python_genSignature(Python_env env) {
...
...
@@ -198,6 +202,64 @@ aspect PythonTypes {
env.print(")");
}
public void UserType.Python_genTypedef(Python_env env) {
env.println(getName() + ".typedef");
}
public void Type.Python_genTypedef(Python_env env) {
throw new Error(this.getClass().getName() +
".Python_genTypedef(Python_env env)" +
" not declared");
}
public void PrimType.Python_genTypedef(Python_env env) {
switch (getToken()) {
case LABCOMM_BOOLEAN: { env.print("labcomm2014.BOOLEAN()"); } break;
case LABCOMM_BYTE: { env.print("labcomm2014.BYTE()"); } break;
case LABCOMM_SHORT: { env.print("labcomm2014.SHORT()"); } break;
case LABCOMM_INT: { env.print("labcomm2014.INTEGER()"); } break;
case LABCOMM_LONG: { env.print("labcomm2014.LONG()"); } break;
case LABCOMM_FLOAT: { env.print("labcomm2014.FLOAT()"); } break;
case LABCOMM_DOUBLE: { env.print("labcomm2014.DOUBLE()"); } break;
case LABCOMM_STRING: { env.print("labcomm2014.STRING()"); } break;
case LABCOMM_SAMPLE: { env.print("labcomm2014.SAMPLE()"); } break;
}
}
public void ArrayType.Python_genTypedef(Python_env env) {
env.print("labcomm2014.array([");
for (int i = 0 ; i < getNumExp() ; i++) {
if (i > 0) { env.print(", "); }
env.print(getExp(i).Python_getValue());
}
env.println("],");
env.indent();
getType().Python_genTypedef(env);
env.print(")");
env.unindent();
}
public void StructType.Python_genTypedef(Python_env env) {
env.println("labcomm2014.struct([");
env.indent();
for (int i = 0 ; i < getNumField() ; i++) {
if (i > 0) { env.println(","); }
getField(i).Python_genTypedef(env);
}
env.print("])");
env.unindent();
}
public void VoidType.Python_genTypedef(Python_env env) {
env.println("labcomm2014.struct([])");
}
public void Field.Python_genTypedef(Python_env env) {
env.print("('" + getName() + "', ");
getType().Python_genTypedef(env);
env.print(")");
}
public void Decl.Python_genTypedefListEntry(Python_env env) {
}
...
...
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