Permalink
Browse files

Turn on ASDL code gen for core/runtime.asdl.

All unit tests and spec tests pass.
  • Loading branch information...
Andy Chu
Andy Chu committed Dec 20, 2017
1 parent dee20f7 commit 2882a573e5f63a216843088e4c7b2327a757d8b3
Showing with 25 additions and 6 deletions.
  1. +3 −2 asdl/gen_python.py
  2. +8 −1 build/dev.sh
  3. +14 −3 core/runtime.py
View
@@ -128,6 +128,7 @@ def EmitFooter(self):
def main(argv):
schema_path = argv[1]
type_lookup_module = argv[2]
with open(schema_path) as input_f:
module = asdl.parse(input_f)
@@ -136,9 +137,9 @@ def main(argv):
f.write("""\
from asdl import const # For const.NO_INTEGER
from asdl import py_meta
from osh.ast_ import TYPE_LOOKUP
from %s import TYPE_LOOKUP
""")
""" % type_lookup_module)
v = GenClassesVisitor(f)
v.VisitModule(module)
View
@@ -33,7 +33,13 @@ gen-help() {
gen-osh-asdl() {
local out=_devbuild/gen/osh_asdl.py
PYTHONPATH=. asdl/gen_python.py osh/osh.asdl > $out
PYTHONPATH=. asdl/gen_python.py osh/osh.asdl 'osh.ast_' > $out
echo "Wrote $out"
}
gen-runtime-asdl() {
local out=_devbuild/gen/runtime_asdl.py
PYTHONPATH=. asdl/gen_python.py core/runtime.asdl 'core.runtime' > $out
echo "Wrote $out"
}
@@ -83,6 +89,7 @@ minimal() {
gen-help
gen-osh-asdl
gen-runtime-asdl
pylibc
}
View
@@ -13,7 +13,7 @@
from core.id_kind import Id
def _ParseAndMakeTypes(f, root):
def _LoadSchema(f):
module = asdl.parse(f)
app_types = {'id': asdl.UserType(Id)}
@@ -22,10 +22,21 @@ def _ParseAndMakeTypes(f, root):
# Check for type errors
if not asdl.check(module, app_types):
raise AssertionError('ASDL file is invalid')
py_meta.MakeTypes(module, root, type_lookup)
return module, type_lookup
f = util.GetResourceLoader().open('core/runtime.asdl')
root = sys.modules[__name__]
_ParseAndMakeTypes(f, root)
module, type_lookup = _LoadSchema(f)
if 0:
py_meta.MakeTypes(module, root, type_lookup)
else:
# Exported for the generated code to use
TYPE_LOOKUP = type_lookup
# Get the types from elsewhere
from _devbuild.gen import runtime_asdl
py_meta.AssignTypes(runtime_asdl, root)
f.close()

0 comments on commit 2882a57

Please sign in to comment.