本文整理汇总了Java中japa.parser.ast.expr.FieldAccessExpr类的典型用法代码示例。如果您正苦于以下问题:Java FieldAccessExpr类的具体用法?Java FieldAccessExpr怎么用?Java FieldAccessExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldAccessExpr类属于japa.parser.ast.expr包,在下文中一共展示了FieldAccessExpr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public String visit(FieldAccessExpr n, Void arg) {
Scope scope = (Scope) n.getData();
Scope context = scope.findFirstNonBlockScope();
String lhsType = n.getScope().accept(this, arg);
Scope lhsScope = scope.findType(lhsType);
switch (context.type) {
case STATIC:
case INSTANCE:
Scope enclosing = lhsScope.findEnclosingScopeForValue(n.getField(), Scope.Type.CLASS);
if (enclosing == null) {
throw new SemanticException("field " + n.getField() + " not present in type on line " + n.getBeginLine());
}
return enclosing.vars.get(n.getField()).type;
default:
throw new SemanticException("what?? on line " + n.getBeginLine());
}
}
示例2: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public Boolean visit(FieldAccessExpr n1, Node arg) {
FieldAccessExpr n2 = (FieldAccessExpr) arg;
if (!nodeEquals(n1.getScope(), n2.getScope())) {
return Boolean.FALSE;
}
if (!objEquals(n1.getField(), n2.getField())) {
return Boolean.FALSE;
}
if (!nodesEquals(n1.getTypeArgs(), n2.getTypeArgs())) {
return Boolean.FALSE;
}
return Boolean.TRUE;
}
示例3: findRootAssignExpr
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
private static AssignExpr findRootAssignExpr(BlockStmt body) {
if (body.getStmts() != null) {
for (Statement s : body.getStmts()) {
if (s instanceof ExpressionStmt) {
ExpressionStmt est = (ExpressionStmt) s;
if (est.getExpression() instanceof AssignExpr) {
AssignExpr ass = (AssignExpr) est.getExpression();
if (ass.getTarget() instanceof FieldAccessExpr) {
FieldAccessExpr fae = (FieldAccessExpr) ass.getTarget();
if ("root".equals(fae.getField())) {
return ass;
}
}
}
}
}
}
return null;
}
示例4: buildUnit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public static void buildUnit() {
CompilationUnit compUnit = new CompilationUnit();
compUnit.setPackage(new PackageDeclaration(ASTHelper
.createNameExpr("compiladores.aula")));
// create the type declaration
ClassOrInterfaceDeclaration type = new ClassOrInterfaceDeclaration(
ModifierSet.PUBLIC, false, "AulaJavaParser");
ASTHelper.addTypeDeclaration(compUnit, type);
// create a method
MethodDeclaration method = new MethodDeclaration(ModifierSet.PUBLIC,
ASTHelper.VOID_TYPE, "main");
method.setModifiers(ModifierSet.addModifier(method.getModifiers(),
ModifierSet.STATIC));
ASTHelper.addMember(type, method);
// add a parameter to the method
Parameter param = ASTHelper.createParameter(
ASTHelper.createReferenceType("String", 0), "args");
param.setVarArgs(true); //makes the parameter a ",,," array
ASTHelper.addParameter(method, param);
// add a body to the method
BlockStmt block = new BlockStmt();
method.setBody(block);
// add a statement do the method body
NameExpr clazz = new NameExpr("System");
FieldAccessExpr field = new FieldAccessExpr(clazz, "out");
MethodCallExpr call = new MethodCallExpr(field, "println");
ASTHelper.addArgument(call, new StringLiteralExpr("Hello World!"));
ASTHelper.addStmt(block, call);
System.out.println(compUnit.toString());
}
示例5: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public void visit(FieldAccessExpr n, Generator arg) {
throw new TransformException("don't know how to linearize");
}
示例6: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public Boolean visit(FieldAccessExpr n, Void arg) {
return false;
}
示例7: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public void visit(FieldAccessExpr n, Scope arg) {
super.visit(n, arg);
n.setData(arg);
}
示例8: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public R visit(FieldAccessExpr n, A arg) {
n.getScope().accept(this, arg);
return null;
}
示例9: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public void visit(FieldAccessExpr n, Object arg) {
n.getScope().accept(this, arg);
printer.print(".");
printer.print(n.getField());
}
示例10: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public void visit(FieldAccessExpr n, A arg) {
n.getScope().accept(this, arg);
}
示例11: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
public Node visit(FieldAccessExpr n, A arg) {
n.setScope((Expression) n.getScope().accept(this, arg));
return n;
}
示例12: visit
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public void visit(FieldAccessExpr n, Object arg) {
doTest(source, n);
super.visit(n, arg);
}
示例13: visitPre
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public void visitPre(FieldAccessExpr n, A arg) {
}
示例14: visitPost
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
@Override
public void visitPost(FieldAccessExpr n, A arg) {
}
示例15: visitPre
import japa.parser.ast.expr.FieldAccessExpr; //导入依赖的package包/类
void visitPre(FieldAccessExpr n, A arg);