Example #1
0
    def run(self, node):
        self.bounds = []
        self.unbounds = []

        generictree = super().run(node)

        bounds = du.genDTuple(self.bounds)

        unbounds = du.genDTuple(self.unbounds)

        return generictree, bounds, unbounds
Example #2
0
 def helper(self, target, id):
     syms = st.gatherSymbols(target)
     
     newtarget = du.genDPatTuple([dha.PatVar(s, dha.P_UNKNOWN) for s in syms])
     
     # Generate wildcard comprehension.
     elt = du.genDTuple([dha.Name(s) for s in syms])
     enumtarget = dka.copy(target)
     st.cleanPatterns(enumtarget)
     WildcardFiller().run(enumtarget)
     enum = dha.RelEnum(enumtarget, id)
     comp = dha.RelSetComp(elt, [enum], [], dka.Symtab())
     
     num = next(wildcard_uid)
     
     repldict = {s: dha.VSymbol(s.name + '_W' + num)
                 for s in syms}
     st.replaceSymbols(comp, repldict)
     
     newid = dha.VSymbol(id.name + '_W' + num)
     
     invdef = dha.InvDef(newid, comp)
     
     ### Need a more robust way to do this part.
     oldccb = self.code_callback
     newccb = \
         (lambda ccb: oldccb(ccb) + [invdef]
             if ccb is self.CCB_NORMAL or
                ccb is self.CCB_LOOP_ENTRY
             else [])
     
     return newtarget, newid, newccb
Example #3
0
File: inc.py Project: sadboy/AsdlPy
 def genDSetBlock(self, enumnum, upvalexpr):
     compnode = self.compnode
     enumvars = self.info.enumvars
     
     enums = dka.copy(compnode.enums)
     conds = dka.copy(compnode.conds)
     st.cleanPatterns(enums)
     
     suffix = '_up' + str(enumnum)
     
     wittarget = dka.copy(enums[enumnum].target)
     upval = dka.copy(upvalexpr)
     upvalassign = dha.Assign(wittarget, upval)
     elt = du.genDTuple([s for s in enumvars])
     
     if len(enums) > 1:
         maintenums = enums[:enumnum] + enums[enumnum+1:]
         maintcomp = dha.RelSetComp(elt, maintenums, conds, dka.Symtab())
         maintupdate = dha.SetUpdate(self.diffsym, dha.UpUnionNS(), maintcomp)
     else:
         maintupdate = dha.SetUpdate(self.diffsym, dha.UpAddNS(), elt)
     
     code = [upvalassign, maintupdate]
     
     repldict = {s: dha.VSymbol(s.name + suffix)
                 for s in enumvars}
     st.replaceSymbols(code, repldict)
     
     return code
Example #4
0
    def run(self, node):
        self.bounds = []
        self.unbounds = []

        mask = super().run(node)

        bounds = du.genDTuple(self.bounds)

        unbounds = du.genDPatTuple(self.unbounds)

        return mask, bounds, unbounds
Example #5
0
 def visit_InvDef(self, node):
     dka.assertnodetype(node.value, dha.RelSetComp)
     
     self.generic_visit(node)
     
     compnode = node.value
     info = node.id.info
     params = info.enumparams
     repldict = {sym: dha.VSymbol(sym.name + '_local')
                 for sym in params}
     
     if len(params) > 0:
         paramtup = du.genDTuple([dha.Name(sym) for sym in params])
         newelt = dha.Tuple([paramtup, dka.copy(compnode.elt)])
         compnode.elt = newelt
     else:
         pass
     
     st.cleanPatterns(compnode)
     st.replaceSymbols(compnode, repldict)