Esempio n. 1
0
def vardecl_stmt(node):

    (VARDECL, (ID, name), init_val) = node

    value = walk(init_val)
    symtab.declare(name, ('INTEGER', value))
    return None
def declare_temp():
    name = make_temp_name()
    target_name = symtab.make_target_name()
    symtab.declare(name, ('INTEGER', target_name))
    if not symtab.in_function:
        symtab.global_vars += [(target_name, 8)]
    return target_name
Esempio n. 3
0
def fundecl_stmt(node):

    (FUNDECL, (ID, name), arglist, body) = node

    context = symtab.get_config()
    funval = ('FUNVAL', arglist, body, context)
    symtab.declare(name, funval)
    return None
def vardecl_stmt(node):

    (VARDECL, (ID, name), init_val) = node

    t = walk(init_val)
    target_name = symtab.make_target_name()
    symtab.declare(name, ('INTEGER', target_name))

    return ('ASSIGN', ('ADDR', target_name), t)
def declare_formal_args(formal_args):

    (LIST, fl) = formal_args

    outlist = list()
    for (ID, sym) in fl:
        target_name = symtab.make_target_name()
        symtab.declare(sym, ('INTEGER', target_name))
        outlist.append(('ADDR', target_name))
    return ('LIST', outlist)
def vardecl_stmt(node):

    (VARDECL, (ID, name), init_val) = node

    t = walk(init_val)
    target_name = symtab.make_target_name()
    symtab.declare(name, ('INTEGER', target_name))
    if not symtab.in_function:
        symtab.global_vars += [(target_name, 8)]

    return ('ASSIGN', ('ADDR', target_name), t)
Esempio n. 7
0
def declare_formal_args(formal_args, actual_val_args):
    '''
    Walk the formal argument list and declare the identifiers on that
    list using the corresponding actual args as initial values.
    NOTE: this is where we implement by-value argument passing
    '''
    (LIST, fl) = formal_args
    (LIST, avl) = actual_val_args

    if len(fl) != len(avl):
        raise ValueError("actual and formal argument lists do not match")

    for ((ID, f), v) in zip(fl, avl):
        symtab.declare(f, v)
def fundecl_stmt(node):

    (FUNDECL, (ID, name), arglist, body) = node

    # we don't need the function body - abbreviated function value
    funval = ('FUNVAL', arglist)
    symtab.declare(name, funval)

    symtab.enter_function()
    new_arglist = declare_formal_args(arglist)
    new_body = walk(body)
    frame_size = symtab.get_frame_size()
    symtab.exit_function()

    return ('FUNDEF', ('ADDR', name), new_arglist, new_body, ('FRAMESIZE',
                                                              frame_size))
def declare_temp():
    name = make_temp_name()
    target_name = symtab.make_target_name()
    symtab.declare(name, ('INTEGER', target_name))
    return target_name