Permalink
Browse files

Fold the core/runtime.py loader into osh/meta.py.

This makes ASDL loading more consistent.
  • Loading branch information...
Andy Chu
Andy Chu committed Feb 7, 2018
1 parent 42fa8d7 commit 723b8bace053301ab59fef37eceafb654034ff70
View
@@ -110,7 +110,7 @@ def EmitFooter(self):
def main(argv):
schema_path = argv[1]
type_lookup_module = argv[2]
type_lookup_import = argv[2]
with open(schema_path) as input_f:
module = asdl.parse(input_f)
@@ -119,9 +119,9 @@ def main(argv):
f.write("""\
from asdl import const # For const.NO_INTEGER
from asdl import py_meta
from %s import TYPE_LOOKUP
%s
""" % type_lookup_module)
""" % type_lookup_import)
v = GenClassesVisitor(f)
v.VisitModule(module)
View
@@ -33,13 +33,15 @@ gen-help() {
gen-osh-asdl() {
local out=_devbuild/gen/osh_asdl.py
PYTHONPATH=. asdl/gen_python.py osh/osh.asdl 'osh.meta' > $out
local import='from osh.meta import OSH_TYPE_LOOKUP as TYPE_LOOKUP'
PYTHONPATH=. asdl/gen_python.py osh/osh.asdl "$import" > $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
local import='from osh.meta import RUNTIME_TYPE_LOOKUP as TYPE_LOOKUP'
PYTHONPATH=. asdl/gen_python.py core/runtime.asdl "$import" > $out
echo "Wrote $out"
}
View
@@ -31,7 +31,7 @@
from core import args
from core import lexer
from core import runtime
from osh.meta import runtime
from core import util
from core import state
from core import word_compile
View
@@ -35,7 +35,7 @@
from core import util
from core import builtin
from core import process
from core import runtime
from osh.meta import runtime
from core import state
from core import word_compile
View
@@ -38,7 +38,7 @@
from osh.meta import ast
from osh import parse_lib
from core import alloc
from core import runtime
from osh.meta import runtime
from core import state
from core import ui
from core import util
View
@@ -20,7 +20,7 @@
from osh.meta import BOOL_OPS, Id
from core.id_kind import OperandType
from core import util
from core import runtime
from osh.meta import runtime
from osh.meta import ast
View
@@ -37,7 +37,7 @@
}
"""
from core import runtime
from osh.meta import runtime
from core import util
value_e = runtime.value_e
View
@@ -16,7 +16,7 @@
import os
import sys
from core import runtime
from osh.meta import runtime
from core import util
from osh.meta import Id
View
@@ -11,7 +11,7 @@
from osh.meta import ast
from core import process # module under test
from core import runtime
from osh.meta import runtime
from core import util
from core.cmd_exec_test import InitExecutor # helper
View

This file was deleted.

Oops, something went wrong.
View
@@ -15,7 +15,7 @@
from core import args
from core import legacy
from core import runtime
from osh.meta import runtime
from core import util
from osh.meta import Id
View
@@ -5,7 +5,7 @@
import unittest
from core import runtime
from osh.meta import runtime
from core import state # module under test
from core import util
from core import test_lib
View
@@ -8,7 +8,7 @@
from core import id_kind
from core import expr_eval
from core import runtime
from osh.meta import runtime
from core import util
from osh import bool_parse
View
@@ -7,7 +7,7 @@
"""
from osh.meta import Id
from core import runtime
from osh.meta import runtime
var_flags_e = runtime.var_flags_e
View
@@ -10,7 +10,7 @@
from core import libstr
from core import glob_
from osh.meta import Id, Kind, LookupKind
from core import runtime
from osh.meta import runtime
from core import state
from core import word_compile
from core import util
View
@@ -102,27 +102,48 @@ def IdInstance(i):
_kind_sizes = ID_SPEC.kind_sizes
APP_TYPES = {'id': asdl.UserType(Id)}
#
# Instantiate the AST
#
f = util.GetResourceLoader().open('osh/osh.asdl')
app_types = {'id': asdl.UserType(Id)}
_asdl_module, _type_lookup = asdl.LoadSchema(f, app_types)
_asdl_module, _type_lookup = asdl.LoadSchema(f, APP_TYPES)
ast = _AsdlModule()
if 0:
py_meta.MakeTypes(_asdl_module, ast, _type_lookup)
else:
# Exported for the generated code to use
TYPE_LOOKUP = _type_lookup
OSH_TYPE_LOOKUP = _type_lookup
# Get the types from elsewhere
from _devbuild.gen import osh_asdl
py_meta.AssignTypes(osh_asdl, ast)
f.close()
#
# Instantiate runtime
#
f = util.GetResourceLoader().open('core/runtime.asdl')
_asdl_module, _type_lookup = asdl.LoadSchema(f, APP_TYPES)
runtime = _AsdlModule()
if 0:
py_meta.MakeTypes(module, runtime, _type_lookup)
else:
# Exported for the generated code to use
RUNTIME_TYPE_LOOKUP = _type_lookup
# Get the types from elsewhere
from _devbuild.gen import runtime_asdl
py_meta.AssignTypes(runtime_asdl, runtime)
f.close()
#
# Redirect Tables associated with IDs
View
@@ -55,7 +55,8 @@ replace() {
replace2() {
#sed -r -i "s/^from core.id_kind import/from osh.meta import/g" */*.py
sed -r -i "s/^from osh import ast_ as ast/from osh.meta import ast/g" */*.py
#sed -r -i "s/^from osh import ast_ as ast/from osh.meta import ast/g" */*.py
sed -r -i "s/^from core import runtime/from osh.meta import runtime/g" */*.py
}
trailing-ws() {

0 comments on commit 723b8ba

Please sign in to comment.