[Nice-commit] Nice/src/nice/tools/code Gen.java,1.8,1.9
Brought to you by:
bonniot
|
From: <ar...@us...> - 2003-03-29 19:26:26
|
Update of /cvsroot/nice/Nice/src/nice/tools/code
In directory sc8-pr-cvs1:/tmp/cvs-serv14029/F:/nice/src/nice/tools/code
Modified Files:
Gen.java
Log Message:
Last part of improvement of bytecode generation of operators, the dispatch methods makes use of the improvements now.
Also removed references to IsNullproc, InstanceOfProc and OrProc because in nice.lang.inline is the same functionality provided.
Index: Gen.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Gen.java 2 Sep 2002 11:46:37 -0000 1.8
--- Gen.java 29 Mar 2003 19:26:23 -0000 1.9
***************
*** 22,49 ****
public class Gen
{
- /**
- Code that returns true if either expression is true.
- Evaluates both expressions.
- */
- public static Expression or(Expression e1, Expression e2)
- {
- return new ApplyExp(orProc, new Expression[]{ e1, e2 });
- }
-
- /**
- Procedure to emit <code>or</code>.
- Shared since it is not parametrized.
- */
- private static final Expression orProc =
- new gnu.expr.QuoteExp(new nice.tools.code.OrProc());
public static Expression instanceOfExp(Expression value, Type ct)
{
! // If matching against primitive types,
! // we know the runtime type will be the corresponding object class.
if (ct instanceof PrimType)
! ct = Types.equivalentObjectType(ct);
! return Inline.inline(new InstanceOfProc(ct), value);
}
--- 22,35 ----
public class Gen
{
public static Expression instanceOfExp(Expression value, Type ct)
{
! // don't do an instanceof on primitive types. This special case
! // should not happen and should be removed when pattern.java is fixed
if (ct instanceof PrimType)
! return QuoteExp.trueExp;
! return Inline.inline(nice.lang.inline.Instanceof.instance, value,
! new QuoteExp(ct));
}
***************
*** 52,55 ****
--- 38,74 ----
return Inline.inline(new IsOfClassProc(ct), value);
}
+
+ public static Expression isNullExp(Expression value)
+ {
+ return Inline.inline(nice.lang.inline.ReferenceOp.create("=="), value,
+ QuoteExp.nullExp);
+ }
+
+ public static Expression boolNotExp(Expression value)
+ {
+ return Inline.inline(nice.lang.inline.BoolNotOp.instance, value);
+ }
+
+ public static Expression integerComparison(String kind, Expression value1,
+ long value2)
+ {
+ char type = value1.getType().getSignature().charAt(0);
+ if (type == 'J')
+ return Inline.inline(nice.lang.inline.CompOp.create("l"+kind), value1,
+ new gnu.expr.QuoteExp(new Long(value2), gnu.bytecode.Type.long_type));
+
+ if (type == 'B' || type == 'S' || type == 'I' || type == 'C')
+ return Inline.inline(nice.lang.inline.CompOp.create("i"+kind), value1,
+ new gnu.expr.QuoteExp(new Long(value2), gnu.bytecode.Type.int_type));
+
+ throw bossa.util.Internal.error("not an integer type");
+ }
+
+ public static Expression shortCircuitAnd(Expression value1, Expression value2)
+ {
+ return Inline.inline(nice.lang.inline.ShortCircuitOp.create("&&"), value1,
+ value2);
+ }
+
/**
|