def reduceCall(callNode, value): # construct the value node valueNode = symbol("constant")(callNode.get("line"), callNode.get("column")) valueNode = reducer.set_node_type_from_value(valueNode, value) # put it in place of the callNode # print "optimizing: .get()" callNode.parent.replaceChild(callNode, valueNode) return valueNode
def reduceCall(callNode, value): # construct the value node valueNode = symbol("constant")(callNode.get("line"), callNode.get("column")) valueNode = reducer.set_node_type_from_value(valueNode, value) # put it in place of the callNode #print "optimizing: .get()" callNode.parent.replaceChild(callNode, valueNode) return valueNode
def visit_Literal(self, enode): n = new_symbol("constant", enode) # have to sort out RegExp literals if enode["value"] == {}: # Esprima 1.0.4 represents regexp's as empty map in Json!, so i have # to fall back to the "raw" property. # the online demo esprima.org/demo/parse.html has the regex as a # string in "value" directly!? n = treegenerator.parse(enode["raw"], expr=True) # need esparse --raw here!! else: n = reducer.set_node_type_from_value(n, enode["value"]) return n
def visit_Literal(self, enode): n = new_symbol("constant", enode) # have to sort out RegExp literals if enode["value"] == {}: # Esprima 1.0.4 represents regexp's as empty map in Json!, so i have # to fall back to the "raw" property. # the online demo esprima.org/demo/parse.html has the regex as a # string in "value" directly!? n = treegenerator.parse(enode["raw"], expr=True) # need esparse --raw here!! else: n = reducer.set_node_type_from_value(n, enode["value"]) return n