@Override public Node getLValue() { // As far as we know, only the property name matters so the target can be an object literal return IR.getprop(IR.objectlit(), memberFunctionDef.getString()); } }
Node processTypeQuery(TypeQueryTree tree) { Iterator<String> segmentsIt = tree.segments.iterator(); Node node = newStringNode(Token.NAME, segmentsIt.next()); while (segmentsIt.hasNext()) { node = IR.getprop(node, IR.string(segmentsIt.next())); } return cloneProps(new TypeDeclarationNode(Token.TYPEOF, node)); }
RecordTypePropertyDefinition(Node name) { super(IR.getprop(IR.objectlit(), name.cloneNode()), /** isExtern */ true); Preconditions.checkArgument(name.isString()); }
RecordTypePropertyDefinition(Node name) { super(IR.getprop(IR.objectlit(), name.cloneNode()), /** isExtern */ true); checkArgument(name.isString()); }
/** * Creates a property access on the {@code context} tree. */ public static Node newPropertyAccess(AbstractCompiler compiler, Node context, String name) { Node propNode = IR.getprop(context, IR.string(name)); if (compiler.getCodingConvention().isConstantKey(name)) { propNode.putBooleanProp(Node.IS_CONSTANT_NAME, true); } return propNode; }
private Node getpropInferringJSType(Node receiver, String propName) { Node getprop = IR.getprop(receiver, propName); JSType receiverType = receiver.getJSType(); if (receiverType == null) { return getprop; } JSType getpropType = receiverType.findPropertyType(propName); if (getpropType == null && receiverType instanceof FunctionType) { getpropType = ((FunctionType) receiverType).getPropertyType(propName); } return getprop.setJSType(getpropType); }
Node createGetProp(Node receiver, String propertyName) { Node result = IR.getprop(receiver, IR.string(propertyName)); if (isAddingTypes()) { result.setJSType(getJsTypeForProperty(receiver, propertyName)); } return result; }
/** * Creates a property access on the {@code context} tree. */ public static Node newPropertyAccess(AbstractCompiler compiler, Node context, String name) { Node propNode = IR.getprop(context, IR.string(name)); if (compiler.getCodingConvention().isConstantKey(name)) { propNode.putBooleanProp(Node.IS_CONSTANT_NAME, true); } return propNode; }
Node buildLineDeclaration(String uri, int lineNo) { Node coverVar = IR.name("_$jscoverage"); Node path = IR.string(uri); Node getURI = IR.getelem(coverVar, path); Node prop = IR.string("branchData"); Node propGet = IR.getprop(getURI, prop); Node number = IR.string("" + lineNo); return IR.getelem(propGet, number); }
Node buildLineDeclaration(String uri, int lineNo) { Node coverVar = IR.name("_$jscoverage"); Node path = IR.string(uri); Node getURI = IR.getelem(coverVar, path); Node prop = IR.string("branchData"); Node propGet = IR.getprop(getURI, prop); Node number = IR.string("" + lineNo); return IR.getelem(propGet, number); }
Node buildLineNumberExpression(int lineNumber, String fileName, String identifier) { Node coverVar = IR.name("_$jscoverage"); Node path = IR.string(fileName); Node getURI = IR.getelem(coverVar, path); Node prop = IR.string(identifier); Node propGet = IR.getprop(getURI, prop); Node number = IR.number(lineNumber); return IR.getelem(propGet, number); }
/** Creates node that access a specified field of the current context. */ Node getContextField(Node sourceNode, String fieldName) { return withType( IR.getprop( getJsContextNameNode(sourceNode), IR.string(fieldName).useSourceInfoFrom(sourceNode)), shouldAddTypes ? contextType.getPropertyType(fieldName) : null) .useSourceInfoFrom(sourceNode); }
public Node buildLineAndConditionCall(String uri, int lineNo, int conditionNo) { Node indexLineNumber = buildLineDeclaration(uri, lineNo); Node conditionNumberLiteral = IR.number(conditionNo); Node indexConditionNumber = IR.getelem(indexLineNumber, conditionNumberLiteral); Node initCall = IR.string("ranCondition"); Node propertyName = IR.getprop(indexConditionNumber, initCall); Node result = IR.name("result"); Node fnCall = IR.call(propertyName, result); return IR.exprResult(fnCall); }
private Node createMathPowCall() { return IR.call( IR.getprop( IR.name("Math").setJSType(mathType), // Force wrapping. IR.string("pow").setJSType(stringType)) .setJSType(mathPowType)) .setJSType(numberType); } }
public Node buildLineAndConditionInitialisation(String uri, int lineNo, int conditionNo, int position, int length) { Node indexLineNumber = buildLineDeclaration(uri, lineNo); Node conditionNumberLiteral = IR.number(conditionNo); Node indexConditionNumber = IR.getelem(indexLineNumber, conditionNumberLiteral); Node positionLiteral = IR.number(position); Node lengthLiteral = IR.number(length); Node initCall = IR.string("init"); Node propertyName = IR.getprop(indexConditionNumber, initCall); Node fnCall = IR.call(propertyName, positionLiteral, lengthLiteral); return IR.exprResult(fnCall); }
public Node buildLineAndConditionInitialisation(String uri, int lineNo, int conditionNo, int position, int length) { Node indexLineNumber = buildLineDeclaration(uri, lineNo); Node conditionNumberLiteral = IR.number(conditionNo); Node indexConditionNumber = IR.getelem(indexLineNumber, conditionNumberLiteral); Node positionLiteral = IR.number(position); Node lengthLiteral = IR.number(length); Node initCall = IR.string("init"); Node propertyName = IR.getprop(indexConditionNumber, initCall); Node fnCall = IR.call(propertyName, positionLiteral, lengthLiteral); return IR.exprResult(fnCall); }
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (n.isReturn() && n.hasChildren()) { Node retVal = n.getFirstChild(); n.removeChild(retVal); parent.replaceChild(n, IR.exprResult( IR.assign( IR.getprop(IR.name("module"), IR.string("exports")), retVal)) .useSourceInfoFromForTree(n)); } } }
@Override public void visit(NodeTraversal t, Node n, Node parent) { if (n.isReturn() && n.hasChildren()) { Node retVal = n.getFirstChild(); n.removeChild(retVal); parent.replaceChild(n, IR.exprResult( IR.assign( IR.getprop(IR.name("module"), IR.string("exports")), retVal)) .useSourceInfoFromForTree(n)); } } }
private void addExtern(String export) { Node objectPrototype = NodeUtil.newQName(compiler, "Object.prototype"); JSType objCtor = compiler.getTypeRegistry().getNativeType(JSTypeNative.OBJECT_FUNCTION_TYPE); objectPrototype.getFirstChild().setJSType(objCtor); Node propstmt = IR.exprResult(IR.getprop(objectPrototype, IR.string(export))); propstmt.useSourceInfoFromForTree(getSynthesizedExternsRoot()); propstmt.setOriginalName(export); getSynthesizedExternsRoot().addChildToBack(propstmt); compiler.reportChangeToEnclosingScope(propstmt); }