[Nice-commit] Nice/stdlib/nice/lang/inline ReferenceOp.java,1.9,1.10
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2005-02-11 15:37:13
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25830/stdlib/nice/lang/inline Modified Files: ReferenceOp.java Log Message: Factored compileJump and compileJumpNot by xoring the conditions with a flag representing whether we do "Not", or not. Index: ReferenceOp.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/ReferenceOp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ReferenceOp.java 11 Feb 2005 01:39:36 -0000 1.9 --- ReferenceOp.java 11 Feb 2005 15:37:03 -0000 1.10 *************** *** 140,143 **** --- 140,154 ---- public void compileJump (Compilation comp, Expression[] args, Label to) { + compileJump(comp, args, to, false); + } + + public void compileJumpNot (Compilation comp, Expression[] args, Label to) + { + compileJump(comp, args, to, true); + } + + private void compileJump (Compilation comp, Expression[] args, Label to, + boolean not) + { CodeAttr code = comp.getCode(); Target stack = Target.pushObject; *************** *** 149,153 **** { compile(args, comp, StackTarget.getInstance(Type.boolean_type)); ! code.emitGotoIfIntNeZero(to); } --- 160,167 ---- { compile(args, comp, StackTarget.getInstance(Type.boolean_type)); ! if (not) ! code.emitGotoIfIntEqZero(to); ! else ! code.emitGotoIfIntNeZero(to); } *************** *** 157,161 **** if (args[1].getType() instanceof PrimType) { ! if (kind == Ne) code.emitGoto(to); --- 171,175 ---- if (args[1].getType() instanceof PrimType) { ! if (not ^ kind == Ne) code.emitGoto(to); *************** *** 164,172 **** args[1].compile(comp, stack); ! if (kind == Eq) code.emitGotoIfNull(to); else code.emitGotoIfNotNull(to); - } else if (args[1] instanceof QuoteExp && --- 178,185 ---- args[1].compile(comp, stack); ! if (not ^ kind == Eq) code.emitGotoIfNull(to); else code.emitGotoIfNotNull(to); } else if (args[1] instanceof QuoteExp && *************** *** 175,179 **** if (args[0].getType() instanceof PrimType) { ! if (kind == Ne) code.emitGoto(to); --- 188,192 ---- if (args[0].getType() instanceof PrimType) { ! if (not ^ kind == Ne) code.emitGoto(to); *************** *** 182,190 **** args[0].compile(comp, stack); ! if (kind == Eq) code.emitGotoIfNull(to); else code.emitGotoIfNotNull(to); - } else --- 195,202 ---- args[0].compile(comp, stack); ! if (not ^ kind == Eq) code.emitGotoIfNull(to); else code.emitGotoIfNotNull(to); } else *************** *** 192,262 **** args[0].compile(comp, stack); args[1].compile(comp, stack); ! if (kind == Eq) code.emitGotoIfEq(to); else code.emitGotoIfNE(to); - - } - } - - public void compileJumpNot (Compilation comp, Expression[] args, Label to) - { - CodeAttr code = comp.getCode(); - Target stack = Target.pushObject; - - boolean prim0 = args[0].getType() instanceof PrimType; - boolean prim1 = args[1].getType() instanceof PrimType; - - if (prim1 && ! prim0 || prim0 && ! prim1) - { - compile(args, comp, StackTarget.getInstance(Type.boolean_type)); - code.emitGotoIfIntEqZero(to); - } - - else if (args[0] instanceof QuoteExp && - ((QuoteExp)args[0]).getType() == Type.nullType) - { - if (args[1].getType() instanceof PrimType) - { - if (kind == Eq) - code.emitGoto(to); - - return; - } - - args[1].compile(comp, stack); - if (kind == Eq) - code.emitGotoIfNotNull(to); - else - code.emitGotoIfNull(to); - - } - else if (args[1] instanceof QuoteExp && - ((QuoteExp)args[1]).getType() == Type.nullType) - { - if (args[0].getType() instanceof PrimType) - { - if (kind == Eq) - code.emitGoto(to); - - return; - } - - args[0].compile(comp, stack); - if (kind == Eq) - code.emitGotoIfNotNull(to); - else - code.emitGotoIfNull(to); - - } - else - { - args[0].compile(comp, stack); - args[1].compile(comp, stack); - if (kind == Eq) - code.emitGotoIfNE(to); - else - code.emitGotoIfEq(to); - } } --- 204,211 ---- args[0].compile(comp, stack); args[1].compile(comp, stack); ! if (not ^ kind == Eq) code.emitGotoIfEq(to); else code.emitGotoIfNE(to); } } |