Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
f10a2157
Commit
f10a2157
authored
Jul 03, 2014
by
dbarbera
Browse files
Added resolve methods to context
parent
b3cfdc54
Changes
1
Hide whitespace changes
Inline
Side-by-side
LlvmGenerator.py
View file @
f10a2157
...
...
@@ -201,16 +201,26 @@ class Context():
def
decl_struct
(
self
,
field_names
,
field_types
,
name
=
None
):
''' Declare a struct '''
name
=
name
if
name
else
"struct.%s"
%
len
(
self
.
structs
)
name
=
name
.
replace
(
'-'
,
'_'
)
struct
=
StructType
(
name
,
field_names
,
field_types
)
self
.
structs
[
name
]
=
struct
return
struct
def
resolve_struct
(
self
,
name
):
''' Return the struct associated to a name '''
return
self
.
structs
[
name
.
replace
(
'-'
,
'_'
)]
def
decl_union
(
self
,
field_names
,
field_types
,
name
=
None
):
name
=
name
if
name
else
"union.%s"
%
len
(
self
.
structs
)
name
=
name
.
replace
(
'-'
,
'_'
)
union
=
UnionType
(
name
,
field_names
,
field_types
)
self
.
unions
[
name
]
=
union
return
union
def
resolve_union
(
self
,
name
):
''' Return the union associated to a name '''
return
self
.
unions
[
name
.
replace
(
'-'
,
'_'
)]
class
StructType
():
def
__init__
(
self
,
name
,
field_names
,
field_types
):
...
...
@@ -1168,7 +1178,7 @@ def _if_then_else(ifthen):
@
expression
.
register
(
ogAST
.
PrimSequence
)
def
_sequence
(
seq
):
''' Generate the code for an ASN.1 SEQUENCE '''
struct
=
ctx
.
struct
s
[
seq
.
exprType
.
ReferencedTypeName
]
struct
=
ctx
.
resolve_
struct
(
seq
.
exprType
.
ReferencedTypeName
)
struct_ptr
=
ctx
.
builder
.
alloca
(
struct
.
ty
)
for
field_name
,
field_expr
in
seq
.
value
.
viewitems
():
...
...
@@ -1207,7 +1217,7 @@ def _sequence_of(seqof):
@
expression
.
register
(
ogAST
.
PrimChoiceItem
)
def
_choiceitem
(
choice
):
''' Generate the code for a CHOICE expression '''
union
=
ctx
.
union
s
[
choice
.
exprType
.
ReferencedTypeName
]
union
=
ctx
.
resolve_
union
(
choice
.
exprType
.
ReferencedTypeName
)
union_ptr
=
ctx
.
builder
.
alloca
(
union
.
ty
)
expr_val
=
expression
(
choice
.
value
[
'value'
])
...
...
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