[Nice-commit] Nice/src/nice/tools/code Gen.java,1.22,1.23
Brought to you by:
bonniot
From: Arjan B. <ar...@us...> - 2005-01-13 14:06:24
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3726/F:/nice/src/nice/tools/code Modified Files: Gen.java Log Message: Moved a few methods from nice.tools.code.Gen to bossa.syntax. Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Gen.java 11 Jan 2005 21:45:46 -0000 1.22 --- Gen.java 13 Jan 2005 14:06:14 -0000 1.23 *************** *** 90,214 **** (new PrimProcedure(Type.pointer_type.getDeclaredMethod("equals", 1))); - /** - Create a lambda expression to generate code for the method. - - @param args can be null if there are no arguments - */ - public static LambdaExp createMethod(String bytecodeName, - Type[] argTypes, - Type retType, - /*MonoSymbol*/VarSymbol[] args) - { - return createMethod(bytecodeName, argTypes, retType, args, true, false); - } - - /** - @param toplevel If the method can be called from foreign code. - This forces its generation even if it is - apparently never called. - **/ - public static LambdaExp createMethod(String bytecodeName, - Type[] argTypes, - Type retType, - /*MonoSymbol*/VarSymbol[] args, - boolean toplevel) - { - return createMethod(bytecodeName, argTypes, retType, args, toplevel, false); - } - - /** - Create a lambda expression to generate code for the method. - - @param args can be null if there are no arguments - @param member true iff this method is a non-static member of - the class in argTypes[0] - @param toplevel If the method can be called from foreign code. - This forces its generation even if it is - apparently never called. - **/ - public static LambdaExp createMethod(String bytecodeName, - Type[] argTypes, - Type retType, - /*MonoSymbol*/VarSymbol[] args, - boolean toplevel, - boolean member) - { - LambdaExp res = new LambdaExp(); - createMethod(res, bytecodeName, argTypes, retType, args, toplevel, member, false); - return res; - } - - public static ConstructorExp createConstructor - (Declaration thisDecl, Type[] argTypes, /*MonoSymbol*/VarSymbol[] args) - { - ConstructorExp res = new ConstructorExp(thisDecl); - createMethod(res, "<init>", argTypes, Type.void_type, args, - true, false, true); - return res; - } - - public static ConstructorExp createCustomConstructor - (ClassType classType, Type[] argTypes, /*MonoSymbol*/VarSymbol[] args) - { - ConstructorExp res = new ConstructorExp(classType); - createMethod(res, "<init>", argTypes, Type.void_type, args, - true, false, true); - return res; - } - - /** - Create a lambda expression to generate code for the method. - - @param args can be null if there are no arguments - @param member true iff this method is a non-static member of - the class in argTypes[0] - @param toplevel If the method can be called from foreign code. - This forces its generation even if it is - apparently never called. - **/ - private static void createMethod - (LambdaExp lexp, - String bytecodeName, - Type[] argTypes, - Type retType, - /*MonoSymbol*/VarSymbol[] args, - boolean toplevel, - boolean member, - boolean constructor) - { - bytecodeName = nice.tools.code.Strings.escape(bytecodeName); - int arity = args == null ? 0 : args.length; - - lexp.setReturnType(retType); - lexp.setName(bytecodeName); - lexp.min_args = lexp.max_args = member ? arity - 1 : arity; - lexp.forceGeneration(); - if (toplevel) - lexp.setCanCall(true); - if (member) - lexp.setClassMethod(true); - - // Parameters - for(int n = 0; n < arity; n++) - { - boolean isThis = member && n == 0; - String parameterName = args[n].getName() == null - ? "anonymous_" + n - : args[n].getName().toString(); - - gnu.expr.Declaration d; - if (isThis) - { - d = new Declaration(parameterName); - d.context = lexp; - } - else - d = lexp.addDeclaration(parameterName); - if (argTypes != null) - d.setType(argTypes[n]); - d.noteValue(null); - args[n].setDeclaration(d, isThis); - } - } /** --- 90,93 ---- |