当前位置: 首页>>代码示例>>Java>>正文


Java MethodType类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.Type.MethodType的典型用法代码示例。如果您正苦于以下问题:Java MethodType类的具体用法?Java MethodType怎么用?Java MethodType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MethodType类属于com.sun.tools.javac.code.Type包,在下文中一共展示了MethodType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: enterUnop

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/** Enter a unary operation into symbol table.
 *  @param name     The name of the operator.
 *  @param arg      The type of the operand.
 *  @param res      The operation's result type.
 *  @param opcode   The operation's bytecode instruction.
 */
private OperatorSymbol enterUnop(String name,
                                 Type arg,
                                 Type res,
                                 int opcode) {
    OperatorSymbol sym =
        new OperatorSymbol(names.fromString(name),
                           new MethodType(List.of(arg),
                                          res,
                                          List.<Type>nil(),
                                          methodClass),
                           opcode,
                           predefClass);
    predefClass.members().enter(sym);
    return sym;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:Symtab.java

示例2: bsmStaticArgToType

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private Type bsmStaticArgToType(Object arg) {
    Assert.checkNonNull(arg);
    if (arg instanceof ClassSymbol) {
        return syms.classType;
    } else if (arg instanceof Integer) {
        return syms.intType;
    } else if (arg instanceof Long) {
        return syms.longType;
    } else if (arg instanceof Float) {
        return syms.floatType;
    } else if (arg instanceof Double) {
        return syms.doubleType;
    } else if (arg instanceof String) {
        return syms.stringType;
    } else if (arg instanceof Pool.MethodHandle) {
        return syms.methodHandleType;
    } else if (arg instanceof MethodType) {
        return syms.methodTypeType;
    } else {
        Assert.error("bad static arg " + arg.getClass());
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:LambdaToMethod.java

示例3: infer

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/**
 * Returns the inferred method type of the template based on the given actual argument types.
 *
 * @throws NoInstanceException if no instances of the specified type variables would allow the
 *         {@code actualArgTypes} to match the {@code expectedArgTypes}
 */
private Type infer(Warner warner,
    Inliner inliner,
    List<Type> freeTypeVariables,
    List<Type> expectedArgTypes,
    Type returnType,
    List<Type> actualArgTypes) throws NoInstanceException {
  Symtab symtab = inliner.symtab();
  MethodType methodType =
      new MethodType(expectedArgTypes, returnType, List.<Type>nil(), symtab.methodClass);
  Enter enter = inliner.enter();
  MethodSymbol methodSymbol =
      new MethodSymbol(0, inliner.asName("__m__"), methodType, symtab.unknownSymbol);
  return inliner.infer().instantiateMethod(enter.getEnv(methodType.tsym),
      freeTypeVariables,
      methodType,
      methodSymbol,
      actualArgTypes,
      autoboxing(),
      false,
      warner);
}
 
开发者ID:sivakumar-kailasam,项目名称:refactor-faster,代码行数:28,代码来源:Template.java

示例4: enterBinop

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/** Enter a binary operation into symbol table.
 *  @param name     The name of the operator.
 *  @param left     The type of the left operand.
 *  @param right    The type of the left operand.
 *  @param res      The operation's result type.
 *  @param opcode   The operation's bytecode instruction.
 */
private void enterBinop(String name,
                        Type left, Type right, Type res,
                        int opcode) {
    predefClass.members().enter(
        new OperatorSymbol(
            names.fromString(name),
            new MethodType(List.of(left, right), res,
                           List.<Type>nil(), methodClass),
            opcode,
            predefClass));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:Symtab.java

示例5: KlassInfo

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private KlassInfo(JCClassDecl clazz) {
    this.clazz = clazz;
    appendedMethodList = new ListBuffer<>();
    deserializeCases = new HashMap<String, ListBuffer<JCStatement>>();
    MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType,
            List.<Type>nil(), syms.methodClass);
    deserMethodSym = makePrivateSyntheticMethod(STATIC, names.deserializeLambda, type, clazz.sym);
    deserParamSym = new VarSymbol(FINAL, names.fromString("lambda"),
            syms.serializedLambdaType, deserMethodSym);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:LambdaToMethod.java

示例6: deserTest

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private JCExpression deserTest(JCExpression prev, String func, String lit) {
    MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.<Type>nil(), syms.methodClass);
    Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.<Type>nil());
    JCMethodInvocation eqtest = make.Apply(
            List.<JCExpression>nil(),
            make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt),
            List.<JCExpression>of(make.Literal(lit)));
    eqtest.setType(syms.booleanType);
    JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest);
    compound.operator = rs.resolveBinaryOperator(null, JCTree.Tag.AND, attrEnv, syms.booleanType, syms.booleanType);
    compound.setType(syms.booleanType);
    return compound;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:14,代码来源:LambdaToMethod.java

示例7: deserGetter

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) {
    MethodType getmt = new MethodType(argTypes, type, List.<Type>nil(), syms.methodClass);
    Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.<Type>nil());
    return make.Apply(
                List.<JCExpression>nil(),
                make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt),
                args).setType(type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:LambdaToMethod.java

示例8: typeToMethodType

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private MethodType typeToMethodType(Type mt) {
    Type type = types.erasure(mt);
    return new MethodType(type.getParameterTypes(),
                    type.getReturnType(),
                    type.getThrownTypes(),
                    syms.methodClass);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:LambdaToMethod.java

示例9: makeIndyCall

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/**
 * Generate an indy method call with given name, type and static bootstrap
 * arguments types
 */
private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
        List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
        Name methName) {
    int prevPos = make.pos;
    try {
        make.at(pos);
        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));

        Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
                bsmName, bsm_staticArgs, List.<Type>nil());

        DynamicMethodSymbol dynSym =
                new DynamicMethodSymbol(methName,
                                        syms.noSymbol,
                                        bsm.isStatic() ?
                                            ClassFile.REF_invokeStatic :
                                            ClassFile.REF_invokeVirtual,
                                        (MethodSymbol)bsm,
                                        indyType,
                                        staticArgs.toArray());

        JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
        qualifier.sym = dynSym;
        qualifier.type = indyType.getReturnType();

        JCMethodInvocation proxyCall = make.Apply(List.<JCExpression>nil(), qualifier, indyArgs);
        proxyCall.type = indyType.getReturnType();
        return proxyCall;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:LambdaToMethod.java

示例10: KlassInfo

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private KlassInfo(JCClassDecl clazz) {
    this.clazz = clazz;
    appendedMethodList = new ListBuffer<>();
    deserializeCases = new HashMap<>();
    MethodType type = new MethodType(List.of(syms.serializedLambdaType), syms.objectType,
            List.nil(), syms.methodClass);
    deserMethodSym = makePrivateSyntheticMethod(STATIC, names.deserializeLambda, type, clazz.sym);
    deserParamSym = new VarSymbol(FINAL, names.fromString("lambda"),
            syms.serializedLambdaType, deserMethodSym);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:LambdaToMethod.java

示例11: deserTest

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private JCExpression deserTest(JCExpression prev, String func, String lit) {
    MethodType eqmt = new MethodType(List.of(syms.objectType), syms.booleanType, List.nil(), syms.methodClass);
    Symbol eqsym = rs.resolveQualifiedMethod(null, attrEnv, syms.objectType, names.equals, List.of(syms.objectType), List.nil());
    JCMethodInvocation eqtest = make.Apply(
            List.nil(),
            make.Select(deserGetter(func, syms.stringType), eqsym).setType(eqmt),
            List.of(make.Literal(lit)));
    eqtest.setType(syms.booleanType);
    JCBinary compound = make.Binary(JCTree.Tag.AND, prev, eqtest);
    compound.operator = operators.resolveBinary(compound, JCTree.Tag.AND, syms.booleanType, syms.booleanType);
    compound.setType(syms.booleanType);
    return compound;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:LambdaToMethod.java

示例12: deserGetter

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
private JCExpression deserGetter(String func, Type type, List<Type> argTypes, List<JCExpression> args) {
    MethodType getmt = new MethodType(argTypes, type, List.nil(), syms.methodClass);
    Symbol getsym = rs.resolveQualifiedMethod(null, attrEnv, syms.serializedLambdaType, names.fromString(func), argTypes, List.nil());
    return make.Apply(
                List.nil(),
                make.Select(make.Ident(kInfo.deserParamSym).setType(syms.serializedLambdaType), getsym).setType(getmt),
                args).setType(type);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:LambdaToMethod.java

示例13: makeIndyCall

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/**
 * Generate an indy method call with given name, type and static bootstrap
 * arguments types
 */
private JCExpression makeIndyCall(DiagnosticPosition pos, Type site, Name bsmName,
        List<Object> staticArgs, MethodType indyType, List<JCExpression> indyArgs,
        Name methName) {
    int prevPos = make.pos;
    try {
        make.at(pos);
        List<Type> bsm_staticArgs = List.of(syms.methodHandleLookupType,
                syms.stringType,
                syms.methodTypeType).appendList(bsmStaticArgToTypes(staticArgs));

        Symbol bsm = rs.resolveInternalMethod(pos, attrEnv, site,
                bsmName, bsm_staticArgs, List.nil());

        DynamicMethodSymbol dynSym =
                new DynamicMethodSymbol(methName,
                                        syms.noSymbol,
                                        bsm.isStatic() ?
                                            ClassFile.REF_invokeStatic :
                                            ClassFile.REF_invokeVirtual,
                                        (MethodSymbol)bsm,
                                        indyType,
                                        staticArgs.toArray());

        JCFieldAccess qualifier = make.Select(make.QualIdent(site.tsym), bsmName);
        qualifier.sym = dynSym;
        qualifier.type = indyType.getReturnType();

        JCMethodInvocation proxyCall = make.Apply(List.nil(), qualifier, indyArgs);
        proxyCall.type = indyType.getReturnType();
        return proxyCall;
    } finally {
        make.at(prevPos);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:LambdaToMethod.java

示例14: makeOperator

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
/**
 * Creates an operator symbol.
 */
private OperatorSymbol makeOperator(Name name, List<OperatorType> formals, OperatorType res, int... opcodes) {
    MethodType opType = new MethodType(
            formals.stream()
                    .map(o -> o.asType(syms))
                    .collect(List.collector()),
            res.asType(syms), List.nil(), syms.methodClass);
    return new OperatorSymbol(name, opType, mergeOpcodes(opcodes), syms.noSymbol);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Operators.java

示例15: typeOfMethod

import com.sun.tools.javac.code.Type.MethodType; //导入依赖的package包/类
String typeOfMethod(MethodSnippet msn) {
    Tree unitTree = method(msn);
    if (unitTree instanceof JCMethodDecl) {
        JCMethodDecl mtree = (JCMethodDecl) unitTree;
        Type mt = types().erasure(mtree.type);
        if (mt instanceof MethodType) {
            return signature(types(), (MethodType) mt);
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TreeDissector.java


注:本文中的com.sun.tools.javac.code.Type.MethodType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。