jdk.test.lib.jittester.Symbol - java examples

Here are the examples of the java api jdk.test.lib.jittester.Symbol taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

18 Examples 7

19 View Complete Implementation : FunctionDefinition.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
// Check if the given function prototype f1 is a valid overload of
// prototypes in collection S.
// The override is invalid if function f1 has the same signature as
// function f2 in S, but has different return type.
public static boolean isInvalidOverride(FunctionInfo f1, Collection<Symbol> symbols) {
    for (Symbol symbol : symbols) {
        FunctionInfo f2 = (FunctionInfo) symbol;
        if (f1.hasEqualSignature(f2)) {
            if (!f1.type.equals(f2.type)) {
                return true;
            }
            if ((f2.flags & FunctionInfo.NONRECURSIVE) > 0 || ((f1.flags & FunctionInfo.ABSTRACT) > 0 && (f2.flags & FunctionInfo.ABSTRACT) == 0) || (f1.flags & FunctionInfo.STATIC) != (f2.flags & FunctionInfo.STATIC) || (f2.flags & FunctionInfo.FINAL) > 0 || (f1.flags & FunctionInfo.ACCESS_ATTRS_MASK) < (f2.flags & FunctionInfo.ACCESS_ATTRS_MASK)) {
                return true;
            }
        }
    }
    return false;
}

19 View Complete Implementation : TypeKlass.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public boolean containsSymbol(Symbol s) {
    return symbolsSet.contains(s);
}

19 View Complete Implementation : TypeKlass.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public boolean addSymbol(Symbol s) {
    return symbolsSet.add(s);
}

18 View Complete Implementation : TypeKlass.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public boolean removeSymbol(Symbol s) {
    return symbolsSet.remove(s);
}

17 View Complete Implementation : FunctionDefinitionBlockFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public FunctionDefinitionBlock produce() throws ProductionFailedException {
    ArrayList<IRNode> content = new ArrayList<>();
    int memFunLimit = (int) (PseudoRandom.random() * memberFunctionsLimit);
    if (memFunLimit > 0) {
        long memFunCompl = complexityLimit / memFunLimit;
        IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlreplaced(ownerClreplaced).setComplexityLimit(memFunCompl).setStatementLimit(statementLimit).setOperatorLimit(operatorLimit).setMemberFunctionsArgLimit(memberFunctionsArgLimit).setLevel(level);
        for (int i = 0; i < memFunLimit; i++) {
            int flags = initialFlags;
            if (PseudoRandom.randomBoolean()) {
                flags |= FunctionInfo.STATIC;
            }
            if (!ProductionParams.disableFinalMethods.value() && PseudoRandom.randomBoolean()) {
                flags |= FunctionInfo.FINAL;
            }
            if (PseudoRandom.randomBoolean()) {
                flags |= FunctionInfo.NONRECURSIVE;
            }
            if (PseudoRandom.randomBoolean()) {
                flags |= FunctionInfo.SYNCHRONIZED;
            }
            switch((int) (PseudoRandom.random() * 4)) {
                case 0:
                    flags |= FunctionInfo.PRIVATE;
                    break;
                case 1:
                    flags |= FunctionInfo.PROTECTED;
                    break;
                case 2:
                    flags |= FunctionInfo.DEFAULT;
                    break;
                case 3:
                    flags |= FunctionInfo.PUBLIC;
                    break;
            }
            Symbol thisSymbol = null;
            if ((flags & FunctionInfo.STATIC) > 0) {
                thisSymbol = SymbolTable.get("this", VariableInfo.clreplaced);
                SymbolTable.remove(thisSymbol);
            }
            try {
                content.add(builder.setName("func_" + i).setFlags(flags).getFunctionDefinitionFactory().produce());
            } catch (ProductionFailedException e) {
            }
            if ((flags & FunctionInfo.STATIC) > 0) {
                SymbolTable.add(thisSymbol);
            }
        }
    }
    return new FunctionDefinitionBlock(content, level, ownerClreplaced);
}

17 View Complete Implementation : FunctionRedefinitionBlockFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public FunctionRedefinitionBlock produce() throws ProductionFailedException {
    ArrayList<IRNode> content = new ArrayList<>();
    if (functionSet.size() > 0) {
        long funcComplexity = complexityLimit / functionSet.size();
        IRNodeBuilder builder = new IRNodeBuilder().setOwnerKlreplaced(ownerClreplaced).setComplexityLimit(funcComplexity).setStatementLimit(statementLimit).setOperatorLimit(operatorLimit).setLevel(level);
        for (Symbol symbol : functionSet) {
            FunctionInfo functionInfo = (FunctionInfo) symbol;
            Symbol thisSymbol = null;
            if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
                thisSymbol = SymbolTable.get("this", VariableInfo.clreplaced);
                SymbolTable.remove(thisSymbol);
            }
            try {
                content.add(builder.setFunctionInfo(functionInfo).setFlags(functionInfo.flags).getFunctionRedefinitionFactory().produce());
            } catch (ProductionFailedException e) {
                if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
                    ownerClreplaced.setAbstract();
                }
            }
            if ((functionInfo.flags & FunctionInfo.STATIC) > 0) {
                SymbolTable.add(thisSymbol);
            }
        }
    }
    return new FunctionRedefinitionBlock(content, level);
}

17 View Complete Implementation : LocalVariableFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public LocalVariable produce() throws ProductionFailedException {
    // Get the variables of the requested type from SymbolTable
    ArrayList<Symbol> allVariables = new ArrayList<>(SymbolTable.get(type, VariableInfo.clreplaced));
    if (!allVariables.isEmpty()) {
        PseudoRandom.shuffle(allVariables);
        for (Symbol symbol : allVariables) {
            VariableInfo varInfo = (VariableInfo) symbol;
            if ((varInfo.flags & VariableInfo.FINAL) == (flags & VariableInfo.FINAL) && (varInfo.flags & VariableInfo.INITIALIZED) == (flags & VariableInfo.INITIALIZED) && (varInfo.flags & VariableInfo.LOCAL) > 0) {
                return new LocalVariable(varInfo);
            }
        }
    }
    throw new ProductionFailedException();
}

17 View Complete Implementation : StaticMemberVariableFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public StaticMemberVariable produce() throws ProductionFailedException {
    // Get the variables of the requested type from SymbolTable
    ArrayList<Symbol> variables = new ArrayList<>(SymbolTable.get(type, VariableInfo.clreplaced));
    if (!variables.isEmpty()) {
        PseudoRandom.shuffle(variables);
        for (Symbol symbol : variables) {
            VariableInfo varInfo = (VariableInfo) symbol;
            if ((varInfo.flags & VariableInfo.FINAL) == (flags & VariableInfo.FINAL) && (varInfo.flags & VariableInfo.INITIALIZED) == (flags & VariableInfo.INITIALIZED) && (varInfo.flags & VariableInfo.STATIC) > 0) {
                return new StaticMemberVariable((TypeKlreplaced) ownerClreplaced, varInfo);
            }
        }
    }
    throw new ProductionFailedException();
}

17 View Complete Implementation : JavaCodeVisitor.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static String attributes(Symbol s) {
    String attrs = "";
    if (s.isPrivate()) {
        attrs += "private ";
    }
    if (s.isProtected()) {
        attrs += "protected ";
    }
    if (s.isPublic()) {
        attrs += "public ";
    }
    if (s.isFinal()) {
        attrs += "final ";
    }
    if (s.isStatic()) {
        attrs += "static ";
    }
    return attrs;
}

16 View Complete Implementation : NonStaticMemberVariableFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public NonStaticMemberVariable produce() throws ProductionFailedException {
    // Get the variables of the requested type from SymbolTable
    ArrayList<Symbol> variables = new ArrayList<>(SymbolTable.get(type, VariableInfo.clreplaced));
    if (!variables.isEmpty()) {
        PseudoRandom.shuffle(variables);
        IRNodeBuilder builder = new IRNodeBuilder().setComplexityLimit(complexityLimit).setOperatorLimit(operatorLimit).setOwnerKlreplaced((TypeKlreplaced) ownerClreplaced).setExceptionSafe(exceptionSafe).setNoConsts(false);
        for (Symbol symbol : variables) {
            VariableInfo varInfo = (VariableInfo) symbol;
            if ((varInfo.flags & VariableInfo.FINAL) == (flags & VariableInfo.FINAL) && (varInfo.flags & VariableInfo.INITIALIZED) == (flags & VariableInfo.INITIALIZED) && (varInfo.flags & VariableInfo.STATIC) == 0 && (varInfo.flags & VariableInfo.LOCAL) == 0) {
                try {
                    IRNode object = builder.setResultType(varInfo.owner).getExpressionFactory().produce();
                    return new NonStaticMemberVariable(object, varInfo);
                } catch (ProductionFailedException e) {
                }
            }
        }
    }
    throw new ProductionFailedException();
}

16 View Complete Implementation : Function.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public long complexity() {
    int argsComplexity = 0;
    for (IRNode child : getChildren()) {
        argsComplexity += child.complexity();
    }
    long funcComplexity = functionInfo.complexity;
    TypeKlreplaced typeKlreplaced = this.owner;
    if (functionInfo.isConstructor()) {
        // Sum complexities of all default constructors of parent clreplacedes
        for (TypeKlreplaced parent : typeKlreplaced.getAllParents()) {
            Collection<Symbol> parentFuncs = SymbolTable.getAllCombined(parent, FunctionInfo.clreplaced);
            for (Symbol f : parentFuncs) {
                FunctionInfo c = (FunctionInfo) f;
                if (c.name.equals(c.owner.getName()) && c.argTypes.isEmpty()) {
                    funcComplexity += c.complexity;
                }
            }
        }
    // TODO: Complexities of all non-static initializers should be also added..
    } else {
        // Perform the CHA and find the highest complexity
        for (TypeKlreplaced child : typeKlreplaced.getAllChildren()) {
            Collection<Symbol> childFuncs = SymbolTable.getAllCombined(child, FunctionInfo.clreplaced);
            for (Symbol childFunc : childFuncs) {
                if (childFunc.equals(functionInfo)) {
                    funcComplexity = Math.max(funcComplexity, ((FunctionInfo) childFunc).complexity);
                }
            }
        }
    }
    return argsComplexity + funcComplexity;
}

12 View Complete Implementation : FunctionFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected Function sproduce() throws ProductionFailedException {
    // Currently no function is exception-safe
    if (exceptionSafe) {
        throw new ProductionFailedException();
    }
    ArrayList<Symbol> allFunctions;
    if (functionInfo.type == null) {
        allFunctions = new ArrayList<>(SymbolTable.getAllCombined(FunctionInfo.clreplaced));
    } else {
        allFunctions = new ArrayList<>(SymbolTable.get(functionInfo.type, FunctionInfo.clreplaced));
    }
    if (!allFunctions.isEmpty()) {
        PseudoRandom.shuffle(allFunctions);
        Collection<TypeKlreplaced> klreplacedHierarchy = ownerClreplaced.getAllParents();
        for (Symbol function : allFunctions) {
            FunctionInfo functionInfo = (FunctionInfo) function;
            // Don't try to construct abstract clreplacedes.
            if (functionInfo.isConstructor() && functionInfo.owner.isAbstract()) {
                continue;
            }
            // We don't call methods from the same clreplaced which are not final, because if we
            // do this may produce an infinite recursion. Simple example:
            // clreplaced  A
            // {
            // f1() { }
            // f2() { f1(); }
            // }
            // 
            // clreplaced B : A
            // {
            // f1() { f2(); }
            // }
            // 
            // However the same example is obviously safe for static and final functions
            // Also we introduce a special flag NONRECURSIVE to mark functions that
            // are not overrided. We may also call such functions.
            // If it's a local call.. or it's a call using some variable to some object of some type in our hierarchy
            boolean inHierarchy = false;
            if (ownerClreplaced.equals(functionInfo.owner) || (inHierarchy = klreplacedHierarchy.contains(functionInfo.owner))) {
                if ((functionInfo.flags & FunctionInfo.FINAL) == 0 && (functionInfo.flags & FunctionInfo.STATIC) == 0 && (functionInfo.flags & FunctionInfo.NONRECURSIVE) == 0) {
                    continue;
                }
                if (inHierarchy && (functionInfo.flags & FunctionInfo.PRIVATE) > 0) {
                    continue;
                }
            } else {
                if ((functionInfo.flags & FunctionInfo.PUBLIC) == 0 && (functionInfo.flags & FunctionInfo.DEFAULT) == 0) {
                    continue;
                }
            }
            if (functionInfo.complexity < complexityLimit - 1) {
                try {
                    List<IRNode> acreplaced = new ArrayList<>();
                    if (!functionInfo.argTypes.isEmpty()) {
                        // Here we should do some replacedysis here to determine if
                        // there are any conflicting functions due to possible
                        // constant folding.
                        // For example the following can be done:
                        // Scan all the hieirachy where the clreplaced is declared.
                        // If there are function with a same name and same number of args,
                        // then disable usage of foldable expressions in the args.
                        boolean noconsts = false;
                        Collection<Symbol> allFuncsInKlreplaced = SymbolTable.getAllCombined(functionInfo.owner, FunctionInfo.clreplaced);
                        for (Symbol s2 : allFuncsInKlreplaced) {
                            FunctionInfo i2 = (FunctionInfo) function;
                            if (!i2.equals(functionInfo) && i2.name.equals(functionInfo.name) && i2.argTypes.size() == functionInfo.argTypes.size()) {
                                noconsts = true;
                                break;
                            }
                        }
                        long argComp = (complexityLimit - 1 - functionInfo.complexity) / functionInfo.argTypes.size();
                        int argumentOperatorLimit = (operatorLimit - 1) / functionInfo.argTypes.size();
                        IRNodeBuilder b = new IRNodeBuilder().setOwnerKlreplaced(ownerClreplaced).setComplexityLimit(argComp).setOperatorLimit(argumentOperatorLimit).setExceptionSafe(exceptionSafe).setNoConsts(noconsts);
                        for (VariableInfo argType : functionInfo.argTypes) {
                            acreplaced.add(b.setResultType(argType.type).getExpressionFactory().produce());
                        }
                    }
                    return new Function(ownerClreplaced, functionInfo, acreplaced);
                } catch (ProductionFailedException e) {
                // removeAllChildren();
                }
            }
        }
    }
    throw new ProductionFailedException();
}

11 View Complete Implementation : ConstructorDefinitionFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public ConstructorDefinition produce() throws ProductionFailedException {
    int argNumber = (int) (PseudoRandom.random() * memberFunctionsArgLimit);
    ArrayList<VariableInfo> argumentsInfo = new ArrayList<>(argNumber);
    ArrayList<ArgumentDeclaration> argumentsDeclaration = new ArrayList<>(argNumber);
    SymbolTable.push();
    IRNode body;
    FunctionInfo functionInfo;
    try {
        int i = 0;
        IRNodeBuilder builder = new IRNodeBuilder().setArgumentType(ownerClreplaced).setOwnerKlreplaced(ownerClreplaced);
        for (; i < argNumber; i++) {
            ArgumentDeclaration d = builder.setVariableNumber(i).getArgumentDeclarationFactory().produce();
            argumentsDeclaration.add(d);
            argumentsInfo.add(d.variableInfo);
        }
        for (boolean dup = true; dup; i++) {
            /* Check if these is a function with a same signature
                (includes original clreplaced name) defined. */
            functionInfo = new FunctionInfo(ownerClreplaced.getName(), ownerClreplaced, ownerClreplaced, 0, FunctionInfo.PUBLIC, argumentsInfo);
            dup = false;
            for (Symbol symbol : SymbolTable.get(ownerClreplaced, FunctionInfo.clreplaced)) {
                if (functionInfo.equals(symbol)) {
                    ArgumentDeclaration argDecl = builder.setVariableNumber(i).getArgumentDeclarationFactory().produce();
                    argumentsDeclaration.add(argDecl);
                    argumentsInfo.add(argDecl.variableInfo);
                    dup = true;
                    break;
                }
            }
        }
        long blockComplLimit = (long) (PseudoRandom.random() * complexityLimit);
        try {
            body = builder.setResultType(TypeList.VOID).setComplexityLimit(blockComplLimit).setStatementLimit(statementLimit).setOperatorLimit(operatorLimit).setLevel(level).setSubBlock(true).getBlockFactory().produce();
        } catch (ProductionFailedException e) {
            body = null;
        }
    } finally {
        SymbolTable.pop();
    }
    functionInfo = new FunctionInfo(ownerClreplaced.getName(), ownerClreplaced, ownerClreplaced, body != null ? body.complexity() : 0, FunctionInfo.PUBLIC, argumentsInfo);
    // If it's all ok, add the function to the symbol table.
    SymbolTable.add(functionInfo);
    return new ConstructorDefinition(functionInfo, argumentsDeclaration, body);
}

11 View Complete Implementation : VariableInitializationFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
protected VariableInitialization sproduce() throws ProductionFailedException {
    LinkedList<Type> types = new LinkedList<>(TypeList.getAll());
    PseudoRandom.shuffle(types);
    if (types.isEmpty()) {
        throw new ProductionFailedException();
    }
    Type resultType = types.getFirst();
    IRNodeBuilder b = new IRNodeBuilder().setComplexityLimit(complexityLimit - 1).setOperatorLimit(operatorLimit - 1).setOwnerKlreplaced(ownerClreplaced).setResultType(resultType).setExceptionSafe(exceptionSafe).setNoConsts(false);
    Rule<IRNode> rule = new Rule<>("initializer");
    rule.add("literal_initializer", b.getLiteralFactory());
    if (!ProductionParams.disableExprInInit.value()) {
        rule.add("expression", b.getLimitedExpressionFactory());
    }
    Symbol thisSymbol = null;
    if (isStatic) {
        thisSymbol = SymbolTable.get("this", VariableInfo.clreplaced);
        SymbolTable.remove(thisSymbol);
    }
    IRNode init;
    try {
        init = rule.produce();
    } finally {
        if (isStatic) {
            SymbolTable.add(thisSymbol);
        }
    }
    String resultName = "var_" + SymbolTable.getNextVariableNumber();
    int flags = VariableInfo.INITIALIZED;
    if (constant) {
        flags |= VariableInfo.FINAL;
    }
    if (isStatic) {
        flags |= VariableInfo.STATIC;
    }
    if (isLocal) {
        flags |= VariableInfo.LOCAL;
    }
    VariableInfo varInfo = new VariableInfo(resultName, ownerClreplaced, resultType, flags);
    SymbolTable.add(varInfo);
    return new VariableInitialization(varInfo, init);
}

6 View Complete Implementation : KlassFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void inheritClreplaced() {
    // Grab all Klreplacedes from the TypeList and select one to be a parent
    LinkedList<Type> probableParents = new LinkedList<>(TypeList.getAll());
    for (Iterator<Type> i = probableParents.iterator(); i.hasNext(); ) {
        Type klreplaced = i.next();
        if (!(klreplaced instanceof TypeKlreplaced) || ((TypeKlreplaced) klreplaced).isFinal() || ((TypeKlreplaced) klreplaced).isInterface()) {
            // we can not derive from finals and interfaces
            i.remove();
        }
    }
    if (probableParents.isEmpty()) {
        parent = TypeList.OBJECT;
    } else {
        parent = (TypeKlreplaced) PseudoRandom.randomElement(probableParents);
    }
    thisKlreplaced.addParent(parent.getName());
    thisKlreplaced.setParent(parent);
    parent.addChild(name);
    for (Symbol symbol : SymbolTable.getAllCombined(parent)) {
        if ((symbol.flags & Symbol.PRIVATE) == 0) {
            Symbol symbolCopy = symbol.deepCopy();
            if (symbolCopy instanceof FunctionInfo) {
                FunctionInfo functionInfo = (FunctionInfo) symbolCopy;
                if (functionInfo.isConstructor()) {
                    continue;
                }
                if ((functionInfo.flags & FunctionInfo.STATIC) == 0) {
                    functionInfo.argTypes.get(0).type = thisKlreplaced;
                }
            }
            symbolCopy.owner = thisKlreplaced;
            SymbolTable.add(symbolCopy);
        }
    }
}

6 View Complete Implementation : KlassFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
private void inheritInterfaces() {
    // Select interfaces that we'll implement.
    LinkedList<Type> probableInterfaces = new LinkedList<>(TypeList.getAll());
    for (Iterator<Type> i = probableInterfaces.iterator(); i.hasNext(); ) {
        Type klreplaced = i.next();
        if (!(klreplaced instanceof TypeKlreplaced) || !((TypeKlreplaced) klreplaced).isInterface()) {
            i.remove();
        }
    }
    PseudoRandom.shuffle(probableInterfaces);
    int implLimit = (int) (ProductionParams.implementationLimit.value() * PseudoRandom.random());
    // Mulitiple inheritance compatibility check
    compatibility_check: for (Iterator<Type> i = probableInterfaces.iterator(); i.hasNext() && implLimit > 0; implLimit--) {
        TypeKlreplaced iface = (TypeKlreplaced) i.next();
        ArrayList<Symbol> ifaceFuncSet = SymbolTable.getAllCombined(iface, FunctionInfo.clreplaced);
        for (Symbol symbol : SymbolTable.getAllCombined(thisKlreplaced, FunctionInfo.clreplaced)) {
            if (FunctionDefinition.isInvalidOverride((FunctionInfo) symbol, ifaceFuncSet)) {
                continue compatibility_check;
            }
        }
        interfaces.add(iface);
        iface.addChild(name);
        thisKlreplaced.addParent(iface.getName());
        for (Symbol symbol : SymbolTable.getAllCombined(iface, FunctionInfo.clreplaced)) {
            FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
            functionInfo.owner = thisKlreplaced;
            functionInfo.argTypes.get(0).type = thisKlreplaced;
            SymbolTable.add(functionInfo);
        }
    }
}

5 View Complete Implementation : InterfaceFactory.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
@Override
public Interface produce() throws ProductionFailedException {
    TypeKlreplaced thisKlreplaced;
    // Do we want to inherit something?
    if (!ProductionParams.disableInheritance.value()) {
        // Grab all Klreplacedes from the TypeList and select one to be a parent
        LinkedList<Type> types = new LinkedList<>(TypeList.getAll());
        for (Iterator<Type> i = types.iterator(); i.hasNext(); ) {
            Type klreplaced = i.next();
            if (!(klreplaced instanceof TypeKlreplaced) || !((TypeKlreplaced) klreplaced).isInterface()) {
                i.remove();
            }
        }
        PseudoRandom.shuffle(types);
        if (!types.isEmpty()) {
            parent = (TypeKlreplaced) types.getFirst();
        }
    }
    thisKlreplaced = new TypeKlreplaced(name, TypeKlreplaced.INTERFACE);
    if (parent != null) {
        thisKlreplaced.addParent(parent.getName());
        thisKlreplaced.setParent(parent);
        parent.addChild(name);
        for (Symbol symbol : SymbolTable.getAllCombined(parent, FunctionInfo.clreplaced)) {
            FunctionInfo functionInfo = (FunctionInfo) symbol.deepCopy();
            functionInfo.owner = thisKlreplaced;
            functionInfo.argTypes.get(0).type = thisKlreplaced;
            SymbolTable.add(functionInfo);
        }
    }
    IRNode functionDeclarations = null;
    try {
        functionDeclarations = new IRNodeBuilder().setOwnerKlreplaced(thisKlreplaced).setMemberFunctionsLimit(memberFunctionsLimit).setMemberFunctionsArgLimit(memberFunctionsArgLimit).setLevel(level + 1).getFunctionDeclarationBlockFactory().produce();
    } finally {
        TypeList.add(thisKlreplaced);
    }
    return new Interface(parent, name, level, functionDeclarations);
}

5 View Complete Implementation : FixedTrees.java
Copyright GNU General Public License v2.0
Author : AdoptOpenJDK
public static FunctionDefinition printVariablesAsFunction(PrintVariables node) {
    TypeKlreplaced owner = node.getOwner();
    ArrayList<IRNode> nodes = new ArrayList<>();
    VariableInfo resultInfo = new VariableInfo("result", node.getOwner(), TypeList.STRING, VariableInfo.LOCAL);
    nodes.add(new Statement(new VariableInitialization(resultInfo, new Literal("[", TypeList.STRING)), true));
    LocalVariable resultVar = new LocalVariable(resultInfo);
    List<Symbol> vars = node.getVars();
    TypeKlreplaced printerKlreplaced = new TypeKlreplaced(Printer.clreplaced.getName());
    VariableInfo thisInfo = new VariableInfo("this", node.getOwner(), node.getOwner(), VariableInfo.LOCAL | VariableInfo.INITIALIZED);
    LocalVariable thisVar = new LocalVariable(thisInfo);
    for (int i = 0; i < vars.size(); i++) {
        Symbol v = vars.get(i);
        nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, new Literal(v.owner.getName() + "." + v.name + " = ", TypeList.STRING)), true));
        VariableInfo argInfo = new VariableInfo("arg", printerKlreplaced, v.type instanceof TypeKlreplaced ? TypeList.OBJECT : v.type, VariableInfo.LOCAL | VariableInfo.INITIALIZED);
        FunctionInfo printInfo = new FunctionInfo("print", printerKlreplaced, TypeList.STRING, 0, FunctionInfo.PUBLIC | FunctionInfo.STATIC, argInfo);
        Function call = new Function(owner, printInfo, null);
        VariableInfo varInfo = new VariableInfo(v.name, v.owner, v.type, v.flags);
        if (v.isStatic()) {
            call.addChild(new StaticMemberVariable(v.owner, varInfo));
        } else {
            call.addChild(new NonStaticMemberVariable(thisVar, varInfo));
        }
        nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, call), true));
        if (i < vars.size() - 1) {
            nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, EOL), true));
        }
    }
    nodes.add(new Statement(new BinaryOperator(OperatorKind.COMPOUND_ADD, TypeList.STRING, resultVar, new Literal("]\n", TypeList.STRING)), true));
    Block block = new Block(node.getOwner(), TypeList.STRING, nodes, 1);
    FunctionInfo toStringInfo = new FunctionInfo("toString", owner, TypeList.STRING, 0L, FunctionInfo.PUBLIC, thisInfo);
    return new FunctionDefinition(toStringInfo, new ArrayList<>(), block, new Return(resultVar));
}