当前位置: 首页>>代码示例>>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;未经允许,请勿转载。