[Nice-commit] Nice/src/nice/tools/code EnsureTypeProc.java,1.3,1.4
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-30 21:49:56
|
Update of /cvsroot/nice/Nice/src/nice/tools/code
In directory sc8-pr-cvs1:/tmp/cvs-serv26306/F:/nice/src/nice/tools/code
Modified Files:
EnsureTypeProc.java
Log Message:
Workaround for a bug that only happens when using primitive types as arguments for OptionOr.
This is really a strange bug, I couldn't find any other case where is bug also happens and I didn't find the exact cause of this bug so this patch is only a workaroud.
Index: EnsureTypeProc.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/EnsureTypeProc.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** EnsureTypeProc.java 5 Apr 2002 09:19:23 -0000 1.3
--- EnsureTypeProc.java 30 Mar 2003 21:49:53 -0000 1.4
***************
*** 20,23 ****
--- 20,24 ----
import gnu.bytecode.*;
+ import nice.lang.inline.OptionOr;
/**
Ensures that the expression has the given bytecode type.
***************
*** 34,38 ****
{
Type type = exp.getType();
!
if (! type.isAssignableTo(expectedType))
return Inline.inline(new EnsureTypeProc(expectedType), exp);
--- 35,39 ----
{
Type type = exp.getType();
!
if (! type.isAssignableTo(expectedType))
return Inline.inline(new EnsureTypeProc(expectedType), exp);
***************
*** 61,65 ****
exp.getArgs()[0].compile(comp, target);
!
/*
If we changed the target, we also have to use the old one.
--- 62,76 ----
exp.getArgs()[0].compile(comp, target);
!
! // A nasty rare case
! if ((oldTarget != null) &&
! (oldTarget.getType() instanceof PrimType) &&
! (exp.getArgs()[0] instanceof ApplyExp) &&
! (((ApplyExp)exp.getArgs()[0]).getFunction() instanceof QuoteExp) &&
! (((QuoteExp)((ApplyExp)exp.getArgs()[0]).getFunction()).getValue() instanceof OptionOr))
! {
! type.emitCoerceFromObject(code);
! return;
! }
/*
If we changed the target, we also have to use the old one.
|