コード例 #1
0
ファイル: mainpass.py プロジェクト: londav28/chasm
def visit(node, env=None):
    result = ast.Group()
    m = env['active-method-map']
    start = m['ins']
    result.children += acm.visitlist(node.body, visit, env)
    end = m['ins']
    erange = (start, end)
    m['eranges'].append(erange)
    node.handlers = acm.visitlist(node.handlers, visit, env)
    for handler in node.handlers:
        # All except blocks now converted to groups of instructions!
        assert (isinstance(handler, ast.Group))
        result.children += handler.children
    m['eranges'].pop()
    return result
コード例 #2
0
ファイル: mainpass.py プロジェクト: londav28/chasm
def visit(node, env=None):
    # NOTE: Preliminary context setup.
    _env_push_context(node, env)
    env['methods'].append(node)
    m = _env_fetch_create(node, env)
    _init_method_map(m)
    env['active-method-map'] = m
    # Iterate over method body.
    node.body = acm.visitlist(node.body, visit, env)
    # Generate a signature block for the arguments and return type.
    typeblock = _make_sig_block(node)
    # Compute flag metadata.
    m['status-0'] = {
        'isvoid': (node.rtype == None),
        'noparams': (len(node.args) == 0),
        'nothrow': (len(m['exceptions']) == 0),
        'debugsym': m['pragmas']['debugset']
    }
    # NOTE: Not all data prepared, some NONE entries for completeness.
    m['status-1'] = {}
    m['name-string'] = _intern_str(node.id.value, env)
    m['debug-symbol'] = m['pragmas']['debugsym']
    m['signature-block'] = _intern_str(typeblock, env)
    m['stack-limit'] = m['pragmas']['limstack']
    m['local-limit'] = m['pragmas']['limlocal']
    m['ins-byte-count'] = fw.restrict(m['ins'], 'u32')
    m['ins-bytes'] = None
    m['ete-count'] = fw.restrict(len(m['exceptions']), 'u32')
    m['ete'] = m['exceptions']
    _env_pop_context(env)
    return node
コード例 #3
0
ファイル: mainpass.py プロジェクト: londav28/chasm
def visit(node, env=None):
    if env is None:
        env = {}
    _env_init(env)
    _env_push_context(node, env)
    node.children = acm.visitlist(node.children, visit, env)
    m = _env_fetch_create(node, env)
    m['methods'] = env['methods']
    m['objects'] = env['objects']
    # Build and attach the string/int64/flt64 tables.
    m['strings'] = _listify_intern_map(env['interned-str'])
    m['int64s'] = _listify_intern_map(env['interned-int64'])
    m['flt64s'] = _listify_intern_map(env['interned-flt64'])
    # NOTE: Bounds checks we were talking about!
    m['method-count'] = fw.restrict(len(env['methods']), 'u32')
    m['object-count'] = fw.restrict(len(env['objects']), 'u32')
    m['string-count'] = fw.restrict(len(m['strings']), 'u32')
    m['int64-count'] = fw.restrict(len(m['int64s']), 'u32')
    m['flt64-count'] = fw.restrict(len(m['flt64s']), 'u32')
    _env_pop_context(env)
    return node
コード例 #4
0
ファイル: backpatching.py プロジェクト: londav28/chasm
def visit(node, env=None):
    node.body = acm.visitlist(node.body, env)
    return node
コード例 #5
0
ファイル: backpatching.py プロジェクト: londav28/chasm
def visit(node, env=None):
    # Again, this wouldn't work with nested methods.
    env['active-method'] = env[node]
    node.body = acm.visitlist(node.body, visit, env)
    return node
コード例 #6
0
ファイル: backpatching.py プロジェクト: londav28/chasm
def visit(node, env=None):
    node.children = acm.visitlist(node.children, visit, env)
    return node
コード例 #7
0
ファイル: mainpass.py プロジェクト: londav28/chasm
def visit(node, env=None):
    result = ast.Group()
    _add_exception_entry(node, env)
    result.children += acm.visitlist(node.body, visit, env)
    return result