def processVariantGet(callNode, variantMap): treeModified = False # Simple sanity checks params = callNode.getChild("params") if len(params.children) != 1: log( "Warning", "Expecting exactly one argument for qx.core.Environment.get. Ignoring this occurrence.", params) return treeModified firstParam = params.getChildByPosition(0) if not isStringLiteral(firstParam): # warning is currently covered in parsing code #log("Warning", "First argument must be a string literal! Ignoring this occurrence.", firstParam) return treeModified # skipping "relative" calls like "a.b.qx.core.Environment.get()" qxIdentifier = treeutil.selectNode(callNode, "operand/variable/identifier[1]") if not treeutil.checkFirstChainChild(qxIdentifier): log( "Warning", "Skipping relative qx.core.Environment.get call. Ignoring this occurrence ('%s')." % treeutil.findChainRoot(qxIdentifier).toJavascript()) return treeModified variantKey = firstParam.get("value") if variantKey in variantMap: confValue = variantMap[variantKey] else: return treeModified # Replace the .get() with its value resultNode = reduceCall(callNode, confValue) treeModified = True # Reduce any potential operations with literals (+3, =='hugo', ?a:b, ...) treeMod = True while treeMod: resultNode, treeMod = reduceOperation(resultNode) # Reduce a potential condition _ = reduceLoop(resultNode) return treeModified
def depsItem_from_node(self, full_name, var_node): # attribute (e.g. method) attribute = '' # requestor (class id of the current tree) requestor = self.file_name # line (where requested) line = var_node.get("line",False) or -1 # is it a static load-time dependency? isLoadDep = self.is_static_loaddep(var_node) depsItem = DependencyItem(full_name, attribute, requestor, line, isLoadDep) # is the var a call operand var_root = treeutil.findChainRoot(var_node) depsItem.isCall = var_root.hasParentContext("call/operand") # depsItem.needsRecursion can only be set in transitive analysis return depsItem
def processVariantGet(callNode, variantMap): treeModified = False # Simple sanity checks params = callNode.getChild("params") if len(params.children) != 1: log("Warning", "Expecting exactly one argument for qx.core.Environment.get. Ignoring this occurrence.", params) return treeModified firstParam = params.getChildByPosition(0) if not isStringLiteral(firstParam): log("Warning", "First argument must be a string literal! Ignoring this occurrence.", firstParam) return treeModified # skipping "relative" calls like "a.b.qx.core.Environment.get()" qxIdentifier = treeutil.selectNode(callNode, "operand/variable/identifier[1]") if not treeutil.checkFirstChainChild(qxIdentifier): log( "Warning", "Skipping relative qx.core.Environment.get call. Ignoring this occurrence ('%s')." % treeutil.findChainRoot(qxIdentifier).toJavascript(), ) return treeModified variantKey = firstParam.get("value") if variantKey in variantMap: confValue = variantMap[variantKey] else: return treeModified # Replace the .get() with its value resultNode = reduceCall(callNode, confValue) treeModified = True # Reduce any potential operations with literals (+3, =='hugo', ?a:b, ...) treeMod = True while treeMod: resultNode, treeMod = reduceOperation(resultNode) # Reduce a potential condition _ = reduceLoop(resultNode) return treeModified
def depsItem_from_node(self, full_name, var_node): # attribute (e.g. method) attribute = '' # requestor (class id of the current tree) requestor = self.file_name # line (where requested) line = var_node.get("line", False) or -1 # is it a static load-time dependency? isLoadDep = self.is_static_loaddep(var_node) depsItem = DependencyItem(full_name, attribute, requestor, line, isLoadDep) # is the var a call operand var_root = treeutil.findChainRoot(var_node) depsItem.isCall = var_root.hasParentContext("call/operand") # depsItem.needsRecursion can only be set in transitive analysis return depsItem