示例#1
0
def search(node, variantMap, fileId_="", verb=False):
    if not variantMap:
        return False

    global verbose
    global fileId
    verbose = verb
    fileId = fileId_
    modified = False

    variantNodes = findVariantNodes(node)
    for variantNode in variantNodes:
        variantMethod = variantNode.toJS(pp).rsplit(".", 1)[1]
        callNode = treeutil.selectNode(variantNode, "../..")
        if variantMethod in ["select"]:
            modified = processVariantSelect(callNode, variantMap) or modified
        elif variantMethod in ["get"]:
            modified = processVariantGet(callNode, variantMap) or modified
        elif variantMethod in ["filter"]:
            modified = processVariantFilter(callNode, variantMap) or modified

    # reduce decidable subtrees
    if modified:
        for cld in node.children[:]:
            new_cld = reducer.ast_reduce(cld)
            node.replaceChild(cld, new_cld)

    return modified
示例#2
0
def search(node, variantMap, fileId_="", verb=False):
    if not variantMap:
        return False

    global verbose
    global fileId
    verbose = verb
    fileId = fileId_
    modified = False

    variantNodes = findVariantNodes(node)
    for variantNode in variantNodes:
        variantMethod = variantNode.toJS(pp).rsplit('.', 1)[1]
        callNode = treeutil.selectNode(variantNode, "../..")
        if variantMethod in ["select"]:
            modified = processVariantSelect(callNode, variantMap) or modified
        elif variantMethod in ["get"]:
            modified = processVariantGet(callNode, variantMap) or modified
        elif variantMethod in ["filter"]:
            modified = processVariantFilter(callNode, variantMap) or modified

    # reduce decidable subtrees
    if modified:
        for cld in node.children[:]:
            new_cld = reducer.ast_reduce(cld)
            node.replaceChild(cld, new_cld)

    return modified
示例#3
0
 def _concatOperation(self, node):
     console = self.context['console']
     result = ""
     reduced_node = reducer.ast_reduce(node)
     if reduced_node.type == 'constant' and reduced_node.get("constantType",'') == "string":
         result = reduced_node.get('value')
     else:
         console.warn("Cannot extract string argument to translation method (%s:%s): %s" % (
             treeutil.getFileFromSyntaxItem(node), node.get("line"), node.toJS(None)))
     return result
 def _concatOperation(self, node):
     console = self.context['console']
     result = ""
     reduced_node = reducer.ast_reduce(node)
     if reduced_node.type == 'constant' and reduced_node.get("constantType",'') == "string":
         result = reduced_node.get('value')
     else:
         console.warn("Cannot extract string argument to translation method (%s:%s): %s" % (
             treeutil.getFileFromSyntaxItem(node), node.get("line"), node.toJS(None)))
     return result