Esempio n. 1
0
def collectAllVars(compiler, cmdline_args, src, dotO, variables, outvars=[]):
    from var import collectVars
    from compile import preprocess
    from parse import normalize, getGlobalText, clearAllAttributes, clearAllPounds
    from path import picklePath
    import pickle
    import sys
    import os

    #make a relative path
    fscope = dotO.replace(".libs/", "")
    #make C++ valid
    fscope = fscope.replace(".", "_").replace("/", "_")

    rc, fulltext = preprocess(compiler, cmdline_args, src)
    if not rc == 0:
        return rc

    #fulltext = normalize(fulltext)

    depth0 = getGlobalText(fulltext)
    depth0 = clearAllPounds(depth0)
    depth0 = clearAllAttributes(depth0)

    fxnargs = FxnArgs()
    fxnargs.depthN = getFunctionBodies(fulltext)
    fxnargs.depth0 = depth0
    fxnargs.fulltext = fulltext

    collectVars(fxnargs, variables, outvars, fscope)

    return rc
Esempio n. 2
0
def collectAllVars(compiler, cmdline_args, src, dotO, variables, outvars=[]):
    from var import collectVars
    from compile import preprocess
    from parse import normalize, getGlobalText, clearAllAttributes, clearAllPounds
    from path import picklePath
    import pickle
    import sys
    import os

    #make a relative path
    fscope = dotO.replace(".libs/", "")
    #make C++ valid
    fscope = fscope.replace(".","_").replace("/","_")

    rc, fulltext = preprocess(compiler, cmdline_args, src)
    if not rc == 0:
        return rc

    #fulltext = normalize(fulltext)

    depth0 = getGlobalText(fulltext)
    depth0 = clearAllPounds(depth0)
    depth0 = clearAllAttributes(depth0)

    fxnargs = FxnArgs()
    fxnargs.depthN = getFunctionBodies(fulltext)
    fxnargs.depth0 = depth0
    fxnargs.fulltext = fulltext

    collectVars(fxnargs, variables, outvars, fscope)

    return rc
Esempio n. 3
0
def refactor(compiler, cmdline_args, src, dotO, variables):
    from fakepath import tmpPath, refactoredPath, picklePath, preprocessedPath, dumpPath
    from fakeparse import normalize, getGlobalText, clearAllPounds, getFunctionBodies
    from var import replVars, collectVars
    from compile import preprocess, compileRefactored
    from collect import collectAllVars
    import sys, os, pickle, re

    tmpfile = tmpPath(src, dotO)
    dumpfile = preprocessedPath(src, dotO)
    
    srctext = open(src).read()
    rc, fulltext = preprocess(compiler, cmdline_args, src)
    if not rc == 0:
        sys.stderr.write("preprocess of %s failed\n" % src)
        return rc

    open(dumpfile, "w").write(fulltext)
    subtext = fulltext



    #cleantext = normalize(subtext)
    cleantext = subtext
    depthN = getFunctionBodies(cleantext)
    depth0 = getGlobalText(cleantext)
    depth0 = clearAllPounds(depth0)
    already_done = {}
    fxnargs = FxnArgs()
    fxnargs.fulltext = subtext
    fxnargs.depth0 = depth0
    fxnargs.depthN = depthN

    dumpfile = dumpPath(src, dotO, "depth0_")
    open(dumpfile, "w").write(depth0)

    outvars = []
    #make a relative path
    fscope = dotO.replace(".libs/", "")
    #make C++ valid
    fscope = fscope.replace(".","_").replace("/","_")
    collectVars(fxnargs, variables, outvars, fscope)

    subtext = replVars(subtext, fxnargs, outvars)

    subtext = clearAllPounds(subtext)

    dumpfile = refactoredPath(src, dotO)
    fobj = open(dumpfile,"w")
    fobj.write(subtext)
    fobj.close()

    return refactorCompile(compiler, cmdline_args, src, dotO)
Esempio n. 4
0
def refactor(compiler, cmdline_args, src, dotO, variables):
    from fakepath import tmpPath, refactoredPath, picklePath, preprocessedPath, dumpPath
    from fakeparse import normalize, getGlobalText, clearAllPounds, getFunctionBodies
    from var import replVars, collectVars
    from compile import preprocess, compileRefactored
    from collect import collectAllVars
    import sys, os, pickle, re

    tmpfile = tmpPath(src, dotO)
    dumpfile = preprocessedPath(src, dotO)

    srctext = open(src).read()
    rc, fulltext = preprocess(compiler, cmdline_args, src)
    if not rc == 0:
        sys.stderr.write("preprocess of %s failed\n" % src)
        return rc

    open(dumpfile, "w").write(fulltext)
    subtext = fulltext

    #cleantext = normalize(subtext)
    cleantext = subtext
    depthN = getFunctionBodies(cleantext)
    depth0 = getGlobalText(cleantext)
    depth0 = clearAllPounds(depth0)
    already_done = {}
    fxnargs = FxnArgs()
    fxnargs.fulltext = subtext
    fxnargs.depth0 = depth0
    fxnargs.depthN = depthN

    dumpfile = dumpPath(src, dotO, "depth0_")
    open(dumpfile, "w").write(depth0)

    outvars = []
    #make a relative path
    fscope = dotO.replace(".libs/", "")
    #make C++ valid
    fscope = fscope.replace(".", "_").replace("/", "_")
    collectVars(fxnargs, variables, outvars, fscope)

    subtext = replVars(subtext, fxnargs, outvars)

    subtext = clearAllPounds(subtext)

    dumpfile = refactoredPath(src, dotO)
    fobj = open(dumpfile, "w")
    fobj.write(subtext)
    fobj.close()

    return refactorCompile(compiler, cmdline_args, src, dotO)