Пример #1
0
def generate_bsvcpp(filelist, project_dir, bsvdefines, interfaces, bsvpath):
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(), inputfile, bsvdefines, bsvpath)
    ## code generation pass
    ilist = []
    for i in interfaces:
        ifc = globalv.globalvars.get(i)
        if not ifc:
            print('Connectal: Unable to locate the interface:', i)
            for keys in globalv.globalvars:
                print('    ', keys)
            sys.exit(1)
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ilist.append(ifc)
        for ditem in ifc.decls:
            for pitem in ditem.params:
                thisType = pitem.type
                p = globalv.globalvars.get(thisType.name)
                if p and thisType.params and p.params:
                    myName = '%sL_%s_P' % (thisType.name, '_'.join(
                        [t.name for t in thisType.params if t]))
                    pitem.oldtype = pitem.type
                    pitem.type = AST.Type(myName, [])
                    if not globalv.globalvars.get(myName):
                        globalv.add_new(
                            AST.TypeDef(
                                p.tdtype.instantiate(
                                    dict(zip(p.params, thisType.params))),
                                myName, []))
    jsondata = AST.serialize_json(ilist, globalimports, bsvdefines)
    if project_dir:
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, False, jsondata)
Пример #2
0
def generate_bsvcpp(filelist, project_dir, bsvdefines, interfaces):
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(),inputfile, bsvdefines)
    ## code generation pass
    ilist = []
    for i in interfaces:
        ifc = globalv.globalvars.get(i)
        if not ifc:
            print 'Connectal: Unable to locate the interface:', i
            for keys in globalv.globalvars:
                print '    ', keys
            sys.exit(1)
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ilist.append(ifc)
        for ditem in ifc.decls:
            for pitem in ditem.params:
                thisType = pitem.type
                p = globalv.globalvars.get(thisType.name)
                if p and thisType.params and p.params:
                    myName = '%sL_%s_P' % (thisType.name, '_'.join([t.name for t in thisType.params if t]))
                    pitem.oldtype = pitem.type
                    pitem.type = AST.Type(myName, [])
                    if not globalv.globalvars.get(myName):
                        globalv.add_new(AST.TypeDef(p.tdtype.instantiate(dict(zip(p.params, thisType.params))), myName, []))
    jsondata = AST.serialize_json(ilist, globalimports, bsvdefines)
    if project_dir:
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, False, jsondata)
Пример #3
0
def p_packageStmt(p):
    '''packageStmt : interfaceDecl
                   | typeClassDecl
                   | functionDef
                   | instanceDecl
                   | varDecl SEMICOLON
                   | varAssign SEMICOLON
                   | moduleDef
                   | macroDef
                   | typeDef
                   | importBviDef'''
    globalv.add_new(p[1])
Пример #4
0
def p_packageStmt(p):
    '''packageStmt : interfaceDecl
                   | typeClassDecl
                   | functionDef
                   | instanceDecl
                   | varDecl SEMICOLON
                   | varAssign SEMICOLON
                   | moduleDef
                   | macroDef
                   | typeDef
                   | importBviDef'''
    globalv.add_new(p[1])