summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-19 13:27:22 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-19 13:27:22 +0200
commitf14256ddd4129eb0e4ed331f2fa3d84b3618f0a6 (patch)
treed4b9e81d4f1e39a539229d90e0626a53e71bff8f
parent8f12413895954e5feed9ea915825d462f0457fe4 (diff)
Woops, the previous commit wasn't enough.
-rw-r--r--instr-scripts/id_manager.py6
-rw-r--r--instr-scripts/process_internals.py62
-rwxr-xr-xinstr-scripts/structural_level.py51
3 files changed, 112 insertions, 7 deletions
diff --git a/instr-scripts/id_manager.py b/instr-scripts/id_manager.py
index a406cd6..27c1474 100644
--- a/instr-scripts/id_manager.py
+++ b/instr-scripts/id_manager.py
@@ -11,6 +11,12 @@ class Id_Manager:
result = str(self.next_id)
self.next_id += 1
+ self.output.write(
+ "(map_xml_id PURE "
+ + result
+ + ")\n"
+ )
+
return result
def generate_new_id (self, xml_id):
diff --git a/instr-scripts/process_internals.py b/instr-scripts/process_internals.py
index 378a6c7..e0034bf 100644
--- a/instr-scripts/process_internals.py
+++ b/instr-scripts/process_internals.py
@@ -1,3 +1,18 @@
+def is_function_or_literal (
+ root,
+ ref
+):
+ source = root.find(".//el[@id=\"" + ref + "\"]")
+
+ if (source == None):
+ return True
+ elif (source.attrib.get("kind") == "function_declaration"):
+ return True
+ elif (source.attrib.get("kind") == "enumeration_literal"):
+ return True
+
+ return False
+
def new_element_from_xml (
inst_list_output,
id_manager,
@@ -35,7 +50,7 @@ def new_element (
class Process_Internals:
def __init__ (self, root, xml, id_manager, wfm_manager, process_id, output):
self.xml = xml
- self.root_xml = root
+ self.xml_root = root
self.id_manager = id_manager
self.wfm_manager = wfm_manager
self.output = output
@@ -128,13 +143,13 @@ class Process_Internals:
for src_xml in sources_xml:
ref = src_xml.attrib.get("ref")
- if (self.root_xml.find(".//el[@id=\"" + ref + "\"]") == None):
+ if (is_function_or_literal(self.xml_root, ref)):
print(
"Assumed that \""
+ src_xml.find("./..").attrib.get("identifier")
- + "\" is a function or literal (XML id: "
+ + "\" is a function or literal (XML id: \""
+ ref
- + ", could not find source)."
+ + "\")."
)
continue
@@ -330,6 +345,19 @@ class Process_Internals:
)
for src_xml in sources_xml:
+ ref = src_xml.attrib.get("ref")
+
+ if (is_function_or_literal(self.xml_root, ref)):
+ print(
+ "Assumed that \""
+ + src_xml.find("./..").attrib.get("identifier")
+ + "\" is a function or literal (XML id: \""
+ + ref
+ + "\")."
+ )
+
+ continue
+
self.output.write(
"(expr_reads "
+ node_id
@@ -372,6 +400,19 @@ class Process_Internals:
)
for src_xml in sources_xml:
+ ref = src_xml.attrib.get("ref")
+
+ if (is_function_or_literal(self.xml_root, ref)):
+ print(
+ "Assumed that \""
+ + src_xml.find("./..").attrib.get("identifier")
+ + "\" is a function or literal (XML id: \""
+ + ref
+ + "\")."
+ )
+
+ continue
+
self.output.write(
"(expr_reads "
+ cond_node_id
@@ -482,6 +523,19 @@ class Process_Internals:
)
for src_xml in sources_xml:
+ ref = src_xml.attrib.get("ref")
+
+ if (is_function_or_literal(self.xml_root, ref)):
+ print(
+ "Assumed that \""
+ + src_xml.find("./..").attrib.get("identifier")
+ + "\" is a function or literal (XML id: \""
+ + ref
+ + "\")."
+ )
+
+ continue
+
self.output.write(
"(expr_reads "
+ node_id
diff --git a/instr-scripts/structural_level.py b/instr-scripts/structural_level.py
index 0427e3c..e645d57 100755
--- a/instr-scripts/structural_level.py
+++ b/instr-scripts/structural_level.py
@@ -7,6 +7,21 @@ import id_manager
import waveform_manager
import process_internals
+def is_function_or_literal (
+ root,
+ ref
+):
+ source = root.find(".//el[@id=\"" + ref + "\"]")
+
+ if (source == None):
+ return True
+ elif (source.attrib.get("kind") == "function_declaration"):
+ return True
+ elif (source.attrib.get("kind") == "enumeration_literal"):
+ return True
+
+ return False
+
################################################################################
## Types #######################################################################
################################################################################
@@ -501,11 +516,26 @@ def handle_process (
".//*[@kind=\"simple_name\"]/named_entity"
)
for c in children:
- inst_list_output.write(
- "(is_accessed_by "
- + wfm_manager.get_waveform_from_source(
+ ref = c.attrib.get("ref")
+
+ if (is_function_or_literal(root, ref)):
+ print(
+ "Assumed that \""
+ + c.find("./..").attrib.get("identifier")
+ + "\" is a function or literal (XML id: \""
+ + ref
+ + "\")."
+ )
+
+ continue
+
+ ref = wfm_manager.get_waveform_from_source(
id_manager.get_id_from_xml(c.attrib.get("ref"))
)
+
+ inst_list_output.write(
+ "(is_accessed_by "
+ + ref
+ " "
+ local_id
+ ")\n"
@@ -851,6 +881,20 @@ def handle_generic (
xml_id
)
+ ## Matching Waveform #######################################################
+ #### Add Element ###########################################################
+ waveform_id = wfm_manager.get_waveform_from_source(local_id)
+ inst_list_output.write("(add_element waveform " + waveform_id + ")\n")
+
+ #### Link With Signal ######################################################
+ inst_list_output.write(
+ "(is_waveform_of "
+ + waveform_id
+ + " "
+ + local_id
+ + ")\n"
+ )
+
## Set Functions ###########################################################
#### line
string_id = new_element_from_string(
@@ -894,6 +938,7 @@ def handle_generic (
+ ")\n"
)
+
## Set Unary Predicates ####################################################
if (elem.attrib.get("has_class") == "true"):
inst_list_output.write("(has_class " + local_id + ")\n")