[Pixelle-commit] SF.net SVN: pixelle: [76] trunk/pixelle/etc/Pixelle.g
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-06-25 04:48:56
|
Revision: 76
http://pixelle.svn.sourceforge.net/pixelle/?rev=76&view=rev
Author: dbrosius
Date: 2008-06-24 21:49:04 -0700 (Tue, 24 Jun 2008)
Log Message:
-----------
add equalities (==, !=)
Modified Paths:
--------------
trunk/pixelle/etc/Pixelle.g
Modified: trunk/pixelle/etc/Pixelle.g
===================================================================
--- trunk/pixelle/etc/Pixelle.g 2008-06-25 04:09:03 UTC (rev 75)
+++ trunk/pixelle/etc/Pixelle.g 2008-06-25 04:49:04 UTC (rev 76)
@@ -57,7 +57,8 @@
expr
{
mv.visitInsn(Opcodes.DRETURN);
- mv.visitMaxs(0,0);cw.visitEnd();
+ mv.visitMaxs(0,0);
+ cw.visitEnd();
} ;
expr :
@@ -73,9 +74,9 @@
cond_or_expr
( '?'
{
+ mv.visitInsn(Opcodes.DCONST_1); //TRUE
+ mv.visitInsn(Opcodes.DCMPG);
falseLabel = new Label();
- mv.visitLdcInsn(Double.valueOf(0));
- mv.visitInsn(Opcodes.DCMPG);
mv.visitJumpInsn(Opcodes.IFNE, falseLabel);
}
expr ':'
@@ -96,8 +97,34 @@
cond_and_expr :
eq_expr ( '||' eq_expr )* ;
-eq_expr :
- rel_expr ( op=('==' | '!=') rel_expr {} )* ;
+eq_expr
+@init
+ {
+ Label cmpSucceedLabel = null;
+ Label continueLabel = null;
+ }
+ :
+ rel_expr
+ ( op=('==' | '!=') rel_expr
+ {
+ mv.visitInsn(Opcodes.DCMPG);
+ cmpSucceedLabel = new Label();
+ if ("==".equals($op.text))
+ {
+ mv.visitJumpInsn(Opcodes.IFEQ, cmpSucceedLabel);
+ }
+ else
+ {
+ mv.visitJumpInsn(Opcodes.IFNE, cmpSucceedLabel);
+ }
+ mv.visitInsn(Opcodes.DCONST_0); //FALSE
+ continueLabel = new Label();
+ mv.visitJumpInsn(Opcodes.GOTO, continueLabel);
+ mv.visitLabel(cmpSucceedLabel);
+ mv.visitInsn(Opcodes.DCONST_1); //TRUE
+ mv.visitLabel(continueLabel);
+ }
+ )* ;
rel_expr :
add_expr ( rel_op add_expr )* ;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|