📄 typedecl.java
字号:
// Declared in CodeGeneration.jrag at line 1132 public void branchGT(CodeGeneration gen, int label) { throw new Error("branchGT not supported for " + getClass().getName()); } // Declared in CodeGeneration.jrag at line 1138 public void branchEQ(CodeGeneration gen, int label) { throw new Error("branchEQ not supported for " + getClass().getName()); } // Declared in CodeGeneration.jrag at line 1147 public void branchNE(CodeGeneration gen, int label) { throw new Error("branchNE not supported for " + getClass().getName()); } // Declared in CreateBCode.jrag at line 42 private void generateBytecodes(CodeGeneration gen) { for(int i = 0; i < getNumBodyDecl(); i++) { BodyDecl b = getBodyDecl(i); if(b instanceof FieldDeclaration && b.isBytecodeField() && b.generate()) { FieldDeclaration f = (FieldDeclaration)b; if(f.isStatic() && f.hasInit()) { f.getInit().createBCode(gen); f.getInit().type().emitAssignConvTo(gen, f.type()); // AssignConversion f.emitStoreField(gen, this); } } else if(b instanceof StaticInitializer) { b.createBCode(gen); } } gen.emitReturn(); } // Declared in Flags.jrag at line 28 // method // mangle modifiers for nested types public int mangledFlags(int flags) { boolean privateFlag = (flags & Modifiers.ACC_PRIVATE) != 0; boolean protectedFlag = (flags & Modifiers.ACC_PROTECTED) != 0; flags &= ~ Modifiers.ACC_PRIVATE; flags &= ~ Modifiers.ACC_PROTECTED; if(protectedFlag) flags |= Modifiers.ACC_PUBLIC; return flags; } // Declared in GenerateClassfile.jrag at line 27 public void generateClassfile() { for(Iterator iter = nestedTypes().iterator(); iter.hasNext(); ) { TypeDecl typeDecl = (TypeDecl)iter.next(); typeDecl.generateClassfile(); } } // Declared in GenerateClassfile.jrag at line 335 public boolean clear() { bytecodes(constantPool()).clearCodeGeneration(); for(int i = 0; i < getNumBodyDecl(); i++) getBodyDecl(i).clear(); attributes_computed = false; attributes_value = null; clinit_attributes_computed = false; clinit_attributes_value = null; constantPool_computed = false; constantPool_value = null; bytecodes_ConstantPool_values = null; return false; } // Declared in InnerClasses.jrag at line 12 // no attribute since needed in phases when the AST has been modified public boolean hasField(String name) { if(!memberFields(name).isEmpty()) return true; for(int i = 0; i < getNumBodyDecl(); i++) { if(getBodyDecl(i) instanceof FieldDeclaration) { FieldDeclaration decl = (FieldDeclaration)getBodyDecl(i); if(decl.name().equals(name)) return true; } } return false; } // Declared in InnerClasses.jrag at line 36 public boolean hasMethod(String id) { if(!memberMethods(id).isEmpty()) return true; for(int i = 0; i < getNumBodyDecl(); i++) { if(getBodyDecl(i) instanceof MethodDecl) { MethodDecl decl = (MethodDecl)getBodyDecl(i); if(decl.name().equals(id)) return true; } } return false; } // Declared in InnerClasses.jrag at line 121 // The set of TypeDecls that has this TypeDecl as their directly enclosing TypeDecl. // I.e., NestedTypes, InnerTypes, AnonymousClasses, LocalClasses. private Collection nestedTypes; // Declared in InnerClasses.jrag at line 122 public Collection nestedTypes() { return nestedTypes != null ? nestedTypes : new HashSet(); } // Declared in InnerClasses.jrag at line 125 public void addNestedType(TypeDecl typeDecl) { if(nestedTypes == null) nestedTypes = new HashSet(); if(typeDecl != this) nestedTypes.add(typeDecl); } // Declared in InnerClasses.jrag at line 132 // The set of nested TypeDecls that are accessed in this TypeDecl private Collection usedNestedTypes; // Declared in InnerClasses.jrag at line 133 public Collection usedNestedTypes() { return usedNestedTypes != null ? usedNestedTypes : new HashSet(); } // Declared in InnerClasses.jrag at line 136 public void addUsedNestedType(TypeDecl typeDecl) { if(usedNestedTypes == null) usedNestedTypes = new HashSet(); usedNestedTypes.add(typeDecl); } // Declared in InnerClasses.jrag at line 167 public int accessorCounter = 0; // Declared in InnerClasses.jrag at line 169 private HashMap accessorMap = null; // Declared in InnerClasses.jrag at line 170 public ASTNode getAccessor(ASTNode source, String name) { ArrayList key = new ArrayList(2); key.add(source); key.add(name); if(accessorMap == null || !accessorMap.containsKey(key)) return null; return (ASTNode)accessorMap.get(key); } // Declared in InnerClasses.jrag at line 178 public void addAccessor(ASTNode source, String name, ASTNode accessor) { ArrayList key = new ArrayList(2); key.add(source); key.add(name); if(accessorMap == null) accessorMap = new HashMap(); accessorMap.put(key, accessor); } // Declared in InnerClasses.jrag at line 186 public ASTNode getAccessorSource(ASTNode accessor) { Iterator i = accessorMap.entrySet().iterator(); while (i.hasNext()) { Map.Entry entry = (Map.Entry) i.next(); if (entry.getValue() == accessor) return (ASTNode) ((ArrayList) entry.getKey()).get(0); } return null; } // Declared in InnerClasses.jrag at line 413 // add val$name as fields to the class private boolean addEnclosingVariables = true; // Declared in InnerClasses.jrag at line 414 public void addEnclosingVariables() { if(!addEnclosingVariables) return; addEnclosingVariables = false; for(Iterator iter = enclosingVariables().iterator(); iter.hasNext(); ) { Variable v = (Variable)iter.next(); Modifiers m = new Modifiers(); m.addModifier(new Modifier("public")); m.addModifier(new Modifier("synthetic")); addMemberField(new FieldDeclaration(m, v.type().createQualifiedAccess(), "val$" + v.name(), new Opt())); } } // Declared in Java2Rewrites.jrag at line 11 int uniqueIndexCounter = 1; // Declared in Java2Rewrites.jrag at line 70 // lazily build a static field for assertionsDisabled private FieldDeclaration createAssertionsDisabled = null; // Declared in Java2Rewrites.jrag at line 71 public FieldDeclaration createAssertionsDisabled() { if(createAssertionsDisabled != null) return createAssertionsDisabled; // static final boolean $assertionsDisabled = !TypeName.class.desiredAssertionStatus(); createAssertionsDisabled = new FieldDeclaration( new Modifiers(new List().add(new Modifier("public")).add(new Modifier("static")).add(new Modifier("final"))), new PrimitiveTypeAccess("boolean"), "$assertionsDisabled", new Opt( new LogNotExpr( topLevelType().createQualifiedAccess().qualifiesAccess( new ClassAccess().qualifiesAccess( new MethodAccess( "desiredAssertionStatus", new List() ) ) ) ) ) ); getBodyDeclList().insertChild(createAssertionsDisabled, 0); // explicit read to trigger possible rewrites createAssertionsDisabled = (FieldDeclaration)getBodyDeclList().getChild(0); // transform the generated initalization, e.g., the ClassAccess construct createAssertionsDisabled.transformation(); return createAssertionsDisabled; } // Declared in Java2Rewrites.jrag at line 124 // lazily build a static field for each typename used in a .class expression private HashMap createStaticClassField = null; // Declared in Java2Rewrites.jrag at line 125 public FieldDeclaration createStaticClassField(String name) { if(createStaticClassField == null) createStaticClassField = new HashMap(); if(createStaticClassField.containsKey(name)) return (FieldDeclaration)createStaticClassField.get(name); // static synthetic Class class$java$lang$String; FieldDeclaration f = new FieldDeclaration( new Modifiers(new List().add(new Modifier("public")).add(new Modifier("static"))), lookupType("java.lang", "Class").createQualifiedAccess(), name, new Opt() ) { public boolean isConstant() { return true; } }; createStaticClassField.put(name, f); return addMemberField(f); } // Declared in Java2Rewrites.jrag at line 146 // lazily build a static class$ method in this type declaration private MethodDecl createStaticClassMethod = null; // Declared in Java2Rewrites.jrag at line 147 public MethodDecl createStaticClassMethod() { if(createStaticClassMethod != null) return createStaticClassMethod; // static synthetic Class class$(String name) { // try { // return java.lang.Class.forName(name); // } catch(java.lang.ClassNotFoundException e) { // throw new java.lang.NoClassDefFoundError(e.getMessage()); // } // } createStaticClassMethod = new MethodDecl( new Modifiers(new List().add(new Modifier("public")).add(new Modifier("static"))), lookupType("java.lang", "Class").createQualifiedAccess(), "class$", new List().add( new ParameterDeclaration( new Modifiers(new List()), lookupType("java.lang", "String").createQualifiedAccess(), "name" ) ), new List(), new Opt( new Block( new List().add( new TryStmt( new Block( new List().add( new ReturnStmt( new Opt( lookupType("java.lang", "Class").createQualifiedAccess().qualifiesAccess( new MethodAccess( "forName", new List().add( new VarAccess("name") ) ) ) ) ) ) ), new List().add( new CatchClause( new ParameterDeclaration( new Modifiers(new List()), lookupType("java.lang", "ClassNotFoundException").createQualifiedAccess(), "e" ), new Block( new List().add( new ThrowStmt( new ClassInstanceExpr( lookupType("java.lang", "NoClassDefFoundError").createQualifiedAccess(), new List().add( new VarAccess("e").qualifiesAccess( new MethodAccess( "getMessage", new List() ) ) ), new Opt() ) ) ) ) ) ), new Opt() ) ) ) ) ) { public boolean isConstant() { return true; } };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -