本文整理汇总了Java中org.codehaus.groovy.ast.expr.VariableExpression.putNodeMetaData方法的典型用法代码示例。如果您正苦于以下问题:Java VariableExpression.putNodeMetaData方法的具体用法?Java VariableExpression.putNodeMetaData怎么用?Java VariableExpression.putNodeMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.expr.VariableExpression
的用法示例。
在下文中一共展示了VariableExpression.putNodeMetaData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryVariableExpressionAsProperty
import org.codehaus.groovy.ast.expr.VariableExpression; //导入方法依赖的package包/类
private boolean tryVariableExpressionAsProperty(final VariableExpression vexp, final String dynName) {
VariableExpression implicitThis = varX("this");
PropertyExpression pe = new PropertyExpression(implicitThis, dynName);
pe.setImplicitThis(true);
if (visitPropertyExpressionSilent(pe, vexp)) {
ClassNode previousIt = vexp.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE);
vexp.copyNodeMetaData(implicitThis);
vexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, previousIt);
storeType(vexp, getType(pe));
Object val = pe.getNodeMetaData(StaticTypesMarker.READONLY_PROPERTY);
if (val!=null) vexp.putNodeMetaData(StaticTypesMarker.READONLY_PROPERTY,val);
val = pe.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER);
if (val!=null) vexp.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER,val);
return true;
}
return false;
}
示例2: tryTransformDelegateToProperty
import org.codehaus.groovy.ast.expr.VariableExpression; //导入方法依赖的package包/类
private static Expression tryTransformDelegateToProperty(VariableExpression expr) {
// we need to transform variable expressions that go to a delegate
// to a property expression, as ACG would loose the information
// in processClassVariable before it reaches any makeCall, that could
// handle it
Object val = expr.getNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER);
if (val == null) return null;
VariableExpression implicitThis = new VariableExpression("this");
PropertyExpression pexp = new PropertyExpression(implicitThis, expr.getName());
pexp.copyNodeMetaData(expr);
pexp.setImplicitThis(true);
pexp.getProperty().setSourcePosition(expr);
ClassNode owner = expr.getNodeMetaData(StaticCompilationMetadataKeys.PROPERTY_OWNER);
if (owner != null) {
implicitThis.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, owner);
implicitThis.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, val);
}
return pexp;
}
示例3: tryTransformPrivateFieldAccess
import org.codehaus.groovy.ast.expr.VariableExpression; //导入方法依赖的package包/类
private static Expression tryTransformPrivateFieldAccess(VariableExpression expr) {
FieldNode field = expr.getNodeMetaData(StaticTypesMarker.PV_FIELDS_ACCESS);
if (field == null) {
field = expr.getNodeMetaData(StaticTypesMarker.PV_FIELDS_MUTATION);
}
if (field != null) {
// access to a private field from a section of code that normally doesn't have access to it, like a
// closure or an inner class
VariableExpression receiver = new VariableExpression("this");
PropertyExpression pexp = new PropertyExpression(
receiver,
expr.getName()
);
pexp.setImplicitThis(true);
pexp.getProperty().setSourcePosition(expr);
// put the receiver inferred type so that the class writer knows that it will have to call a bridge method
receiver.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, field.getDeclaringClass());
// add inferred type information
pexp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, field.getOriginType());
return pexp;
}
return null;
}
示例4: makeDynamic
import org.codehaus.groovy.ast.expr.VariableExpression; //导入方法依赖的package包/类
/**
* Instructs the type checker that an unresolved variable is a dynamic variable.
* @param returnType the type of the dynamic variable
* Calling this method automatically sets the handled flag to true.
* @param vexp the dynamic variable
*/
public void makeDynamic(VariableExpression vexp, ClassNode returnType) {
context.getEnclosingMethod().putNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION, Boolean.TRUE);
vexp.putNodeMetaData(StaticTypesMarker.DYNAMIC_RESOLUTION, returnType);
storeType(vexp, returnType);
setHandled(true);
if (debug) {
LOG.info("Turning '"+vexp.getText()+"' into a dynamic variable access of type "+returnType.toString(false));
}
}