本文整理汇总了Java中jdk.nashorn.internal.ir.PropertyNode类的典型用法代码示例。如果您正苦于以下问题:Java PropertyNode类的具体用法?Java PropertyNode怎么用?Java PropertyNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PropertyNode类属于jdk.nashorn.internal.ir包,在下文中一共展示了PropertyNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: propertyAssignment
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
/**
* Parse a property assignment from the token stream
* @return the property assignment as a Node
*/
private PropertyNode propertyAssignment() {
// Capture firstToken.
final long propertyToken = token;
LiteralNode<?> name = null;
if (type == STRING) {
name = getStringLiteral();
} else if (type == ESCSTRING) {
name = getLiteral();
}
if (name != null) {
expect(COLON);
final Expression value = jsonLiteral();
return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
}
// Raise an error.
throw error(AbstractParser.message("expected", "string", type.getNameOrType()));
}
示例2: checkPropertyRedefinition
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
private void checkPropertyRedefinition(final PropertyNode property, final Expression value, final FunctionNode getter, final FunctionNode setter, final Expression prevValue, final FunctionNode prevGetter, final FunctionNode prevSetter) {
// ECMA 11.1.5 strict mode restrictions
if (isStrictMode && value != null && prevValue != null) {
throw error(AbstractParser.message("property.redefinition", property.getKeyName()), property.getToken());
}
final boolean isPrevAccessor = prevGetter != null || prevSetter != null;
final boolean isAccessor = getter != null || setter != null;
// data property redefined as accessor property
if (prevValue != null && isAccessor) {
throw error(AbstractParser.message("property.redefinition", property.getKeyName()), property.getToken());
}
// accessor property redefined as data
if (isPrevAccessor && value != null) {
throw error(AbstractParser.message("property.redefinition", property.getKeyName()), property.getToken());
}
if (isAccessor && isPrevAccessor) {
if (getter != null && prevGetter != null ||
setter != null && prevSetter != null) {
throw error(AbstractParser.message("property.redefinition", property.getKeyName()), property.getToken());
}
}
}
示例3: enterObjectNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
weight += OBJECT_WEIGHT;
final List<PropertyNode> properties = objectNode.getElements();
final boolean isSpillObject = properties.size() > CodeGenerator.OBJECT_SPILL_THRESHOLD;
for (final PropertyNode property : properties) {
if (!LiteralNode.isConstant(property.getValue())) {
weight += SETPROP_WEIGHT;
property.getValue().accept(this);
} else if (!isSpillObject) {
// constants in spill object are set via preset spill array,
// but fields objects need to set constants.
weight += SETPROP_WEIGHT;
}
}
return false;
}
示例4: enterPropertyNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) {
tagNeverOptimistic(propertyNode.getValue());
}
return super.enterPropertyNode(propertyNode);
}
示例5: enterPropertyNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
// Avoid falsely adding property keys to the control flow graph
if(propertyNode.getValue() != null) {
propertyNode.getValue().accept(this);
}
return false;
}
示例6: enterObjectNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
final List<PropertyNode> propNodes = objectNode.getElements();
final List<? extends PropertyTree> propTrees = translateProperties(propNodes);
curExpr = new ObjectLiteralTreeImpl(objectNode, propTrees);
return false;
}
示例7: translateProperties
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
private List<? extends PropertyTree> translateProperties(final List<PropertyNode> propNodes) {
final List<PropertyTree> propTrees = new ArrayList<>(propNodes.size());
for (final PropertyNode propNode : propNodes) {
propTrees.add(translateProperty(propNode));
}
return propTrees;
}
示例8: translateProperty
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
private PropertyTree translateProperty(final PropertyNode propNode) {
return new PropertyTreeImpl(propNode,
translateExpr(propNode.getKey()),
translateExpr(propNode.getValue()),
(FunctionExpressionTree) translateExpr(propNode.getGetter()),
(FunctionExpressionTree) translateExpr(propNode.getSetter()));
}
示例9: PropertyTreeImpl
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
PropertyTreeImpl(final PropertyNode node,
final ExpressionTree key,
final ExpressionTree value,
final FunctionExpressionTree getter,
final FunctionExpressionTree setter) {
super(node);
this.key = key;
this.value = value;
this.getter = getter;
this.setter = setter;
this.isStatic = node.isStatic();
this.isComputed = node.isComputed();
}
示例10: enterPropertyNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
if (propertyNode.getValue() != null) {
propertyNode.getValue().accept(this);
return false;
} else {
return enterDefault(propertyNode);
}
}
示例11: enterPropertyNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterPropertyNode(final PropertyNode propertyNode) {
if(ScriptObject.PROTO_PROPERTY_NAME.equals(propertyNode.getKeyName())) {
tagNeverOptimistic(propertyNode.getValue());
}
return super.enterPropertyNode(propertyNode);
}
示例12: enterObjectNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
for(final PropertyNode propertyNode: objectNode.getElements()) {
// Avoid falsely adding property keys to the control flow graph
final Expression value = propertyNode.getValue();
if (value != null) {
visitExpression(value);
}
}
return pushExpressionType(objectNode);
}
示例13: enterObjectNode
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
@Override
public boolean enterObjectNode(final ObjectNode objectNode) {
final List<PropertyNode> propNodes = objectNode.getElements();
final List<PropertyTreeImpl> propTrees = new ArrayList<>(propNodes.size());
for (final PropertyNode propNode : propNodes) {
propTrees.add(new PropertyTreeImpl(propNode,
translateExpr(propNode.getKey()),
translateExpr(propNode.getValue()),
(FunctionExpressionTree) translateExpr(propNode.getGetter()),
(FunctionExpressionTree) translateExpr(propNode.getSetter())));
}
curExpr = new ObjectLiteralTreeImpl(objectNode, propTrees);
return false;
}
示例14: PropertyTreeImpl
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
PropertyTreeImpl(final PropertyNode node,
final ExpressionTree key,
final ExpressionTree value,
final FunctionExpressionTree getter,
final FunctionExpressionTree setter) {
super(node);
this.key = key;
this.value = value;
this.getter = getter;
this.setter = setter;
}
示例15: objectLiteral
import jdk.nashorn.internal.ir.PropertyNode; //导入依赖的package包/类
/**
* Parse an object literal from the token stream
* @return the object literal as a Node
*/
private ObjectNode objectLiteral() {
// Capture LBRACE token.
final long objectToken = token;
// LBRACE tested in caller.
next();
// Prepare to accumulate elements.
final List<PropertyNode> elements = new ArrayList<>();
// Create a block for the object literal.
loop:
while (true) {
switch (type) {
case RBRACE:
next();
break loop;
case COMMARIGHT:
next();
// check for trailing comma - not allowed in JSON
if (type == RBRACE) {
throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
}
break;
default:
// Get and add the next property.
final PropertyNode property = propertyAssignment();
elements.add(property);
// Comma between property assigments is mandatory in JSON.
if (type != RBRACE && type != COMMARIGHT) {
throw error(AbstractParser.message("expected", ", or }", type.getNameOrType()));
}
break;
}
}
// Construct new object literal.
return new ObjectNode(objectToken, finish, elements);
}