示例#1
0
def evar(var, domain):
  def mixVarWithLoc(loc):
    newVar = copy.deepcopy(var)
    newVar["label"] = newVar["label"].replace("%loc",loc)
    checkForAlgebraicExpressions(newVar["expression"],["%loc"],[locations[loc]],str(0))
    solveAlgebraicExpressions(newVar["expression"])
    newVar["expression"] = checkForChains(newVar["expression"])
    insertLocInExpression(newVar["expression"],loc)
    return newVar
  
  def mixVarWithOrgDst(matrixCell):
    (org, dst, r) = matrixCell
    if (options.fullMatrix == False and r == 0):
      return nullInstruction
    if (org != dst):
      newVar = copy.deepcopy(var)
      newVar["label"] = newVar["label"].replace("%org",org)
      newVar["label"] = newVar["label"].replace("%dst",dst)
      checkForAlgebraicExpressions(newVar["expression"],["%org","%dst"],[locations[org],locations[dst]],str(r))
      solveAlgebraicExpressions(newVar["expression"])
      newVar["expression"] = checkForChains(newVar["expression"])
      insertOrgInExpression(newVar["expression"],org)
      insertDstInExpression(newVar["expression"],dst)
      return newVar
    else:
      return nullInstruction

  varBuilder = None
  if (domain[0].__class__ == "".__class__): #if it is string, it is just loc
    varBuilder = mixVarWithLoc
  else: #the type is tuple, it is a matrix
    varBuilder = mixVarWithOrgDst
  for r in map(varBuilder, domain):
    printing.printVar(r)