Update of /cvsroot/nice/Nice/src/nice/tools/code
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18206/src/nice/tools/code
Modified Files:
IsOfClassProc.java Gen.java
Log Message:
Compile initializers in a $init method that is called after all constructors
have been executed so that the instance is valid.
(This implies that code in proper constructors cannot capture 'this' anymore,
hence the simplification of gnu.expr.ConstructorExp)
Index: Gen.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** Gen.java 30 Jun 2004 09:42:34 -0000 1.20
--- Gen.java 9 Oct 2004 09:28:40 -0000 1.21
***************
*** 29,35 ****
}
! public static Expression isOfClass(Expression value, Type ct)
{
! return Inline.inline(new IsOfClassProc(ct), value);
}
--- 29,36 ----
}
! public static Expression isOfClass(Expression value, Type ct,
! boolean possiblyNull)
{
! return Inline.inline(new IsOfClassProc(ct, possiblyNull), value);
}
***************
*** 227,231 ****
Expression[] params)
{
! LambdaExp lexp = new LambdaExp();
bytecodeName = nice.tools.code.Strings.escape(bytecodeName);
int arity = 1 + (argTypes == null ? 0 : argTypes.length);
--- 228,234 ----
Expression[] params)
{
! Declaration thisDecl = new Declaration("this");
! LambdaExp lexp = new MemberLambdaExp(thisDecl);
!
bytecodeName = nice.tools.code.Strings.escape(bytecodeName);
int arity = 1 + (argTypes == null ? 0 : argTypes.length);
***************
*** 247,252 ****
if (isThis)
{
! d = new Declaration(parameterName);
! d.context = lexp;
d.setType(receiver);
params[n] = new ThisExp(d);
--- 250,254 ----
if (isThis)
{
! d = thisDecl;
d.setType(receiver);
params[n] = new ThisExp(d);
***************
*** 261,266 ****
d.setCanRead(true);
d.setCanWrite(true);
-
}
return lexp;
}
--- 263,268 ----
d.setCanRead(true);
d.setCanWrite(true);
}
+
return lexp;
}
***************
*** 350,353 ****
lambda.body = new ApplyExp(proc, args);
return lambda;
! }
}
--- 352,366 ----
lambda.body = new ApplyExp(proc, args);
return lambda;
! }
!
! public static Expression superCall(Expression method, Expression[] args)
! {
! return new ApplyExp(method, args, true);
! }
!
!
! public static Expression superCaller(Method method)
! {
! return new QuoteExp(PrimProcedure.specialCall(method));
! }
}
Index: IsOfClassProc.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/IsOfClassProc.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** IsOfClassProc.java 24 May 2003 19:55:58 -0000 1.2
--- IsOfClassProc.java 9 Oct 2004 09:28:40 -0000 1.3
***************
*** 19,29 ****
public class IsOfClassProc extends Procedure1 implements Inlineable
{
! public IsOfClassProc(Type type)
{
this.type = type;
}
private Type type;
!
public void compile (ApplyExp exp, Compilation comp, Target target)
{
--- 19,31 ----
public class IsOfClassProc extends Procedure1 implements Inlineable
{
! public IsOfClassProc(Type type, boolean possiblyNull)
{
this.type = type;
+ this.possiblyNull = possiblyNull;
}
private Type type;
! private boolean possiblyNull;
!
public void compile (ApplyExp exp, Compilation comp, Target target)
{
***************
*** 31,46 ****
CodeAttr code = comp.getCode();
- //first a check is needed for the case that the argument is null
args[0].compile(comp, Target.pushObject);
! code.emitDup();
! code.emitIfNotNull();
code.emitInvokeVirtual(getClassMethod);
code.emitInvokeVirtual(getNameMethod);
code.emitPushString(type.getName());
code.emitInvokeVirtual(equalsMethod);
! code.emitElse();
! code.emitPop(1);
! code.emitPushBoolean(false);
! code.emitFi();
target.compileFromStack(comp, Type.boolean_type);
}
--- 33,58 ----
CodeAttr code = comp.getCode();
args[0].compile(comp, Target.pushObject);
!
! if (possiblyNull)
! {
! //first a check is needed for the case that the argument is null
! code.emitDup();
! code.emitIfNotNull();
! }
!
code.emitInvokeVirtual(getClassMethod);
code.emitInvokeVirtual(getNameMethod);
code.emitPushString(type.getName());
code.emitInvokeVirtual(equalsMethod);
!
! if (possiblyNull)
! {
! code.emitElse();
! code.emitPop(1);
! code.emitPushBoolean(false);
! code.emitFi();
! }
!
target.compileFromStack(comp, Type.boolean_type);
}
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
|