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
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Anders Blomdell
LabComm
Commits
f7bd9857
Commit
f7bd9857
authored
10 years ago
by
Sven Gestegård Robertz
Browse files
Options
Downloads
Patches
Plain Diff
Python refactoring: changed name to dict
parent
9e1a6d74
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/2014/Python_CodeGen.jrag
+22
-5
22 additions, 5 deletions
compiler/2014/Python_CodeGen.jrag
lib/python/labcomm2014/LabComm.py
+17
-8
17 additions, 8 deletions
lib/python/labcomm2014/LabComm.py
with
39 additions
and
13 deletions
compiler/2014/Python_CodeGen.jrag
+
22
−
5
View file @
f7bd9857
...
...
@@ -115,9 +115,11 @@ aspect PythonTypes {
public void TypeDecl.Python_genSignatureAndTypedef(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("typedef = labcomm2014.typedef('" + getName() + "',");
env.print("typedef = labcomm2014.typedef(");
Python_genIntentions(env);
env.println(",");
env.indent();
get
DataTyp
e().Python_genTypedef(env);
get
TypeInstanc
e().Python_genTypedef(env);
env.unindent();
env.println(")");
env.unindent();
...
...
@@ -127,19 +129,34 @@ aspect PythonTypes {
public void SampleDecl.Python_genSignatureAndTypedef(Python_env env) {
env.println("class " + getName() + "(object):");
env.indent();
env.println("signature = labcomm2014.sample('" + getName() + "', ");
env.print("signature = labcomm2014.sample(");
Python_genIntentions(env);
env.println(",");
env.indent();
getDataType().Python_genSignature(env);
env.unindent();
env.println(")");
env.println("typedef = labcomm2014.sample('" + getName() + "', ");
env.print("typedef = labcomm2014.sample(");
Python_genIntentions(env);
env.println(",");
env.indent();
get
DataTyp
e().Python_genTypedef(env);
get
TypeInstanc
e().Python_genTypedef(env);
env.unindent();
env.println(")");
env.unindent();
env.println();
}
public void Decl.Python_genIntentions(Python_env env) {
getTypeInstance().Python_genIntentions(env);
}
public void TypeInstance.Python_genIntentions(Python_env env) {
env.print("{'':'"+getName()+"'}");
}
public void TypeInstance.Python_genTypedef(Python_env env) {
getDataType().Python_genTypedef(env);
}
public void UserType.Python_genSignature(Python_env env) {
lookupType(getName()).getDataType().Python_genSignature(env);
...
...
This diff is collapsed.
Click to expand it.
lib/python/labcomm2014/LabComm.py
+
17
−
8
View file @
f7bd9857
...
...
@@ -393,8 +393,11 @@ class SAMPLE(primitive):
# Aggregate types
#
class
sampledef_or_sampleref_or_typedef
(
type_decl
):
def
__init__
(
self
,
name
=
None
,
decl
=
None
):
self
.
name
=
name
def
__init__
(
self
,
intentions
=
None
,
decl
=
None
):
if
intentions
is
not
None
and
''
in
intentions
:
self
.
name
=
intentions
[
''
]
else
:
self
.
name
=
None
self
.
decl
=
decl
def
encode_decl
(
self
,
encoder
):
...
...
@@ -418,7 +421,7 @@ class sampledef_or_sampleref_or_typedef(type_decl):
length
=
decoder
.
decode_packed32
()
decl
=
decoder
.
decode_decl
()
result
=
self
.
__class__
.
__new__
(
self
.
__class__
)
result
.
__init__
(
name
=
name
,
decl
=
decl
)
result
.
__init__
(
intentions
=
{
''
:
name
}
,
decl
=
decl
)
self
.
add_index
(
decoder
,
index
,
result
)
return
result
...
...
@@ -455,17 +458,23 @@ class sample_def(sampledef_or_sampleref_or_typedef):
decoder
.
add_decl
(
decl
,
index
)
def
rename
(
self
,
name
):
return
sample_def
(
name
=
name
,
decl
=
self
.
decl
)
newIntentions
=
intentions
.
copy
()
newIntentions
[
''
]
=
name
return
sample_def
(
newIntentions
,
decl
=
self
.
decl
)
class
sample_ref
(
sampledef_or_sampleref_or_typedef
):
type_index
=
i_SAMPLE_REF
type_name
=
'
sample_ref
'
def
__init__
(
self
,
name
=
None
,
decl
=
None
,
sample
=
None
):
self
.
name
=
name
def
__init__
(
self
,
intentions
=
None
,
decl
=
None
,
sample
=
None
):
if
intentions
is
not
None
and
''
in
intentions
:
self
.
name
=
intentions
[
''
]
print
"
sampleref: name = %d
"
%
self
.
name
else
:
self
.
name
=
None
self
.
decl
=
decl
if
sample
==
None
and
name
!=
None
and
decl
!=
None
:
self
.
sample
=
sample_def
(
name
,
decl
)
if
sample
==
None
and
self
.
name
!=
None
and
decl
!=
None
:
self
.
sample
=
sample_def
(
intentions
,
decl
)
else
:
self
.
sample
=
sample
...
...
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