示例#1
0
def parse_tree(label, data):
    context = Context()
    context.switch_stream(data)
    tree = Tree()
    getattr(parser, label).parse(context, tree)
    tree = parser.DeferredExpansion(context).transform(tree)
    return tree
示例#2
0
 def add_device_object(self, device_object):
     device_path = device_object.NameString.value
     scope = Context.parent(device_path)
     device_name = device_path[-4:]
     device_object.NameString.value = device_name
     self.__objects[scope].append(
         self.__discard_external_objects(device_object))
示例#3
0
def DSDT(val):
    table_dir = os.path.dirname(val)
    if not table_dir:
        table_dir = "."
    ssdt = filter(lambda x: x.startswith("SSDT"), os.listdir(table_dir))
    tables = [val] + list(map(lambda x: os.path.join(table_dir, x), ssdt))

    context = Context()
    trees = []
    try:
        for t in tables:
            logging.info(f"Loading {t}")
            context.switch_stream(t)
            tree = Tree()
            AMLCode.parse(context, tree)
            tree = DeferredExpansion(context).transform_topdown(tree)
            tree = FlattenTransformer().transform_bottomup(tree)
            trees.append(tree)
    except Exception as e:
        context.current_stream.dump()
        raise

    context.skip_external_on_lookup()
    visitor = ConditionallyUnregisterSymbolVisitor(
        ConcreteInterpreter(context))
    for tree in trees:
        visitor.visit_topdown(tree)
    return context