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
dc45a40a
Commit
dc45a40a
authored
Jul 03, 2014
by
dbarbera
Browse files
Added choice determinant generation
parent
4a99fbc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
LlvmGenerator.py
View file @
dc45a40a
...
...
@@ -44,6 +44,7 @@ class Context():
self
.
scope
=
Scope
()
self
.
global_scope
=
self
.
scope
self
.
states
=
{}
self
.
enums
=
{}
self
.
structs
=
{}
self
.
unions
=
{}
self
.
strings
=
{}
...
...
@@ -164,9 +165,13 @@ class Context():
''' Return the equivalent LL type of a Choice ASN.1 type '''
field_names
=
[]
field_types
=
[]
for
field_name
,
field_ty
in
choice_ty
.
Children
.
viewitems
():
for
idx
,
field_name
in
enumerate
(
Helper
.
sorted_fields
(
choice_ty
)):
# enum values used in choice determinant/present
self
.
enums
[
field_name
]
=
core
.
Constant
.
int
(
self
.
i32
,
idx
)
field_names
.
append
(
field_name
)
field_types
.
append
(
self
.
type_of
(
field_
ty
.
type
))
field_types
.
append
(
self
.
type_of
(
choice_ty
.
Children
[
field_
name
]
.
type
))
union
=
self
.
decl_union
(
field_names
,
field_types
,
name
)
return
union
.
ty
...
...
@@ -1074,7 +1079,8 @@ def _enumerated_value(primary):
@
expression
.
register
(
ogAST
.
PrimChoiceDeterminant
)
def
_choice_determinant
(
primary
):
''' Generate code for a choice determinant (enumerated) '''
raise
NotImplementedError
enumerant
=
primary
.
value
[
0
].
replace
(
'_'
,
'-'
)
return
ctx
.
enums
[
enumerant
]
@
expression
.
register
(
ogAST
.
PrimInteger
)
...
...
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