當前位置: 首頁>>代碼示例>>Java>>正文


Java Expression.setSymbolData方法代碼示例

本文整理匯總了Java中org.walkmod.javalang.ast.expr.Expression.setSymbolData方法的典型用法代碼示例。如果您正苦於以下問題:Java Expression.setSymbolData方法的具體用法?Java Expression.setSymbolData怎麽用?Java Expression.setSymbolData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.walkmod.javalang.ast.expr.Expression的用法示例。


在下文中一共展示了Expression.setSymbolData方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: visit

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
@Override
public void visit(VariableDeclarator n, A arg) {
    n.getId().accept(this, arg);

    Expression init = n.getInit();
    if (init != null) {
        Symbol<?> aux = symbolTable.findSymbol(n.getId().getName(), ReferenceType.VARIABLE);
        Scope innerscope = new Scope(aux);
        aux.setInnerScope(innerscope);
        symbolTable.pushScope(innerscope);
        if (init instanceof LambdaExpr || init instanceof MethodReferenceExpr) {
            ArrayFilter<Method> filter = new ArrayFilter<Method>(null);
            SymbolType scope = symbolTable.getType(n.getId().getName(), ReferenceType.VARIABLE);
            filter.appendPredicate(
                    new CompatibleFunctionalMethodPredicate<A>(scope, this, null, arg, symbolTable, null, null));
            SymbolData sd = null;
            try {
                sd = MethodInspector.findMethodType(scope, null, filter, null, null);
            } catch (Exception e) {
                throw new NoSuchExpressionTypeException(e);
            }
            if (init instanceof LambdaExpr) {
                init.setSymbolData(sd);
            } else {
                init.setSymbolData(scope);
                MethodReferenceExpr methodRef = (MethodReferenceExpr) init;
                methodRef.accept(this, arg);
            }
        } else {
            init.accept(this, arg);
        }
        symbolTable.popScope();
    }
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:35,代碼來源:TypeVisitorAdapter.java

示例2: build

import org.walkmod.javalang.ast.expr.Expression; //導入方法依賴的package包/類
@Override
public MethodCallExpr build(MethodCallExpr n) throws Exception {
    List<Expression> args = n.getArgs();
    MethodSymbolData st = n.getSymbolData();
    if (args != null) {
        int i = 0;
        if (st == null) {
            Expression scope = n.getScope();
            String scopeName = "empty";
            if (scope != null) {
                scopeName = scope.getSymbolData().toString();
            }
            String argsTypeName = "empty";
            List<Expression> argExpr = n.getArgs();
            if (argExpr != null) {
                argsTypeName = "[";
                Iterator<Expression> it = argExpr.iterator();
                while (it.hasNext()) {
                    Expression arg = it.next();
                    if (arg != null && arg.getSymbolData() != null) {
                        argsTypeName += " " + arg.getSymbolData().toString();
                    } else {
                        argsTypeName += " null";
                    }
                    if (it.hasNext()) {
                        argsTypeName += ",";
                    }
                }
                argsTypeName += "]";
            }
            throw new Exception("Ops! The method call " + n.toString() + " is not resolved. The scope is ["
                    + scopeName + "] , and the args are : " + argsTypeName);
        }
        java.lang.reflect.Type[] argClasses = st.getMethod().getGenericParameterTypes();
        int paramCount = st.getMethod().getParameterTypes().length;
        for (Expression argument : args) {
            if (argument instanceof MethodReferenceExpr) {
                SymbolType aux = null;
                if (i < paramCount) {
                    aux = SymbolType.valueOf(argClasses[i], typeMapping);

                } else {
                    java.lang.reflect.Type componentType = null;
                    java.lang.reflect.Type lastArg = argClasses[argClasses.length - 1];
                    if (lastArg instanceof Class<?>) {
                        componentType = ((Class<?>) lastArg).getComponentType();
                    } else if (lastArg instanceof GenericArrayType) {
                        componentType = ((GenericArrayType) lastArg).getGenericComponentType();
                    }
                    aux = SymbolType.valueOf(componentType, typeMapping);
                }
                argument.setSymbolData(aux);
                argument.accept(visitor, ctxt);
            }
            i++;
        }
    }
    return null;
}
 
開發者ID:rpau,項目名稱:javalang-compiler,代碼行數:60,代碼來源:SymbolDataOfMethodReferenceBuilder.java


注:本文中的org.walkmod.javalang.ast.expr.Expression.setSymbolData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。