예제 #1
0
파일: toplevel.py 프로젝트: bl0b/cppy
def func_signature(ast):
    print ast
    params = []
    cv = None
    for x in ast[1:]:
        if x[0] == 'func_type':
            ftype = x[1]
        elif x[0] == 'func_id':
            print "FUNC ID", x[1:]
            if type(x[1]) is Function:
                fid = x[1].name
            else:
                fid = x[1][1]
        elif x[0] == 'func_param':
            params.append(x[1])
        elif x[0] == 'opt_cv_qualifier':
            cv = (a[0] for a in x[1:])
    print "ftype", ftype
    print "fid", fid
    print "fparam", params
    f = id_engine.resolve(fid, True)
    if f is Entity.Null:
        f = Function(fid, id_engine.current())
    sig = f.create_signature(ftype, params, cv)
    id_engine.enter(f.scopes[sig])
    return ('func_signature', fid, sig)
예제 #2
0
파일: toplevel.py 프로젝트: bl0b/cppy
def NAMESPACE_ENTER(ast):
    sym = ast[1][1]
    n = id_engine.resolve(sym, True)
    print "enter namespace ?", n
    if n is Entity.Null:
        n = Namespace(sym, id_engine.current())
        print "new namespace !", n
    id_engine.enter(n)
    return id_engine.current()
예제 #3
0
파일: toplevel.py 프로젝트: bl0b/cppy
def _MARK_STRUC(ast):
    if ast[2][0] == 'symbol':
        sym = ast[2][1]
    else:
        sym = make_anon()
    ret = id_engine.resolve(sym)
    if ret is Entity.Null:
        ret = StructuredType(sym, id_engine.current())
    print "_MARK_STRUC current =", id_engine.current()
    #id_engine.enter(ret)
    return ret
예제 #4
0
파일: toplevel.py 프로젝트: bl0b/cppy
def _ENTER_STRUC(ast):
    if ast[2][0] == 'symbol':
        sym = ast[2][1]
        ret = id_engine.resolve(sym)
    else:
        sym = make_anon()
        ret = Entity.Null
    if ret is Entity.Null:
        ret = StructuredType(sym, id_engine.current())
    print "_ENTER_STRUC current =", id_engine.current()
    id_engine.enter(ret)
    print "_ENTER_STRUC in_struc =", id_engine.current()
    return ret
예제 #5
0
파일: expressions.py 프로젝트: bl0b/cppy
def expr_p1(ast):
    id = ast[-1]
    spec = len(id) == 3 and id[-1] or None
    print
    print "EXPR_P1", len(ast), ast, id[1][1]
    if len(ast) == 2:
        what = id_engine.resolve(id[1][1], False)
    elif len(ast) == 3:
        what = id_engine.root().resolve(id[1][1], False)
    else:
        what = ast[1].resolve(id[1][1], True)
    if spec:
        return what.match_specialization(spec)
    else:
        return what
예제 #6
0
파일: toplevel.py 프로젝트: bl0b/cppy
def _ASSERT_NEW_SYMBOL(ast):
    if id_engine.resolve(ast[1][1]) is not Entity.Null:
        return None
    return ast[1]