/** * Main method: enter one class from a list of toplevel trees and place the rest on uncompleted * for later processing. * * @param trees The list of trees to be processed. * @param c The class symbol to be processed. */ public void complete(List<JCCompilationUnit> trees, ClassSymbol c) { annotate.enterStart(); ListBuffer<ClassSymbol> prevUncompleted = uncompleted; if (memberEnter.completionEnabled) uncompleted = new ListBuffer<ClassSymbol>(); try { // enter all classes, and construct uncompleted list classEnter(trees, null); // complete all uncompleted classes in memberEnter if (memberEnter.completionEnabled) { while (uncompleted.nonEmpty()) { ClassSymbol clazz = uncompleted.next(); if (c == null || c == clazz || prevUncompleted == null) clazz.complete(); else // defer prevUncompleted.append(clazz); } // if there remain any unimported toplevels (these must have // no classes at all), process their import statements as well. for (JCCompilationUnit tree : trees) { if (tree.starImportScope.elems == null) { JavaFileObject prev = log.useSource(tree.sourcefile); Env<AttrContext> topEnv = topLevelEnv(tree); memberEnter.memberEnter(tree, topEnv); log.useSource(prev); } } } } finally { uncompleted = prevUncompleted; annotate.enterDone(); } }
@Override public void visitTopLevel(JCCompilationUnit tree) { JavaFileObject prev = log.useSource(tree.sourcefile); boolean addEnv = false; boolean isPkgInfo = tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE); if (tree.pid != null) { tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid)); if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) { if (isPkgInfo) { addEnv = true; } else { log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java"); } } } else { tree.packge = syms.unnamedPackage; } tree.packge.complete(); // Find all classes in package. Env<AttrContext> topEnv = topLevelEnv(tree); // Save environment of package-info.java file. if (isPkgInfo) { Env<AttrContext> env0 = typeEnvs.get(tree.packge); if (env0 == null) { typeEnvs.put(tree.packge, topEnv); } else { JCCompilationUnit tree0 = env0.toplevel; if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) { log.warning( tree.pid != null ? tree.pid.pos() : null, "pkg-info.already.seen", tree.packge); if (addEnv || (tree0.packageAnnotations.isEmpty() && tree.docComments != null && tree.docComments.get(tree) != null)) { typeEnvs.put(tree.packge, topEnv); } } } for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS; Name name = names.package_info; ClassSymbol c = reader.enterClass(name, tree.packge); c.flatname = names.fromString(tree.packge + "." + name); c.sourcefile = tree.sourcefile; c.completer = null; c.members_field = new Scope(c); tree.packge.package_info = c; } classEnter(tree.defs, topEnv); if (addEnv) { todo.append(topEnv); } log.useSource(prev); result = null; }
public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { ClassSymbol sym = (ClassSymbol) typeElem; if (typeArgs.length == 0) return (DeclaredType) sym.erasure(types); if (sym.type.getEnclosingType().isParameterized()) throw new IllegalArgumentException(sym.toString()); return getDeclaredType0(sym.type.getEnclosingType(), sym, typeArgs); }
void run(Queue<Env<AttrContext>> list, Iterable<? extends TypeElement> classes) { Set<TypeElement> set = new HashSet<TypeElement>(); for (TypeElement item : classes) set.add(item); ListBuffer<Env<AttrContext>> defer = ListBuffer.<Env<AttrContext>>lb(); while (list.peek() != null) { Env<AttrContext> env = list.remove(); ClassSymbol csym = env.enclClass.sym; if (csym != null && set.contains(csym.outermostClass())) process(env); else defer = defer.append(env); } list.addAll(defer); }
void writeClass(final Pool pool, final ClassSymbol cs, final ClassWriter writer) throws IOException { try { pool.reset(); cs.pool = pool; writer.writeClass(cs); for (Scope.Entry e = cs.members().elems; e != null; e = e.sibling) { if (e.sym.kind == Kinds.TYP) { ClassSymbol nestedClass = (ClassSymbol) e.sym; nestedClass.complete(); writeClass(pool, nestedClass, writer); } } } catch (ClassWriter.StringOverflow ex) { throw new RuntimeException(ex); } catch (ClassWriter.PoolOverflow ex) { throw new RuntimeException(ex); } }
/** * 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.make(arg), res, Type.emptyList, methodClass), opcode, predefClass); predefClass.members().enter(sym); return sym; }
/** * 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.make(left, right), res, Type.emptyList, methodClass), opcode, predefClass)); }
/** Enter a set of generated class files. */ private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) { ClassReader reader = ClassReader.instance(context); Names names = Names.instance(context); List<ClassSymbol> list = List.nil(); for (Map.Entry<String, JavaFileObject> entry : classFiles.entrySet()) { Name name = names.fromString(entry.getKey()); JavaFileObject file = entry.getValue(); if (file.getKind() != JavaFileObject.Kind.CLASS) throw new AssertionError(file); ClassSymbol cs; if (isPkgInfo(file, JavaFileObject.Kind.CLASS)) { Name packageName = Convert.packagePart(name); PackageSymbol p = reader.enterPackage(packageName); if (p.package_info == null) p.package_info = reader.enterClass(Convert.shortName(name), p); cs = p.package_info; if (cs.classfile == null) cs.classfile = file; } else cs = reader.enterClass(name, file); list = list.prepend(cs); } return list.reverse(); }
public Symbol resolveMember(String name) { Symbol s = getMembers().get(name); if (s != null) return s; if (superClass != null) return superClass.resolveMember(name); return null; }
/** * Main method: compile a list of files, return all compiled classes * * @param filenames The names of all files to be compiled. */ public List<ClassSymbol> compile( List<String> filenames, Map<String, String> origOptions, ClassLoader aptCL, AnnotationProcessorFactory providedFactory, java.util.Set<Class<? extends AnnotationProcessorFactory>> productiveFactories, java.util.Set<java.io.File> aggregateGenFiles) throws Throwable { // as a JavaCompiler can only be used once, throw an exception if // it has been used before. assert !hasBeenUsed : "attempt to reuse JavaCompiler"; hasBeenUsed = true; this.aggregateGenFiles = aggregateGenFiles; long msec = System.currentTimeMillis(); ListBuffer<ClassSymbol> classes = new ListBuffer<ClassSymbol>(); try { JavacFileManager fm = (JavacFileManager) fileManager; // parse all files ListBuffer<JCCompilationUnit> trees = new ListBuffer<JCCompilationUnit>(); for (List<String> l = filenames; l.nonEmpty(); l = l.tail) { if (classesAsDecls) { if (!l.head.endsWith(".java")) { // process as class file ClassSymbol cs = reader.enterClass(names.fromString(l.head)); try { cs.complete(); } catch (Symbol.CompletionFailure cf) { bark.aptError("CantFindClass", l); continue; } classes.append(cs); // add to list of classes continue; } } JavaFileObject fo = fm.getJavaFileObjectsFromStrings(List.of(l.head)).iterator().next(); trees.append(parse(fo)); } // enter symbols for all files List<JCCompilationUnit> roots = trees.toList(); if (errorCount() == 0) { boolean prev = bark.setDiagnosticsIgnored(true); try { enter.main(roots); } finally { bark.setDiagnosticsIgnored(prev); } } if (errorCount() == 0) { apt.main(roots, classes, origOptions, aptCL, providedFactory, productiveFactories); genSourceFileNames.addAll(apt.getSourceFileNames()); genClassFileNames.addAll(apt.getClassFileNames()); } } catch (Abort ex) { } if (verbose) log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec)); chk.reportDeferredDiagnostics(); printCount("error", errorCount()); printCount("warn", warningCount()); return classes.toList(); }
public void visitClassDef(JCClassDecl tree) { Symbol owner = env.info.scope.owner; Scope enclScope = enterScope(env); ClassSymbol c; if (owner.kind == PCK) { // We are seeing a toplevel class. PackageSymbol packge = (PackageSymbol) owner; for (Symbol q = packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS; c = reader.enterClass(tree.name, packge); packge.members().enterIfAbsent(c); if ((tree.mods.flags & PUBLIC) != 0 && !classNameMatchesFileName(c, env)) { log.error(tree.pos(), "class.public.should.be.in.file", tree.name); } } else { if (!tree.name.isEmpty() && !chk.checkUniqueClassName(tree.pos(), tree.name, enclScope)) { result = null; return; } if (owner.kind == TYP) { // We are seeing a member class. c = reader.enterClass(tree.name, (TypeSymbol) owner); if ((owner.flags_field & INTERFACE) != 0) { tree.mods.flags |= PUBLIC | STATIC; } } else { // We are seeing a local class. c = reader.defineClass(tree.name, owner); c.flatname = chk.localClassName(c); if (!c.name.isEmpty()) chk.checkTransparentClass(tree.pos(), c, env.info.scope); } } tree.sym = c; // Enter class into `compiled' table and enclosing scope. if (chk.compiled.get(c.flatname) != null) { duplicateClass(tree.pos(), c); result = types.createErrorType(tree.name, (TypeSymbol) owner, Type.noType); tree.sym = (ClassSymbol) result.tsym; return; } chk.compiled.put(c.flatname, c); enclScope.enter(c); // Set up an environment for class block and store in `typeEnvs' // table, to be retrieved later in memberEnter and attribution. Env<AttrContext> localEnv = classEnv(tree, env); typeEnvs.put(c, localEnv); // Fill out class fields. c.completer = memberEnter; c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree); c.sourcefile = env.toplevel.sourcefile; c.members_field = new Scope(c); ClassType ct = (ClassType) c.type; if (owner.kind != PCK && (c.flags_field & STATIC) == 0) { // We are seeing a local or inner class. // Set outer_field of this class to closest enclosing class // which contains this class in a non-static context // (its "enclosing instance class"), provided such a class exists. Symbol owner1 = owner; while ((owner1.kind & (VAR | MTH)) != 0 && (owner1.flags_field & STATIC) == 0) { owner1 = owner1.owner; } if (owner1.kind == TYP) { ct.setEnclosingType(owner1.type); } } // Enter type parameters. ct.typarams_field = classEnter(tree.typarams, localEnv); // Add non-local class to uncompleted, to make sure it will be // completed later. if (!c.isLocal() && uncompleted != null) uncompleted.append(c); // System.err.println("entering " + c.fullname + " in " + c.owner);//DEBUG // Recursively enter all member classes. classEnter(tree.defs, localEnv); result = c.type; }
private boolean isPkgInfo(ClassSymbol sym) { return isPkgInfo(sym.classfile, JavaFileObject.Kind.CLASS) && (sym.packge().package_info == sym); }
void createSymbols() throws IOException { Set<String> legacy = getLegacyPackages(); Set<String> legacyProprietary = getLegacyPackages(); Set<String> documented = new HashSet<String>(); Set<PackageSymbol> packages = ((JavacProcessingEnvironment) processingEnv).getSpecifiedPackages(); String jarName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Jar"); if (jarName == null) throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Jar=LOCATION_OF_JAR"); String destName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Dest"); if (destName == null) throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Dest=LOCATION_OF_JAR"); for (PackageSymbol psym : packages) { String name = psym.getQualifiedName().toString(); legacyProprietary.remove(name); documented.add(name); } JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null); Location jarLocation = StandardLocation.locationFor(jarName); File jarFile = new File(jarName); fm.setLocation(jarLocation, List.of(jarFile)); fm.setLocation(StandardLocation.CLASS_PATH, List.<File>nil()); fm.setLocation(StandardLocation.SOURCE_PATH, List.<File>nil()); { ArrayList<File> bootClassPath = new ArrayList<File>(); bootClassPath.add(jarFile); for (File path : fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)) { if (!new File(path.getName()).equals(new File("rt.jar"))) bootClassPath.add(path); } System.err.println("Using boot class path = " + bootClassPath); fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath); } // System.out.println(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)); File destDir = new File(destName); if (!destDir.exists()) if (!destDir.mkdirs()) throw new RuntimeException("Could not create " + destDir); fm.setLocation(StandardLocation.CLASS_OUTPUT, List.of(destDir)); Set<String> hiddenPackages = new HashSet<String>(); Set<String> crisp = new HashSet<String>(); List<String> options = List.of("-XDdev"); // options = options.prepend("-doe"); // options = options.prepend("-verbose"); JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, fm, null, options, null, null); com.sun.tools.javac.main.JavaCompiler compiler = com.sun.tools.javac.main.JavaCompiler.instance(task.getContext()); ClassReader reader = ClassReader.instance(task.getContext()); ClassWriter writer = ClassWriter.instance(task.getContext()); Symtab syms = Symtab.instance(task.getContext()); Attribute.Compound proprietary = new Attribute.Compound( syms.proprietaryType, List.<Pair<Symbol.MethodSymbol, Attribute>>nil()); Type.moreInfo = true; Pool pool = new Pool(); for (JavaFileObject file : fm.list(jarLocation, "", EnumSet.of(CLASS), true)) { String className = fm.inferBinaryName(jarLocation, file); int index = className.lastIndexOf('.'); String pckName = index == -1 ? "" : className.substring(0, index); boolean addLegacyAnnotation = false; if (documented.contains(pckName)) { if (!legacy.contains(pckName)) crisp.add(pckName); // System.out.println("Documented: " + className); } else if (legacyProprietary.contains(pckName)) { addLegacyAnnotation = true; // System.out.println("Legacy proprietary: " + className); } else { // System.out.println("Hidden " + className); hiddenPackages.add(pckName); continue; } TypeSymbol sym = (TypeSymbol) compiler.resolveIdent(className); if (sym.kind != Kinds.TYP) { if (className.indexOf('$') < 0) { System.err.println("Ignoring (other) " + className + " : " + sym); System.err.println(" " + sym.getClass().getSimpleName() + " " + sym.type); } continue; } sym.complete(); if (sym.getEnclosingElement().getKind() != ElementKind.PACKAGE) { System.err.println("Ignoring (bad) " + sym.getQualifiedName()); continue; } ClassSymbol cs = (ClassSymbol) sym; if (addLegacyAnnotation) { cs.attributes_field = (cs.attributes_field == null) ? List.of(proprietary) : cs.attributes_field.prepend(proprietary); } writeClass(pool, cs, writer); } if (false) { for (String pckName : crisp) System.out.println("Crisp: " + pckName); for (String pckName : hiddenPackages) System.out.println("Hidden: " + pckName); for (String pckName : legacyProprietary) System.out.println("Legacy proprietary: " + pckName); for (String pckName : documented) System.out.println("Documented: " + pckName); } }
/** Constructor; enters all predefined identifiers and operators into symbol table. */ private Symtab(Context context) throws CompletionFailure { super(); context.put(symtabKey, this); names = Name.Table.instance(context); byteType = new Type(TypeTags.BYTE, null); charType = new Type(TypeTags.CHAR, null); shortType = new Type(TypeTags.SHORT, null); intType = new Type(TypeTags.INT, null); longType = new Type(TypeTags.LONG, null); floatType = new Type(TypeTags.FLOAT, null); doubleType = new Type(TypeTags.DOUBLE, null); booleanType = new Type(TypeTags.BOOLEAN, null); voidType = new Type(TypeTags.VOID, null); botType = new Type(TypeTags.BOT, null); unknownType = new Type(TypeTags.UNKNOWN, null) { public boolean isSameType(Type that) { return true; } public boolean isSubType(Type that) { return false; } public boolean isSuperType(Type that) { return true; } }; rootPackage = new PackageSymbol(names.empty, null); emptyPackage = new PackageSymbol(names.emptyPackage, rootPackage); noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage); noSymbol.kind = Kinds.NIL; errSymbol = new ClassSymbol(PUBLIC | STATIC, names.any, null, rootPackage); errType = new ErrorType(errSymbol); initType(byteType, "byte", "Byte"); initType(shortType, "short", "Short"); initType(charType, "char", "Character"); initType(intType, "int", "Integer"); initType(longType, "long", "Long"); initType(floatType, "float", "Float"); initType(doubleType, "double", "Double"); initType(booleanType, "boolean", "Boolean"); initType(voidType, "void", "Void"); initType(botType, "<nulltype>"); initType(errType, errSymbol); initType(unknownType, "<any?>"); arrayClass = new ClassSymbol(PUBLIC, names.Array, noSymbol); methodClass = new ClassSymbol(PUBLIC, names.Method, noSymbol); predefClass = new ClassSymbol(PUBLIC, names.empty, rootPackage); Scope scope = new Scope(predefClass); predefClass.members_field = scope; scope.enter(byteType.tsym); scope.enter(shortType.tsym); scope.enter(charType.tsym); scope.enter(intType.tsym); scope.enter(longType.tsym); scope.enter(floatType.tsym); scope.enter(doubleType.tsym); scope.enter(booleanType.tsym); scope.enter(errType.tsym); classes.put(predefClass.fullname, predefClass); reader = ClassReader.instance(context); reader.init(this); objectType = enterClass("java.lang.Object"); classType = enterClass("java.lang.Class"); stringType = enterClass("java.lang.String"); stringBufferType = enterClass("java.lang.StringBuffer"); cloneableType = enterClass("java.lang.Cloneable"); throwableType = enterClass("java.lang.Throwable"); serializableType = enterClass("java.io.Serializable"); errorType = enterClass("java.lang.Error"); exceptionType = enterClass("java.lang.Exception"); runtimeExceptionType = enterClass("java.lang.RuntimeException"); classNotFoundExceptionType = enterClass("java.lang.ClassNotFoundException"); noClassDefFoundErrorType = enterClass("java.lang.NoClassDefFoundError"); assertionErrorType = enterClass("java.lang.AssertionError"); classLoaderType = enterClass("java.lang.ClassLoader"); ClassType arrayClassType = (ClassType) arrayClass.type; arrayClassType.supertype_field = objectType; arrayClassType.interfaces_field = List.make(cloneableType, serializableType); arrayClass.members_field = new Scope(arrayClass); lengthVar = new VarSymbol(PUBLIC | FINAL, names.length, intType, arrayClass); arrayClass.members().enter(lengthVar); Symbol cloneMethod = new MethodSymbol( PUBLIC, names.clone, new MethodType(Type.emptyList, objectType, Type.emptyList, methodClass), arrayClass); arrayClass.members().enter(cloneMethod); nullConst = enterConstant("null", botType); trueConst = enterConstant("true", booleanType.constType(new Integer(1))); falseConst = enterConstant("false", booleanType.constType(new Integer(0))); enterUnop("+", intType, intType, nop); enterUnop("+", longType, longType, nop); enterUnop("+", floatType, floatType, nop); enterUnop("+", doubleType, doubleType, nop); enterUnop("-", intType, intType, ineg); enterUnop("-", longType, longType, lneg); enterUnop("-", floatType, floatType, fneg); enterUnop("-", doubleType, doubleType, dneg); enterUnop("~", intType, intType, ixor); enterUnop("~", longType, longType, lxor); enterUnop("++", byteType, byteType, iadd); enterUnop("++", shortType, shortType, iadd); enterUnop("++", charType, charType, iadd); enterUnop("++", intType, intType, iadd); enterUnop("++", longType, longType, ladd); enterUnop("++", floatType, floatType, fadd); enterUnop("++", doubleType, doubleType, dadd); enterUnop("--", byteType, byteType, isub); enterUnop("--", shortType, shortType, isub); enterUnop("--", charType, charType, isub); enterUnop("--", intType, intType, isub); enterUnop("--", longType, longType, lsub); enterUnop("--", floatType, floatType, fsub); enterUnop("--", doubleType, doubleType, dsub); enterUnop("!", booleanType, booleanType, bool_not); nullcheck = enterUnop("<*nullchk*>", objectType, objectType, nullchk); enterBinop("+", stringType, stringType, stringType, string_add); enterBinop("+", stringType, intType, stringType, string_add); enterBinop("+", stringType, longType, stringType, string_add); enterBinop("+", stringType, floatType, stringType, string_add); enterBinop("+", stringType, doubleType, stringType, string_add); enterBinop("+", stringType, booleanType, stringType, string_add); enterBinop("+", stringType, objectType, stringType, string_add); enterBinop("+", stringType, botType, stringType, string_add); enterBinop("+", intType, stringType, stringType, string_add); enterBinop("+", longType, stringType, stringType, string_add); enterBinop("+", floatType, stringType, stringType, string_add); enterBinop("+", doubleType, stringType, stringType, string_add); enterBinop("+", booleanType, stringType, stringType, string_add); enterBinop("+", objectType, stringType, stringType, string_add); enterBinop("+", botType, stringType, stringType, string_add); enterBinop("+", intType, intType, intType, iadd); enterBinop("+", longType, longType, longType, ladd); enterBinop("+", floatType, floatType, floatType, fadd); enterBinop("+", doubleType, doubleType, doubleType, dadd); enterBinop("+", botType, botType, botType, error); enterBinop("+", botType, intType, botType, error); enterBinop("+", botType, longType, botType, error); enterBinop("+", botType, floatType, botType, error); enterBinop("+", botType, doubleType, botType, error); enterBinop("+", botType, booleanType, botType, error); enterBinop("+", botType, objectType, botType, error); enterBinop("+", intType, botType, botType, error); enterBinop("+", longType, botType, botType, error); enterBinop("+", floatType, botType, botType, error); enterBinop("+", doubleType, botType, botType, error); enterBinop("+", booleanType, botType, botType, error); enterBinop("+", objectType, botType, botType, error); enterBinop("-", intType, intType, intType, isub); enterBinop("-", longType, longType, longType, lsub); enterBinop("-", floatType, floatType, floatType, fsub); enterBinop("-", doubleType, doubleType, doubleType, dsub); enterBinop("*", intType, intType, intType, imul); enterBinop("*", longType, longType, longType, lmul); enterBinop("*", floatType, floatType, floatType, fmul); enterBinop("*", doubleType, doubleType, doubleType, dmul); enterBinop("/", intType, intType, intType, idiv); enterBinop("/", longType, longType, longType, ldiv); enterBinop("/", floatType, floatType, floatType, fdiv); enterBinop("/", doubleType, doubleType, doubleType, ddiv); enterBinop("%", intType, intType, intType, imod); enterBinop("%", longType, longType, longType, lmod); enterBinop("%", floatType, floatType, floatType, fmod); enterBinop("%", doubleType, doubleType, doubleType, dmod); enterBinop("&", booleanType, booleanType, booleanType, iand); enterBinop("&", intType, intType, intType, iand); enterBinop("&", longType, longType, longType, land); enterBinop("|", booleanType, booleanType, booleanType, ior); enterBinop("|", intType, intType, intType, ior); enterBinop("|", longType, longType, longType, lor); enterBinop("^", booleanType, booleanType, booleanType, ixor); enterBinop("^", intType, intType, intType, ixor); enterBinop("^", longType, longType, longType, lxor); enterBinop("<<", intType, intType, intType, ishl); enterBinop("<<", longType, intType, longType, lshl); enterBinop("<<", intType, longType, intType, ishll); enterBinop("<<", longType, longType, longType, lshll); enterBinop(">>", intType, intType, intType, ishr); enterBinop(">>", longType, intType, longType, lshr); enterBinop(">>", intType, longType, intType, ishrl); enterBinop(">>", longType, longType, longType, lshrl); enterBinop(">>>", intType, intType, intType, iushr); enterBinop(">>>", longType, intType, longType, lushr); enterBinop(">>>", intType, longType, intType, iushrl); enterBinop(">>>", longType, longType, longType, lushrl); enterBinop("<", intType, intType, booleanType, if_icmplt); enterBinop("<", longType, longType, booleanType, lcmp, iflt); enterBinop("<", floatType, floatType, booleanType, fcmpg, iflt); enterBinop("<", doubleType, doubleType, booleanType, dcmpg, iflt); enterBinop(">", intType, intType, booleanType, if_icmpgt); enterBinop(">", longType, longType, booleanType, lcmp, ifgt); enterBinop(">", floatType, floatType, booleanType, fcmpl, ifgt); enterBinop(">", doubleType, doubleType, booleanType, dcmpl, ifgt); enterBinop("<=", intType, intType, booleanType, if_icmple); enterBinop("<=", longType, longType, booleanType, lcmp, ifle); enterBinop("<=", floatType, floatType, booleanType, fcmpg, ifle); enterBinop("<=", doubleType, doubleType, booleanType, dcmpg, ifle); enterBinop(">=", intType, intType, booleanType, if_icmpge); enterBinop(">=", longType, longType, booleanType, lcmp, ifge); enterBinop(">=", floatType, floatType, booleanType, fcmpl, ifge); enterBinop(">=", doubleType, doubleType, booleanType, dcmpl, ifge); enterBinop("==", intType, intType, booleanType, if_icmpeq); enterBinop("==", longType, longType, booleanType, lcmp, ifeq); enterBinop("==", floatType, floatType, booleanType, fcmpl, ifeq); enterBinop("==", doubleType, doubleType, booleanType, dcmpl, ifeq); enterBinop("==", booleanType, booleanType, booleanType, if_icmpeq); enterBinop("==", objectType, objectType, booleanType, if_acmpeq); enterBinop("!=", intType, intType, booleanType, if_icmpne); enterBinop("!=", longType, longType, booleanType, lcmp, ifne); enterBinop("!=", floatType, floatType, booleanType, fcmpl, ifne); enterBinop("!=", doubleType, doubleType, booleanType, dcmpl, ifne); enterBinop("!=", booleanType, booleanType, booleanType, if_icmpne); enterBinop("!=", objectType, objectType, booleanType, if_acmpne); enterBinop("&&", booleanType, booleanType, booleanType, bool_and); enterBinop("||", booleanType, booleanType, booleanType, bool_or); }
/** * Enter a constant into symbol table. * * @param name The constant's name. * @param type The constant's type. */ private VarSymbol enterConstant(String name, Type type) { VarSymbol c = new VarSymbol(PUBLIC | STATIC | FINAL, names.fromString(name), type, predefClass); c.constValue = type.constValue; predefClass.members().enter(c); return c; }