當前位置: 首頁>>代碼示例>>Python>>正文


Python PE.makeArray方法代碼示例

本文整理匯總了Python中PE.makeArray方法的典型用法代碼示例。如果您正苦於以下問題:Python PE.makeArray方法的具體用法?Python PE.makeArray怎麽用?Python PE.makeArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PE的用法示例。


在下文中一共展示了PE.makeArray方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: copyWithoutStore

# 需要導入模塊: import PE [as 別名]
# 或者: from PE import makeArray [as 別名]
def copyWithoutStore(C6, funname, scalars, arrays, localglobals, brokeninvariants) :
    """makes a 2-deep copy of the functions, global invariants, novars
       within  C6. 
       Used to initialize a C6 for a function body for function,  funname

       Makes store and heap empty and places dummy scalar and array values
       in store based on  scalars  and  arrays .  Sets rels to []

       Subtracts  localglobals  from  ``novars'' list to denote that
                  these vars are mutable
       Revises  globalinvs list, removing brokeninvariants that are no longer
                  invariants because their vars are mutable
       Places  brokeninvariants  into  brokeninvs list

       params: C6;  
               funname : name of function
               scalars: vtree list of scalar vars;
               arrays: vtree list of array vars
               localglobals : vtree list of global vars that can be mutated
               brokeninvariants: invariants that mention
                      local globals, a btree list
       returns new C6 configuration
    """
    newC6 = empty()

    fcns = C6["funs"]
    for f in fcns :
        newC6["funs"][f] = fcns[f]

    newC6["globalinvs"] = [ g for g in C6["globalinvs"] \
                                       if g not in brokeninvariants ] 
    newC6["brokeninvs"] = brokeninvariants

    newC6["defs"] = [ d  for d in C6["defs"] ]
    newC6["novars"] = [ g for g in C6["novars"] if g not in localglobals]
    newC6["whoami"] = funname

    for v in scalars :
        newC6["store"][v[1]] = PE.make(PE.makeSym())
    for v in arrays :
        newloc = PE.make(PE.makeSym())
        newarray = PE.makeArray()
        newC6["store"][v[1]] = newloc
        newC6["heap"][PE.peToTuple(newloc)] = newarray

    return newC6
開發者ID:amgregoi,項目名稱:School,代碼行數:48,代碼來源:Tables.py

示例2: reset

# 需要導入模塊: import PE [as 別名]
# 或者: from PE import makeArray [as 別名]
def reset(C6, modified_vars) :
    """changes  C6's sigma so that new constants are generated for
       each var mentioned in modified_vars.

       param: modified_vars, a sequence of lhs-trees; can be either
              ["var", s] or ["index" ["var", s] pe].   IMPORTANT:
              in the latter case, the  etree  has been replaced by its pe-value
    """
    sigma = C6["store"]
    heap = C6["heap"]
    #print "In reset"
    #print "store=", sigma
    for m in modified_vars :
        if m[0] == "var" and lookupType(C6, m[1]) != "array" :  # simple var
            sigma[m[1]] = PE.make(PE.makeSym())

        elif m[0] == "var" and lookupType(C6, m[1]) == "array" :
            arrayname = m[1]
            newarray = PE.makeArray()
            newloc = PE.make(PE.makeSym())
            sigma[m[1]] = newloc
            heap[PE.peToTuple(newloc)] = newarray

        elif m[0] == "index" or m[0] == "len" :
            vname = m[1][1]
            loc = PE.peToTuple(sigma[vname])
            length = heap[loc][0]
            vector = heap[loc][1]
            # make copy:
            copy = {}
            for k in vector :
                copy[k] = vector[k]
            newloc = PE.make(PE.makeSym())
            if m[0] == "index" : # indexed var ["index" ["var", s] pe]
                saveDistinctElements(C6, copy, PE.evall(C6, m[2]))
            elif m[0] == "len":  # ["len", ["var", s]], as a result of append
                length = PE.make(PE.makeSym())

            sigma[vname] = newloc
            heap[PE.peToTuple(newloc)] = (length, copy)
開發者ID:amgregoi,項目名稱:School,代碼行數:42,代碼來源:Tables.py


注:本文中的PE.makeArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。