Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TASTE
dmt
Commits
8e74a764
Commit
8e74a764
authored
Jul 29, 2019
by
Thanassis Tsiodras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce cache-ing of AADL ASTs created by ANTLR-based parser.
parent
b7f5c79b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
14 deletions
+42
-14
dmt/aadl2glueC.py
dmt/aadl2glueC.py
+42
-14
No files found.
dmt/aadl2glueC.py
View file @
8e74a764
...
...
@@ -80,6 +80,7 @@ but with an extra call to OnFinal at the end.
import
os
import
sys
import
hashlib
from
distutils
import
spawn
from
typing
import
cast
,
Optional
,
Dict
,
List
,
Tuple
,
Set
,
Any
# NOQA pylint: disable=unused-import
...
...
@@ -145,19 +146,48 @@ def ParseAADLfilesAndResolveSignals() -> None:
'''Invokes the ANTLR generated AADL parser, and resolves
all references to AAADL Data types into the param._signal member
of each SUBPROGRAM param.'''
import
tempfile
f
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
astFile
=
f
.
name
f
.
close
()
os
.
unlink
(
astFile
)
parserUtility
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)),
"parse_aadl.py"
)
cmd
=
"python2 "
+
parserUtility
+
" -o "
+
astFile
+
' '
+
\
projectCache
=
os
.
getenv
(
"PROJECT_CACHE"
)
if
projectCache
is
not
None
:
if
not
os
.
path
.
isdir
(
projectCache
):
panic
(
"The configured cache folder:
\n\n\t
"
+
projectCache
+
"
\n\n
...is not there!
\n
"
)
cachedModelExists
=
False
aadlASTcache
=
None
if
projectCache
is
not
None
:
filehash
=
hashlib
.
md5
()
for
each
in
sorted
(
sys
.
argv
[
1
:]):
filehash
.
update
(
open
(
each
).
read
().
encode
(
'utf-8'
))
newHash
=
filehash
.
hexdigest
()
# set the name of the Pickle files containing the dumped AST
aadlASTcache
=
projectCache
+
os
.
sep
+
newHash
+
"_aadl_ast.pickle"
if
not
os
.
path
.
exists
(
aadlASTcache
):
print
(
"[DMT] No cached AADL model found for"
,
","
.
join
(
sys
.
argv
[
1
:]))
else
:
cachedModelExists
=
True
print
(
"[DMT] Reusing cached AADL model for"
,
","
.
join
(
sys
.
argv
[
1
:]))
import
pickle
if
cachedModelExists
:
astInfo
=
pickle
.
load
(
open
(
aadlASTcache
,
'rb'
),
fix_imports
=
False
)
else
:
import
tempfile
f
=
tempfile
.
NamedTemporaryFile
(
delete
=
False
)
astFile
=
f
.
name
f
.
close
()
os
.
unlink
(
astFile
)
parserUtility
=
os
.
path
.
join
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)),
"parse_aadl.py"
)
cmd
=
"python2 "
+
parserUtility
+
" -o "
+
astFile
+
' '
+
\
' '
.
join
(
sys
.
argv
[
1
:])
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
path
.
exists
(
astFile
):
os
.
unlink
(
astFile
)
panic
(
"AADL parsing failed. Aborting..."
)
if
os
.
system
(
cmd
)
!=
0
:
if
os
.
path
.
exists
(
astFile
):
os
.
unlink
(
astFile
)
panic
(
"AADL parsing failed. Aborting..."
)
astInfo
=
pickle
.
load
(
open
(
astFile
,
'rb'
),
fix_imports
=
False
)
if
aadlASTcache
:
pickle
.
dump
(
astInfo
,
open
(
aadlASTcache
,
'wb'
),
fix_imports
=
False
)
def
FixMetaClasses
(
sp
:
ApLevelContainer
)
->
None
:
def
patchMe
(
o
:
Any
)
->
None
:
...
...
@@ -181,8 +211,6 @@ of each SUBPROGRAM param.'''
for
cn
in
sp
.
_connections
:
patchMe
(
cn
)
try
:
import
pickle
astInfo
=
pickle
.
load
(
open
(
astFile
,
'rb'
),
fix_imports
=
False
)
for
k
in
[
'g_processImplementations'
,
'g_apLevelContainers'
,
'g_signals'
,
'g_systems'
,
'g_subProgramImplementations'
,
'g_threadImplementations'
]:
...
...
Write
Preview
Markdown
is supported
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