本文整理汇总了Python中PE.make方法的典型用法代码示例。如果您正苦于以下问题:Python PE.make方法的具体用法?Python PE.make怎么用?Python PE.make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PE
的用法示例。
在下文中一共展示了PE.make方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insertAppend
# 需要导入模块: import PE [as 别名]
# 或者: from PE import make [as 别名]
def insertAppend(C6, v, e) :
"""appends e to the end of array/list v in the heap.
Does the same actions as an insertAssign to an indexed array,
but preserves more heap info since the append does not produce
any aliases within v
params : C6; v - a vartee; e - an etree
"""
sigma = C6["store"]
heap = C6["heap"]
vname = v[1]
vold = Parse.makeOldVar(v)
if lookupType(C6, vname) != "array" :
error("cannot append to a non-list/array")
else :
loc = PE.peToTuple(sigma[vname])
length = heap[loc][0]
newlength = PE.add(length, PE.make(1))
vector = heap[loc][1]
# assign original to v_old:
sigma[vold[1]] = sigma[vname]
# make copy for the new value of v:
copy = {}
for k in vector :
copy[k] = vector[k]
newloc = PE.make(PE.makeSym())
rhs = PE.evall(C6, e)
copy[ PE.peToTuple(length) ] = rhs
sigma[vname] = newloc
heap[ PE.peToTuple(newloc) ] = (newlength, copy)
示例2: copyWithoutStore
# 需要导入模块: import PE [as 别名]
# 或者: from PE import make [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
示例3: insertAssign
# 需要导入模块: import PE [as 别名]
# 或者: from PE import make [as 别名]
def insertAssign(C6, v, etree):
"""updates the store of C6 with an assignment.
If v already exists in C6's store, saves former value as v_old
for later use in proof reasoning.
params: v - has form, ["var", s] or ["index", ["var", s], etree]
etree - another etree, to be assigned to the var.
"""
sigma = C6["store"]
heap = C6["heap"]
badvars = C6["novars"]
if v[0] == "var" : vtree = v
elif v[0] == "index" : vtree = v[1]
vold = Parse.makeOldVar(vtree) # ["var", vname_old]
# first, check if we are allowed to update v:
if (vtree in badvars) :
error("you may not update a protected global var outside of its maintenance function")
return
# if possible, rename current value of var v as v_old:
if v[0] == "var" and v[1] in sigma : # and lookupType(C6, v[1]) != "array":
sigma[vold[1]] = sigma[v[1]] # assign v's current value to v_old
elif v[0] == "index" and lookupType(C6, v[1][1]) == "array":
vname = v[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]
# assign original to v_old and copy to v :
sigma[vold[1]] = sigma[vname]
newloc = PE.make(PE.makeSym())
sigma[vname] = newloc
heap[ PE.peToTuple(newloc) ] = (length, copy)
# (later, vold will be erased from sigma....)
# now, eval assignment's rhs and store it into v:
rhs = PE.evall(C6, etree)
if v[0] == "var": # simple var
sigma[v[1]] = rhs
elif v[0] == "index": # an array/list reference
# eval index expression (NOTE: no nested indexing allowed):
indexpe = PE.evall(C6, v[2])
# save values in sigma[vname][1] provably distinct from vname[index]:
vname = v[1][1]
if vname not in sigma or lookupType(C6, vname) != "array" :
error(vname + " is not an array in the store")
#sigma[vname] = PE.makeArray()
else :
vmap = heap[PE.peToTuple(sigma[vname])][1]
saveDistinctElements(C6, vmap, indexpe)
vmap[PE.peToTuple(indexpe)] = rhs
示例4: reset
# 需要导入模块: import PE [as 别名]
# 或者: from PE import make [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)