jdk.nashorn.internal.ir.AccessNode Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.AccessNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSONWriter.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property", accessNode.getProperty()); comma(); property("computed", false); return leave(); }
Example #2
Source File: TypeEvaluator.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #3
Source File: TypeEvaluator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #4
Source File: JSONWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property", accessNode.getProperty()); comma(); property("computed", false); return leave(); }
Example #5
Source File: TypeEvaluator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #6
Source File: JSONWriter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property", accessNode.getProperty()); comma(); property("computed", false); return leave(); }
Example #7
Source File: JSONWriter.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property", accessNode.getProperty()); comma(); property("computed", false); return leave(); }
Example #8
Source File: TypeEvaluator.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #9
Source File: JSONWriter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property"); accessNode.getProperty().accept(this); comma(); property("computed", false); return leave(); }
Example #10
Source File: TypeEvaluator.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #11
Source File: TypeEvaluator.java From hottub with GNU General Public License v2.0 | 6 votes |
private Object evaluateSafely(final Expression expr) { if (expr instanceof IdentNode) { return runtimeScope == null ? null : evaluatePropertySafely(runtimeScope, ((IdentNode)expr).getName()); } if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return evaluatePropertySafely((ScriptObject)base, accessNode.getProperty()); } return null; }
Example #12
Source File: JSONWriter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property"); accessNode.getProperty().accept(this); comma(); property("computed", false); return leave(); }
Example #13
Source File: JSONWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override public boolean enterAccessNode(final AccessNode accessNode) { enterDefault(accessNode); type("MemberExpression"); comma(); property("object"); accessNode.getBase().accept(this); comma(); property("property", accessNode.getProperty()); comma(); property("computed", false); return leave(); }
Example #14
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Verify an assignment expression. * @param op Operation token. * @param lhs Left hand side expression. * @param rhs Right hand side expression. * @return Verified expression. */ private Expression verifyAssignment(final long op, final Expression lhs, final Expression rhs) { final TokenType opType = Token.descType(op); switch (opType) { case ASSIGN: case ASSIGN_ADD: case ASSIGN_BIT_AND: case ASSIGN_BIT_OR: case ASSIGN_BIT_XOR: case ASSIGN_DIV: case ASSIGN_MOD: case ASSIGN_MUL: case ASSIGN_SAR: case ASSIGN_SHL: case ASSIGN_SHR: case ASSIGN_SUB: if (!(lhs instanceof AccessNode || lhs instanceof IndexNode || lhs instanceof IdentNode)) { return referenceError(lhs, rhs, env._early_lvalue_error); } if (lhs instanceof IdentNode) { if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, rhs, false); } verifyStrictIdent((IdentNode)lhs, "assignment"); } break; default: break; } // Build up node. return new BinaryNode(op, lhs, rhs); }
Example #15
Source File: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private Node leaveASSIGN(final BinaryNode binaryNode) { // If we're assigning a property of the this object ("this.foo = ..."), record it. final Expression lhs = binaryNode.lhs(); if (lhs instanceof AccessNode) { final AccessNode accessNode = (AccessNode) lhs; final Expression base = accessNode.getBase(); if (base instanceof IdentNode) { final Symbol symbol = ((IdentNode)base).getSymbol(); if(symbol.isThis()) { thisProperties.peek().add(accessNode.getProperty()); } } } return binaryNode; }
Example #16
Source File: Attr.java From nashorn with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveAccessNode(final AccessNode accessNode) { //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this, that //is why we can't set the access node base to be an object here, that will ruin access specialization //for example for a.x | 17. return end(ensureSymbol(Type.OBJECT, accessNode)); }
Example #17
Source File: Parser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private String getDefaultFunctionName() { if(!defaultNames.isEmpty()) { final Object nameExpr = defaultNames.peek(); if(nameExpr instanceof PropertyKey) { markDefaultNameUsed(); return ((PropertyKey)nameExpr).getPropertyName(); } else if(nameExpr instanceof AccessNode) { markDefaultNameUsed(); return ((AccessNode)nameExpr).getProperty(); } } return null; }
Example #18
Source File: Parser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private String getDefaultFunctionName() { if(!defaultNames.isEmpty()) { final Object nameExpr = defaultNames.peek(); if(nameExpr instanceof PropertyKey) { markDefaultNameUsed(); return ((PropertyKey)nameExpr).getPropertyName(); } else if(nameExpr instanceof AccessNode) { markDefaultNameUsed(); return ((AccessNode)nameExpr).getProperty(); } } return null; }
Example #19
Source File: AssignSymbols.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Node leaveASSIGN(final BinaryNode binaryNode) { // If we're assigning a property of the this object ("this.foo = ..."), record it. final Expression lhs = binaryNode.lhs(); if (lhs instanceof AccessNode) { final AccessNode accessNode = (AccessNode) lhs; final Expression base = accessNode.getBase(); if (base instanceof IdentNode) { final Symbol symbol = ((IdentNode)base).getSymbol(); if(symbol.isThis()) { thisProperties.peek().add(accessNode.getProperty()); } } } return binaryNode; }
Example #20
Source File: Parser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private String getDefaultFunctionName() { if(!defaultNames.isEmpty()) { final Object nameExpr = defaultNames.peek(); if(nameExpr instanceof PropertyKey) { markDefaultNameUsed(); return ((PropertyKey)nameExpr).getPropertyName(); } else if(nameExpr instanceof AccessNode) { markDefaultNameUsed(); return ((AccessNode)nameExpr).getProperty(); } } return null; }
Example #21
Source File: AssignSymbols.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private Node leaveASSIGN(final BinaryNode binaryNode) { // If we're assigning a property of the this object ("this.foo = ..."), record it. final Expression lhs = binaryNode.lhs(); if (lhs instanceof AccessNode) { final AccessNode accessNode = (AccessNode) lhs; final Expression base = accessNode.getBase(); if (base instanceof IdentNode) { final Symbol symbol = ((IdentNode)base).getSymbol(); if(symbol.isThis()) { thisProperties.peek().add(accessNode.getProperty()); } } } return binaryNode; }
Example #22
Source File: FinalizeTypes.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * A symbol (and {@link jdk.nashorn.internal.runtime.Property}) can be tagged as "may be primitive". * This is used a hint for dual fields that it is even worth it to try representing this * field as something other than java.lang.Object. * * @param node node in which to tag symbols as primitive * @param to which primitive type to use for tagging */ private static void setCanBePrimitive(final Node node, final Type to) { final HashSet<Node> exclude = new HashSet<>(); node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { private void setCanBePrimitive(final Symbol symbol) { LOG.info("*** can be primitive symbol ", symbol, " ", Debug.id(symbol)); symbol.setCanBePrimitive(to); } @Override public boolean enterIdentNode(final IdentNode identNode) { if (!exclude.contains(identNode)) { setCanBePrimitive(identNode.getSymbol()); } return false; } @Override public boolean enterAccessNode(final AccessNode accessNode) { setCanBePrimitive(accessNode.getProperty().getSymbol()); return false; } @Override public boolean enterIndexNode(final IndexNode indexNode) { exclude.add(indexNode.getBase()); //prevent array base node to be flagged as primitive, but k in a[k++] is fine return true; } }); }
Example #23
Source File: Attr.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveAccessNode(final AccessNode accessNode) { //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this, that //is why we can't set the access node base to be an object here, that will ruin access specialization //for example for a.x | 17. return end(ensureSymbol(Type.OBJECT, accessNode)); }
Example #24
Source File: Parser.java From hottub with GNU General Public License v2.0 | 5 votes |
private String getDefaultFunctionName() { if(!defaultNames.isEmpty()) { final Object nameExpr = defaultNames.peek(); if(nameExpr instanceof PropertyKey) { markDefaultNameUsed(); return ((PropertyKey)nameExpr).getPropertyName(); } else if(nameExpr instanceof AccessNode) { markDefaultNameUsed(); return ((AccessNode)nameExpr).getProperty(); } } return null; }
Example #25
Source File: AssignSymbols.java From hottub with GNU General Public License v2.0 | 5 votes |
private Node leaveASSIGN(final BinaryNode binaryNode) { // If we're assigning a property of the this object ("this.foo = ..."), record it. final Expression lhs = binaryNode.lhs(); if (lhs instanceof AccessNode) { final AccessNode accessNode = (AccessNode) lhs; final Expression base = accessNode.getBase(); if (base instanceof IdentNode) { final Symbol symbol = ((IdentNode)base).getSymbol(); if(symbol.isThis()) { thisProperties.peek().add(accessNode.getProperty()); } } } return binaryNode; }
Example #26
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Verify an assignment expression. * @param op Operation token. * @param lhs Left hand side expression. * @param rhs Right hand side expression. * @return Verified expression. */ private Expression verifyAssignment(final long op, final Expression lhs, final Expression rhs) { final TokenType opType = Token.descType(op); switch (opType) { case ASSIGN: case ASSIGN_ADD: case ASSIGN_BIT_AND: case ASSIGN_BIT_OR: case ASSIGN_BIT_XOR: case ASSIGN_DIV: case ASSIGN_MOD: case ASSIGN_MUL: case ASSIGN_SAR: case ASSIGN_SHL: case ASSIGN_SHR: case ASSIGN_SUB: if (!(lhs instanceof AccessNode || lhs instanceof IndexNode || lhs instanceof IdentNode)) { return referenceError(lhs, rhs, env._early_lvalue_error); } if (lhs instanceof IdentNode) { if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, rhs, false); } verifyStrictIdent((IdentNode)lhs, "assignment"); } break; default: break; } // Build up node. return new BinaryNode(op, lhs, rhs); }
Example #27
Source File: Attr.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@Override public Node leaveAccessNode(final AccessNode accessNode) { //While Object type is assigned here, Access Specialization in FinalizeTypes may narrow this, that //is why we can't set the access node base to be an object here, that will ruin access specialization //for example for a.x | 17. return end(ensureSymbol(Type.OBJECT, accessNode)); }
Example #28
Source File: Parser.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Verify an assignment expression. * @param op Operation token. * @param lhs Left hand side expression. * @param rhs Right hand side expression. * @return Verified expression. */ private Expression verifyAssignment(final long op, final Expression lhs, final Expression rhs) { final TokenType opType = Token.descType(op); switch (opType) { case ASSIGN: case ASSIGN_ADD: case ASSIGN_BIT_AND: case ASSIGN_BIT_OR: case ASSIGN_BIT_XOR: case ASSIGN_DIV: case ASSIGN_MOD: case ASSIGN_MUL: case ASSIGN_SAR: case ASSIGN_SHL: case ASSIGN_SHR: case ASSIGN_SUB: if (!(lhs instanceof AccessNode || lhs instanceof IndexNode || lhs instanceof IdentNode)) { return referenceError(lhs, rhs, env._early_lvalue_error); } if (lhs instanceof IdentNode) { if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, rhs, false); } verifyStrictIdent((IdentNode)lhs, "assignment"); } break; default: break; } // Build up node. return new BinaryNode(op, lhs, rhs); }
Example #29
Source File: Parser.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private String getDefaultFunctionName() { if(!defaultNames.isEmpty()) { final Object nameExpr = defaultNames.peek(); if(nameExpr instanceof PropertyKey) { markDefaultNameUsed(); return ((PropertyKey)nameExpr).getPropertyName(); } else if(nameExpr instanceof AccessNode) { markDefaultNameUsed(); return ((AccessNode)nameExpr).getProperty(); } } return null; }
Example #30
Source File: Parser.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Verify an assignment expression. * @param op Operation token. * @param lhs Left hand side expression. * @param rhs Right hand side expression. * @return Verified expression. */ private Expression verifyAssignment(final long op, final Expression lhs, final Expression rhs) { final TokenType opType = Token.descType(op); switch (opType) { case ASSIGN: case ASSIGN_ADD: case ASSIGN_BIT_AND: case ASSIGN_BIT_OR: case ASSIGN_BIT_XOR: case ASSIGN_DIV: case ASSIGN_MOD: case ASSIGN_MUL: case ASSIGN_SAR: case ASSIGN_SHL: case ASSIGN_SHR: case ASSIGN_SUB: if (!(lhs instanceof AccessNode || lhs instanceof IndexNode || lhs instanceof IdentNode)) { return referenceError(lhs, rhs, env._early_lvalue_error); } if (lhs instanceof IdentNode) { if (!checkIdentLValue((IdentNode)lhs)) { return referenceError(lhs, rhs, false); } verifyStrictIdent((IdentNode)lhs, "assignment"); } break; default: break; } // Build up node. if(BinaryNode.isLogical(opType)) { return new BinaryNode(op, new JoinPredecessorExpression(lhs), new JoinPredecessorExpression(rhs)); } return new BinaryNode(op, lhs, rhs); }