فهرست منبع

Remove unnecessary parts in bootstrap and compilers: symbols and hash

Yentl Van Tendeloo 8 سال پیش
والد
کامیت
6518e8fd23
3فایلهای تغییر یافته به همراه6 افزوده شده و 29 حذف شده
  1. 3 18
      bootstrap/bootstrap.py
  2. 2 8
      interface/HUTN/hutn_compiler/bootstrap_visitor.py
  3. 1 3
      interface/HUTN/hutn_compiler/compiler.py

+ 3 - 18
bootstrap/bootstrap.py

@@ -18,7 +18,6 @@ def bootstrap():
                     ]
 
     task_frame = [  "evalstack",
-                    "symbols",
                     "returnvalue",
                     ]
 
@@ -187,11 +186,11 @@ def bootstrap():
                 # Bind task to the root
                 f.write('Dict (root, "%s", task_root)\n' % (task_manager))
 
-                def compile_code_AL(filename, target, prepend="", main=False, symbols=None):
+                def compile_code_AL(filename, target, prepend="", main=False):
                     import sys
                     sys.path.append("interface/HUTN/")
                     from hutn_compiler.compiler import main as compile_code
-                    code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"], symbols=symbols)
+                    code = compile_code(filename, "interface/HUTN/grammars/actionlanguage.g", "BS", ["--debug", "--prepend:%s" % prepend, "--main" if main else "--not-main"])
                     return code.replace("auto_initial_IP", target)
 
                 # Create all library code
@@ -234,8 +233,7 @@ def bootstrap():
                     # Compile the subfile
                     bootstrap_file = bootstrap_file.replace("\\", "/")
                     print("[ALC] %s" % bootstrap_file)
-                    symbols = {}
-                    f.write(compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, symbols=symbols, main = bootstrap_file in [initial_code_manager, initial_code_task]), both=False)
+                    f.write(compile_code_AL(bootstrap_file, "initial_IP", prepend=bootstrap_file, main = bootstrap_file in [initial_code_manager, initial_code_task]), both=False)
 
                     # Now link the code with the compilation manager structure
                     f.write("Node elem()\n", both=False)
@@ -243,19 +241,6 @@ def bootstrap():
                     f.write('Dict (__objects, "%s", elem)\n' % bootstrap_file, both=False)
                     f.write('Dict (elem, "initializers", %s_initial_IP)\n' % bootstrap_file, both=False)
 
-                    md5 = hashlib.md5()
-                    md5.update(open(bootstrap_file, 'r').read())
-
-                    f.write('Node hash_value("%s")\n' % md5.hexdigest(), both=False)
-                    f.write('Dict (elem, "hash_md5", hash_value)\n', both=False)
-
-                    f.write('Node __symbols()\n', both=False)
-                    f.write('Dict (elem, "symbols", __symbols)\n', both=False)
-
-                    for k, v in symbols.items():
-                        f.write('Node v(%s)\n' % v, both=False)
-                        f.write('Dict (__symbols, "%s", v)\n' % (k), both=False)
-
                 # Create code for initial task
                 print("[BOOT] task_manager")
                 f.write('Dict (task_frame, "IP", %s_initial_IP)\n' % (initial_code_manager), both=False)

+ 2 - 8
interface/HUTN/hutn_compiler/bootstrap_visitor.py

@@ -13,8 +13,6 @@ class BootstrapVisitor(PrimitivesVisitor):
         else:
             self.prepend_name = "auto"
 
-        self.object_symbols = {}
-
     def rename(self, name):
         if name == "initial_IP":
             return "%s_%s" % (self.prepend_name, name)
@@ -66,17 +64,16 @@ class BootstrapVisitor(PrimitivesVisitor):
                 output.append("Edge _%s(_%s, _%s)\n" % (name, source, target))
         return ''.join(output)
 
+    """
     def visit_definition(self, tree):
         for a in tree.get_children("ID"):
             name = a.get_tail()[0]
-            self.object_symbols[name] = True
             return PrimitivesVisitor.visit_definition(self, tree)
 
     def visit_vardecl(self, tree):
         if len(tree.get_tail()) > 2:
             for a in tree.get_children("ID"):
                 name = a.get_tail()[0]
-                self.object_symbols.setdefault(name, False)
                 return PrimitivesVisitor.visit_vardecl(self, tree)
         else:
             return PrimitivesVisitor.visit_vardecl(self, tree)
@@ -85,8 +82,5 @@ class BootstrapVisitor(PrimitivesVisitor):
         for a in tree.get_children("func_name"):
             for b in a.get_children("ID"):
                 name = b.get_tail()[0]
-                if tree.get_children("func_body") or tree.get_children("ASSIGN"):
-                    self.object_symbols[name] = True
-                else:
-                    self.object_symbols.setdefault(name, False)
                 return PrimitivesVisitor.visit_funcdecl(self, tree)
+    """

+ 1 - 3
interface/HUTN/hutn_compiler/compiler.py

@@ -141,7 +141,7 @@ def do_compile(inputfile, grammarfile, visitors=[], include_paths = []):
     if visitors:
         return visitors[-1].dump()
 
-def main(input_file, grammar_file, mode, args=[], symbols=None):
+def main(input_file, grammar_file, mode, args=[]):
     from prettyprint_visitor import PrettyPrintVisitor
     from prettyprint_visitor import PrintVisitor
     from semantics_visitor import SemanticsVisitor
@@ -162,8 +162,6 @@ def main(input_file, grammar_file, mode, args=[], symbols=None):
     try:
         visitors = [v(args) for v in modes[mode]]
         result = do_compile(input_file, grammar_file, visitors)
-        if symbols is not None and mode == "BS":
-            symbols.update(visitors[-1].object_symbols)
     except CachedException:
         return True
     return result