nice-commit Mailing List for The Nice Programming Language (Page 119)
Brought to you by:
bonniot
You can subscribe to this list here.
2003 |
Jan
|
Feb
(60) |
Mar
(125) |
Apr
(183) |
May
(140) |
Jun
(227) |
Jul
(141) |
Aug
(181) |
Sep
(75) |
Oct
(89) |
Nov
(187) |
Dec
(162) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(69) |
Feb
(197) |
Mar
(98) |
Apr
(26) |
May
(10) |
Jun
(85) |
Jul
(88) |
Aug
(79) |
Sep
(80) |
Oct
(81) |
Nov
(53) |
Dec
(109) |
2005 |
Jan
(68) |
Feb
(77) |
Mar
(232) |
Apr
(79) |
May
(37) |
Jun
(37) |
Jul
(3) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
(10) |
Feb
|
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
(9) |
2007 |
Jan
(2) |
Feb
(8) |
Mar
(2) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
|
Oct
|
Nov
(17) |
Dec
(6) |
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <bo...@us...> - 2003-04-02 16:52:52
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions In directory sc8-pr-cvs1:/tmp/cvs-serv24373/testsuite/compiler/expressions Modified Files: conditional.testsuite Log Message: Check that variable capture inside if expressions if detected. Index: conditional.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/conditional.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** conditional.testsuite 16 Jan 2003 23:56:45 -0000 1.2 --- conditional.testsuite 2 Apr 2003 16:52:40 -0000 1.3 *************** *** 11,12 **** --- 11,18 ---- var int nameX = 1; int dummy() = false ? 0 : nameX; + + /// PASS + int i = 0; + void f() { if (true) i++; } + f(); + assert i == 1; |
From: <bo...@us...> - 2003-04-02 16:44:54
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv18474/stdlib/nice/lang/inline Modified Files: OptionOr.java Log Message: A simpler fix for OptionOr, when the first argument has an optional primitive type. Index: OptionOr.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/OptionOr.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OptionOr.java 30 Mar 2003 21:49:53 -0000 1.3 --- OptionOr.java 2 Apr 2003 16:44:50 -0000 1.4 *************** *** 38,72 **** Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); - Label _end = new Label(code); ! fixAndLoadArgument(args[0], comp, target); code.emitDup(); ! code.emitGotoIfNotNull(_end); code.emitPop(1); ! fixAndLoadArgument(args[1], comp, target); ! _end.define(code); } - - private void fixAndLoadArgument(Expression arg, Compilation comp, Target target) - { - if (arg instanceof ReferenceExp && ((ReferenceExp)arg).getBinding() != null) - { - Declaration.followAliases(((ReferenceExp)arg).getBinding()).load(comp); - return; - } - if ((arg instanceof ApplyExp) && (((ApplyExp)arg).getFunction() instanceof QuoteExp)) - { - Object ensTP = ((QuoteExp)((ApplyExp)arg).getFunction()).getValue(); - if (ensTP != null && (ensTP instanceof EnsureTypeProc)) - { - Target t = new CheckedTarget(((EnsureTypeProc)ensTP).getReturnType(((ApplyExp)arg).getArgs()), - "nice.tools.code.EnsureTypeProc", gnu.mapping.WrongType.ARG_DESCRIPTION); - ((ApplyExp)arg).getArgs()[0].compile(comp, t); - return; - } - } - arg.compile(comp, target); - } - public Type getReturnType (Expression[] args) --- 38,53 ---- Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); ! // We cannot use target for the first argument, since its value maybe ! // be null, while the target may not. ! args[0].compile(comp, Target.pushObject); code.emitDup(); ! code.emitIfNotNull(); ! target.compileFromStack(comp, code.topType()); ! code.emitElse(); code.emitPop(1); ! args[1].compile(comp, target); ! code.emitFi(); } public Type getReturnType (Expression[] args) |
From: <bo...@us...> - 2003-04-02 16:44:53
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/operators In directory sc8-pr-cvs1:/tmp/cvs-serv18474/testsuite/compiler/expressions/operators Modified Files: null.testsuite Log Message: A simpler fix for OptionOr, when the first argument has an optional primitive type. Index: null.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/null.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** null.testsuite 29 Mar 2003 20:18:52 -0000 1.4 --- null.testsuite 2 Apr 2003 16:44:49 -0000 1.5 *************** *** 32,36 **** } ! /// PASS bug Map<String,int> map = new HashMap(); String s = "abc"; --- 32,41 ---- } ! /// PASS ! ?int i = 1; ! int j = i || 0; ! assert j == 1; ! ! /// PASS Map<String,int> map = new HashMap(); String s = "abc"; *************** *** 38,39 **** --- 43,47 ---- int i = map.get(s) || 0; assert(i==1); + + /// PASS + int[] i = [1,2] || [3,4]; |
From: <bo...@us...> - 2003-04-02 16:44:53
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv18474/src/nice/tools/code Modified Files: EnsureTypeProc.java Log Message: A simpler fix for OptionOr, when the first argument has an optional primitive type. Index: EnsureTypeProc.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/EnsureTypeProc.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EnsureTypeProc.java 30 Mar 2003 21:49:53 -0000 1.4 --- EnsureTypeProc.java 2 Apr 2003 16:44:50 -0000 1.5 *************** *** 63,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. --- 63,66 ---- |
From: <ar...@us...> - 2003-04-02 16:18:54
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/operators In directory sc8-pr-cvs1:/tmp/cvs-serv1486/F:/nice/testsuite/compiler/expressions/operators Modified Files: boolean.testsuite Log Message: Aditional tests for the optimized operators. Index: boolean.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/boolean.testsuite,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** boolean.testsuite 24 Sep 2002 11:38:20 -0000 1.1 --- boolean.testsuite 2 Apr 2003 16:18:50 -0000 1.2 *************** *** 64,65 **** --- 64,82 ---- /// PASS assert (! (false && fail())); + + /// COMMENT tests to assure the optimized operators don't break the stack + /// PASS + boolean b = true; + b = b ? true : 1==3||4!=4||false; + + /// PASS + boolean b = false; + b = b ? 1<2<=3<4 : false != true; + + /// PASS + boolean b = true; + b = b ? false||1!=0&&1>=5 : false | true & true; + + /// PASS + boolean b = true; + b = true ? b^b||10>3<6 : false ^ b && 0 != 5; |
From: <bo...@us...> - 2003-04-02 15:56:24
|
Update of /cvsroot/nice/Nice/regtest/basic In directory sc8-pr-cvs1:/tmp/cvs-serv21094/regtest/basic Modified Files: methods.nice Log Message: Test dispatch on null values, rather than relying on notNull, which is a feature unrelated to methods. Index: methods.nice =================================================================== RCS file: /cvsroot/nice/Nice/regtest/basic/methods.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** methods.nice 18 Sep 2001 12:39:55 -0000 1.2 --- methods.nice 2 Apr 2003 15:56:18 -0000 1.3 *************** *** 4,10 **** class C2 extends C1 {} ! String name(C1); name(c@C1) = "C1"; name(c@C2) = "C2"; void test_methods(); --- 4,11 ---- class C2 extends C1 {} ! String name(?C1); name(c@C1) = "C1"; name(c@C2) = "C2"; + name(@null) = "NULL class"; void test_methods(); *************** *** 15,23 **** println(name(new C2())); ?C1 c = null; ! try{ ! println(name(notNull(c))); ! } ! catch(NullPointerException ex){ ! println("NULL class"); ! } } --- 16,19 ---- println(name(new C2())); ?C1 c = null; ! println(name(c)); } |
From: <ar...@us...> - 2003-04-01 21:12:34
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang In directory sc8-pr-cvs1:/tmp/cvs-serv22151/F:/nice/stdlib/nice/lang Modified Files: BooleanAlgebra.nice booleans.nice Log Message: undeleted default implementation of '^' and added a comment. Index: BooleanAlgebra.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/BooleanAlgebra.nice,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BooleanAlgebra.nice 23 Mar 2003 00:05:48 -0000 1.2 --- BooleanAlgebra.nice 1 Apr 2003 20:51:40 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- } + `^`(x, y) = (x & !y) | (!x & y); `->`(x, y, z) = (x & y) | (!x & z); Index: booleans.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/booleans.nice,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** booleans.nice 23 Mar 2003 00:05:48 -0000 1.8 --- booleans.nice 1 Apr 2003 20:51:40 -0000 1.9 *************** *** 10,15 **** boolean `==`(boolean, boolean) = inline nice.lang.inline.BoolOp("=="); boolean `!=`(boolean, boolean) = inline nice.lang.inline.BoolOp("^"); - boolean TRUE() = native Boolean.TRUE; --- 10,15 ---- boolean `==`(boolean, boolean) = inline nice.lang.inline.BoolOp("=="); + //for booleans is '!=' equal to '^' boolean `!=`(boolean, boolean) = inline nice.lang.inline.BoolOp("^"); boolean TRUE() = native Boolean.TRUE; |
From: <ar...@us...> - 2003-04-01 20:25:42
|
Update of /cvsroot/nice/Nice/testsuite/compiler/methods In directory sc8-pr-cvs1:/tmp/cvs-serv10514/F:/nice/testsuite/compiler/methods Modified Files: integer.testsuite Log Message: @type patterns are automatic replaced by at any patterns if the type is equal to the type of the declaration. All @type and #type patterns where type is a primitive type after the previous replacement will yield an error because instanceof a primitve type make no sense (yet). An exception is made for boolean, so instanceof boolean is made to work now. Index: integer.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/methods/integer.testsuite,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** integer.testsuite 25 Feb 2003 20:08:02 -0000 1.2 --- integer.testsuite 1 Apr 2003 20:25:08 -0000 1.3 *************** *** 72,73 **** --- 72,85 ---- toStr(c@'a') = "a"; toStr(c@'b') = "b"; + + /// FAIL + /// Toplevel + void foo(long); + foo(@long) {} + foo(@int) {} + + /// FAIL + /// Toplevel + void foo(long); + foo(@long) {} + foo(#int) {} |
From: <ar...@us...> - 2003-04-01 20:25:41
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv10514/F:/nice/src/nice/tools/code Modified Files: Gen.java Log Message: @type patterns are automatic replaced by at any patterns if the type is equal to the type of the declaration. All @type and #type patterns where type is a primitive type after the previous replacement will yield an error because instanceof a primitve type make no sense (yet). An exception is made for boolean, so instanceof boolean is made to work now. Index: Gen.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/code/Gen.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Gen.java 29 Mar 2003 19:26:23 -0000 1.9 --- Gen.java 1 Apr 2003 20:25:07 -0000 1.10 *************** *** 25,33 **** 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)); --- 25,28 ---- |
From: <ar...@us...> - 2003-04-01 20:25:39
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv10514/F:/nice/src/bossa/syntax Modified Files: Pattern.java MethodBodyDefinition.java Log Message: @type patterns are automatic replaced by at any patterns if the type is equal to the type of the declaration. All @type and #type patterns where type is a primitive type after the previous replacement will yield an error because instanceof a primitve type make no sense (yet). An exception is made for boolean, so instanceof boolean is made to work now. Index: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Pattern.java 29 Mar 2003 19:26:23 -0000 1.43 --- Pattern.java 1 Apr 2003 20:24:57 -0000 1.44 *************** *** 369,374 **** if (exactlyAt) return Typing.testRigidLeq(tag, tc) && Typing.testRigidLeq(tc, tag); ! else ! return Typing.testRigidLeq(tag, tc); } --- 369,374 ---- if (exactlyAt) return Typing.testRigidLeq(tag, tc) && Typing.testRigidLeq(tc, tag); ! ! return Typing.testRigidLeq(tag, tc); } *************** *** 377,394 **** if (atAny()) return true; ! if (atIntValue) ! return this.value == val; ! return atPrimTypeFitting(val); } ! //TODO: call this from methodbodydefition when the pattern has the same ! //type as the the methoddeclaration ! public void setAtAny() { // only set it to atAny if it's a @type pattern ! if (atValue == null && !exactlyAt && !atIntValue) tc = null; - } /**************************************************************** * Printing --- 377,401 ---- if (atAny()) return true; ! ! return atIntValue && this.value == val; } ! public void setDomainEq(boolean equal) { // only set it to atAny if it's a @type pattern ! if (equal && atValue == null && !exactlyAt && !atIntValue) tc = null; + // don't allow primitive types(except boolean) in @type and #type patterns + if (!equal && !atBool() && !atIntValue && ( + tc == PrimitiveType.longTC || + tc == PrimitiveType.intTC || + tc == PrimitiveType.shortTC || + tc == PrimitiveType.charTC || + tc == PrimitiveType.byteTC) ) + User.error(typeConstructor,"A pattern cannot have a primitive type that is different from the declararion."); + + } + /**************************************************************** * Printing *************** *** 602,612 **** public boolean atFalse() { return atBool() && atValue.toString().equals("false"); - } - public boolean atPrimTypeFitting(long val){ - return ( tc == PrimitiveType.longTC ) || - (tc == PrimitiveType.intTC && val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) || - (tc == PrimitiveType.shortTC && val >= Short.MIN_VALUE && val <= Short.MAX_VALUE) || - (tc == PrimitiveType.charTC && val >= Character.MIN_VALUE && val <= Character.MAX_VALUE) || - (tc == PrimitiveType.byteTC && val >= Byte.MIN_VALUE && val <= Byte.MAX_VALUE); } --- 609,612 ---- Index: MethodBodyDefinition.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/MethodBodyDefinition.java,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** MethodBodyDefinition.java 14 Mar 2003 00:55:26 -0000 1.114 --- MethodBodyDefinition.java 1 Apr 2003 20:25:01 -0000 1.115 *************** *** 409,412 **** --- 409,420 ---- } + for(int n = 0; n < formals.length; n++) + { + TypeConstructor tc = Types.rawType(domain[n]).head(); + if (tc != null && formals[n].tc != null) + formals[n].setDomainEq(Typing.testRigidLeq(tc, formals[n].tc)); + + } + Node.currentFunction = this; if (insideClass) |
From: <ar...@us...> - 2003-04-01 20:25:15
|
Update of /cvsroot/nice/Nice/testsuite/compiler/native In directory sc8-pr-cvs1:/tmp/cvs-serv10514/F:/nice/testsuite/compiler/native Modified Files: instanceof.testsuite Log Message: @type patterns are automatic replaced by at any patterns if the type is equal to the type of the declaration. All @type and #type patterns where type is a primitive type after the previous replacement will yield an error because instanceof a primitve type make no sense (yet). An exception is made for boolean, so instanceof boolean is made to work now. Index: instanceof.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/native/instanceof.testsuite,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** instanceof.testsuite 20 Feb 2003 15:05:15 -0000 1.4 --- instanceof.testsuite 1 Apr 2003 20:25:10 -0000 1.5 *************** *** 30,31 **** --- 30,37 ---- /// FAIL boolean b = /* /// FAIL HERE */ 1 instanceof int; + + /// PASS + if (true instanceof boolean) + ; + else + throw new Error(); |
From: <ar...@us...> - 2003-04-01 20:25:14
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv10514/F:/nice/stdlib/nice/lang/inline Modified Files: Instanceof.java Log Message: @type patterns are automatic replaced by at any patterns if the type is equal to the type of the declaration. All @type and #type patterns where type is a primitive type after the previous replacement will yield an error because instanceof a primitve type make no sense (yet). An exception is made for boolean, so instanceof boolean is made to work now. Index: Instanceof.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/Instanceof.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Instanceof.java 20 Feb 2003 15:05:16 -0000 1.2 --- Instanceof.java 1 Apr 2003 20:25:09 -0000 1.3 *************** *** 43,46 **** --- 43,50 ---- Type type = (Type) ((QuoteExp) args[1]).getValue(); + // instanceof on boolean can make sense + if (type == Type.boolean_type) + type = Type.boolean_ctype; + if (type instanceof PrimType) throw new bossa.util.UserError |
From: <ar...@us...> - 2003-03-31 19:15:22
|
Update of /cvsroot/nice/Nice/stdlib/nice/getopt In directory sc8-pr-cvs1:/tmp/cvs-serv15302/F:/nice/stdlib/nice/getopt Modified Files: getopt.nice Added Files: gnugetopt.nice Removed Files: wrapper.nice Log Message: Replaced the use of the getopt.jar with a version in Nice. --- NEW FILE: gnugetopt.nice --- /************************************************************************** /* Getopt.java -- Java port of GNU getopt from glibc 2.0.6 /* /* Copyright (c) 1987-1997 Free Software Foundation, Inc. /* Java Port Copyright (c) 1998 by Aaron M. Renn (ar...@ur...) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU Library General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This program is distributed in the hope that it will be useful, but /* WITHOUT ANY WARRANTY; without even the implied warranty of /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /* GNU Library General Public License for more details. /* /* You should have received a copy of the GNU Library General Public License /* along with this program; see the file COPYING.LIB. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ package nice.getopt; import java.text.*; public class Getopt { private final int REQUIRE_ORDER = 1; private final int PERMUTE = 2; private final int RETURN_IN_ORDER = 3; private ?String optarg = null; private ?String nextchar = null; private boolean posixly_correct = System.getProperty("gnu.posixly_correct", null) != null; private boolean longopt_handled = false; private boolean endparse = false; private boolean opterr = true; private int optopt = '?'; private int optind = 0; private int longind = 0; private int first_nonopt = 1; private int last_nonopt = 1; private const int ordering = 2;//== PERMUTE private String progname; private String[] argv; private String optstring = " "; private LongOpt[] long_options; private boolean long_only = false; //public Getopt(String progname, String[] argv, String optstring, // LongOpt[] long_options, boolean long_only) public void initGetopt() { // Determine how to handle the ordering of options and non-options if (optstring.charAt(0) == '-') { ordering = RETURN_IN_ORDER; if (optstring.length() > 1) this.optstring = optstring.substring(1); } else if (optstring.charAt(0) == '+') { ordering = REQUIRE_ORDER; if (optstring.length() > 1) this.optstring = optstring.substring(1); } else if (posixly_correct) { ordering = REQUIRE_ORDER; } } public void setOptstring(String optstring) { this.optstring = optstring.length() == 0 ? " " : optstring; } public int getOptind() = optind; public void setOptind(int optind) { this.optind = optind; } public void setArgv(String[] argv) { this.argv = argv; } public ?String getOptarg() = optarg; public void setOpterr(boolean opterr) { this.opterr = opterr; } public int getOptopt() = optopt; public int getLongind() = longind; private void exchange(String[] argv) { int bottom = first_nonopt; int middle = last_nonopt; int top = optind; String tem; while (top > middle && middle > bottom) { if (top - middle > middle - bottom) { // Bottom segment is the short one. int len = middle - bottom; int i; // Swap it with the top part of the top segment. for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; } // Exclude the moved bottom segment from further swapping. top -= len; } else { // Top segment is the short one. int len = top - middle; int i; // Swap it with the bottom part of the bottom segment. for (i = 0; i < len; i++) { tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; } // Exclude the moved top segment from further swapping. bottom += len; } } // Update records for the slots the non-options now occupy. first_nonopt += (optind - last_nonopt); last_nonopt = optind; } private int checkLongOption() { ?LongOpt pfound = null; int nameend; boolean ambig; boolean exact; longopt_handled = true; ambig = false; exact = false; longind = -1; nameend = (nextchar || "").indexOf("="); if (nameend == -1) nameend = (nextchar || "").length(); // Test all lnog options for either exact match or abbreviated matches for (int i = 0; i < long_options.length; i++) { if (long_options[i].getName().startsWith((nextchar || "").substring(0, nameend))) { if (long_options[i].getName().equals((nextchar || "").substring(0, nameend))) { // Exact match found pfound = long_options[i]; longind = i; exact = true; break; } else if (pfound == null) { // First nonexact match found pfound = long_options[i]; longind = i; } else { // Second or later nonexact match found ambig = true; } } } // for // Print out an error if the option specified was ambiguous if (ambig && !exact) { if (opterr) System.err.println(progname+": option '"+argv[optind]+ "' is ambiguous"); nextchar = ""; optopt = 0; ++optind; return('?'); } if (pfound != null) { ++optind; if (nameend != (nextchar || "").length()) { if (pfound.has_arg != NO_ARGUMENT) { if ((nextchar || "").substring(nameend).length() > 1) optarg = (nextchar || "").substring(nameend+1); else optarg = ""; } else { if (opterr) { // -- option if (argv[optind - 1].startsWith("--")) System.err.println(progname+": option '--"+pfound.name+"' doesn't allow an argument"); // +option or -option else System.err.println(progname+": option '"+argv[optind-1].charAt(0).toString()+"' doesn't allow an argument"); } nextchar = ""; optopt = pfound.val; return('?'); } } // if (nameend) else if (pfound.has_arg == REQUIRED_ARGUMENT) { if (optind < argv.length) { optarg = argv[optind]; ++optind; } else { if (opterr) System.err.println(progname+": option '"+argv[optind-1]+"' requires an argument"); nextchar = ""; optopt = pfound.val; return optstring.charAt(0) == ':' ? ':' : '?'; } } // else if (pfound) nextchar = ""; ?StringBuffer sb = pfound.flag; if (sb != null) { sb.setLength(0); sb.append(pfound.val); return(0); } return(pfound.val); } // if (pfound != null) longopt_handled = false; return(0); } public int getopt() { optarg = null; if (endparse == true) return(-1); if ((nextchar == null) || (nextchar.equals(""))) { // If we have just processed some options following some non-options, // exchange them so that the options come first. if (last_nonopt > optind) last_nonopt = optind; if (first_nonopt > optind) first_nonopt = optind; if (ordering == PERMUTE) { // If we have just processed some options following some non-options, // exchange them so that the options come first. if ((first_nonopt != last_nonopt) && (last_nonopt != optind)) this.exchange(argv); else if (last_nonopt != optind) first_nonopt = optind; // Skip any additional non-options // and extend the range of non-options previously skipped. while ((optind < argv.length) && (argv[optind].equals("") || (argv[optind].charAt(0) != '-') || argv[optind].equals("-"))) { optind++; } last_nonopt = optind; } // The special ARGV-element `--' means premature end of options. // Skip it like a null option, // then exchange with previous non-options as if it were an option, // then skip everything else like a non-option. if ((optind != argv.length) && argv[optind].equals("--")) { optind++; if ((first_nonopt != last_nonopt) && (last_nonopt != optind)) this.exchange(argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argv.length; optind = argv.length; } // If we have done all the ARGV-elements, stop the scan // and back over any non-options that we skipped and permuted. if (optind == argv.length) { // Set the next-arg-index to point at the non-options // that we previously skipped, so the caller will digest them. if (first_nonopt != last_nonopt) optind = first_nonopt; return(-1); } // If we have come to a non-option and did not permute it, // either stop the scan or describe it to the caller and pass it by. if (argv[optind].equals("") || (argv[optind].charAt(0) != '-') || argv[optind].equals("-")) { if (ordering == REQUIRE_ORDER) return(-1); optarg = argv[optind++]; return(1); } // We have found another option-ARGV-element. // Skip the initial punctuation. if (argv[optind].startsWith("--")) nextchar = argv[optind].substring(2); else nextchar = argv[optind].substring(1); } // Decode the current option-ARGV-element. /* Check whether the ARGV-element is a long option. If long_only and the ARGV-element has the form "-f", where f is a valid short option, don't consider it an abbreviated form of a long option that starts with f. Otherwise there would be no way to give the -f short option. On the other hand, if there's a long option "fubar" and the ARGV-element is "-fu", do consider that an abbreviation of the long option, just like "--fu", and not "-f" with arg "u". This distinction seems to be the most useful approach. */ if ((long_options != null) && (argv[optind].startsWith("--") || (long_only && ((argv[optind].length() > 2) || (optstring.indexOf(argv[optind].charAt(1)) == -1))))) { int c = this.checkLongOption(); if (longopt_handled) return(c); // Can't find it as a long option. If this is not getopt_long_only, // or the option starts with '--' or is not a valid short // option, then it's an error. // Otherwise interpret it as a short option. if (!long_only || argv[optind].startsWith("--") || (optstring.indexOf((nextchar || "").charAt(0)) == -1)) { if (opterr) { if (argv[optind].startsWith("--")) System.err.println(progname+": unrecognized option '--"+nextchar+"'"); else System.err.println(progname+": unrecognized option '--"+argv[optind].charAt(0).toString()+"'"); } nextchar = ""; ++optind; optopt = 0; return('?'); } } // if (longopts) // Look at and handle the next short option-character */ int c = (nextchar || "").charAt(0); //**** Do we need to check for empty str? if ((nextchar || "").length() > 1) nextchar = (nextchar || "").substring(1); else nextchar = ""; ?String temp = null; if (optstring.indexOf(c) != -1) temp = optstring.substring(optstring.indexOf(c)); if (nextchar.equals("")) ++optind; if ((temp == null) || (c == ':')) { if (opterr) { if (posixly_correct) System.err.println(progname+": illegal option -- "+this.toString()); else System.err.println(progname+": invalid option -- "+char(c).toString()); } optopt = c; return('?'); } // Convenience. Treat POSIX -W foo same as long option --foo if ((temp.charAt(0) == 'W') && (temp.length() > 1) && (temp.charAt(1) == ';')) { if (!nextchar.equals("")) { optarg = nextchar; } // No further cars in this argv element and no more argv elements else if (optind == argv.length) { if (opterr) System.err.println(progname+": option '"+char(c).toString()+"' doesn't allow an argument"); optopt = c; return optstring.charAt(0) == ':' ? ':' : '?'; } else { // We already incremented `optind' once; // increment it again when taking next ARGV-elt as argument. nextchar = argv[optind]; optarg = argv[optind]; } c = this.checkLongOption(); if (longopt_handled) return(c); else // Let the application handle it { nextchar = null; ++optind; return('W'); } } if ((temp.length() > 1) && (temp.charAt(1) == ':')) { if ((temp.length() > 2) && (temp.charAt(2) == ':')) // This is an option that accepts and argument optionally { if (!nextchar.equals("")) { optarg = nextchar; ++optind; } else { optarg = null; } nextchar = null; } else { if (!nextchar.equals("")) { optarg = nextchar; ++optind; } else if (optind == argv.length) { if (opterr) System.err.println(progname+": option requires an argument -- "+char(c).toString()); optopt = c; return optstring.charAt(0) == ':' ? ':' : '?'; } else { optarg = argv[optind]; ++optind; // Ok, here's an obscure Posix case. If we have o:, and // we get -o -- foo, then we're supposed to skip the --, // end parsing of options, and make foo an operand to -o. // Only do this in Posix mode. if ((posixly_correct) && optarg.equals("--")) { // If end of argv, error out if (optind == argv.length) { if (opterr) System.err.println(progname+": option requires an argument -- "+char(c).toString()); optopt = c; return optstring.charAt(0) == ':' ? ':' : '?'; } // Set new optarg and set to end // Don't permute as we do on -- up above since we // know we aren't in permute mode because of Posix. optarg = argv[optind]; ++optind; first_nonopt = optind; last_nonopt = argv.length; endparse = true; } } nextchar = null; } } return(c); } } // Class Getopt var int NO_ARGUMENT = 0; var int REQUIRED_ARGUMENT = 1; var int OPTIONAL_ARGUMENT = 2; public class LongOpt { private String name; private int has_arg; private ?StringBuffer flag = null; private int val; public void initLongOpt() //throws IllegalArgumentException { // Validate has_arg if ((has_arg != NO_ARGUMENT) && (has_arg != REQUIRED_ARGUMENT) && (has_arg != OPTIONAL_ARGUMENT)) { throw new IllegalArgumentException("Invalid value "+has_arg.toString()+" for parameter 'has_arg'"); } } public String getName() = name; public int getHasArg() = has_arg; public ?StringBuffer getFlag() = flag; public int getVal() = val; } // Class LongOpt Index: getopt.nice =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/getopt/getopt.nice,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** getopt.nice 24 Jan 2003 12:36:47 -0000 1.14 --- getopt.nice 31 Mar 2003 19:15:11 -0000 1.15 *************** *** 2,7 **** package nice.getopt; - import gnu.getopt.*; - /** Parses the list of strings according to the options, and returns the non-options arguments. */ --- 2,5 ---- *************** *** 11,17 **** int optType(Option); ! optType(o@NoParamOption) = LongOpt.NO_ARGUMENT(); ! optType(o@ParamOption) = LongOpt.REQUIRED_ARGUMENT(); ! optType(o@OptionalParamOption) = LongOpt.OPTIONAL_ARGUMENT(); String optSuffix(Option); --- 9,15 ---- int optType(Option); ! optType(o@NoParamOption) = NO_ARGUMENT; ! optType(o@ParamOption) = REQUIRED_ARGUMENT; ! optType(o@OptionalParamOption) = OPTIONAL_ARGUMENT; String optSuffix(Option); *************** *** 33,41 **** { uniqId = uniqId+1; ! l = new LongOpt(o.longName,optType(o),null,uniqId); } else ! l = new LongOpt(o.longName,optType(o),null,o.shortName); ! o.optval = l.getVal(); --- 31,39 ---- { uniqId = uniqId+1; ! l = new LongOpt(name:o.longName, has_arg:optType(o), val:uniqId); } else ! l = new LongOpt(name:o.longName,has_arg:optType(o),val:o.shortName); ! l.initLongOpt(); o.optval = l.getVal(); *************** *** 50,55 **** for (int i = 0; i < longOpts.length; i++) longOpts[i] = longOptions.get(i); ! Getopt g = newGetopt(progName, args, shortOptions, longOpts); ! // Parsing loop int c = g.getopt(); --- 48,54 ---- for (int i = 0; i < longOpts.length; i++) longOpts[i] = longOptions.get(i); ! Getopt g = new Getopt(progname: progName, argv: args, optstring: shortOptions, ! long_options: cast(longOpts)); ! g.initGetopt(); // Parsing loop int c = g.getopt(); --- wrapper.nice DELETED --- |
From: <ar...@us...> - 2003-03-31 15:21:05
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv5983/F:/nice/src/nice/tools/code Removed Files: InstanceOfProc.java Log Message: Removed IsNullProc, InstanceOfProc and OrProc because they aren't used anymore and in nice.lang.inline is the same functionality provided. --- InstanceOfProc.java DELETED --- |
From: <ar...@us...> - 2003-03-31 15:00:31
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv5723/F:/nice/src/nice/tools/code Removed Files: IsNullProc.java Log Message: Removed IsNullProc, InstanceOfProc and OrProc because they aren't used anymore and in nice.lang.inline is the same functionality provided. --- IsNullProc.java DELETED --- |
From: <ar...@us...> - 2003-03-31 14:59:42
|
Update of /cvsroot/nice/Nice/src/nice/tools/code In directory sc8-pr-cvs1:/tmp/cvs-serv5424/F:/nice/src/nice/tools/code Removed Files: OrProc.java Log Message: Removed IsNullProc, InstanceOfProc and OrProc because they aren't used anymore and in nice.lang.inline is the same functionality provided. --- OrProc.java DELETED --- |
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. |
From: <ar...@us...> - 2003-03-30 21:49:56
|
Update of /cvsroot/nice/Nice/stdlib/nice/lang/inline In directory sc8-pr-cvs1:/tmp/cvs-serv26306/F:/nice/stdlib/nice/lang/inline Modified Files: OptionOr.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: OptionOr.java =================================================================== RCS file: /cvsroot/nice/Nice/stdlib/nice/lang/inline/OptionOr.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OptionOr.java 19 Feb 2003 14:19:40 -0000 1.2 --- OptionOr.java 30 Mar 2003 21:49:53 -0000 1.3 *************** *** 16,19 **** --- 16,20 ---- import gnu.expr.*; import gnu.bytecode.*; + import nice.tools.code.EnsureTypeProc; /** *************** *** 37,49 **** Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); ! args[0].compile(comp, target); code.emitDup(); ! code.emitIfNull(); code.emitPop(1); ! args[1].compile(comp, target); ! code.emitElse(); ! code.emitFi(); } public Type getReturnType (Expression[] args) --- 38,72 ---- Expression[] args = exp.getArgs(); CodeAttr code = comp.getCode(); + Label _end = new Label(code); ! fixAndLoadArgument(args[0], comp, target); code.emitDup(); ! code.emitGotoIfNotNull(_end); code.emitPop(1); ! fixAndLoadArgument(args[1], comp, target); ! _end.define(code); } + + private void fixAndLoadArgument(Expression arg, Compilation comp, Target target) + { + if (arg instanceof ReferenceExp && ((ReferenceExp)arg).getBinding() != null) + { + Declaration.followAliases(((ReferenceExp)arg).getBinding()).load(comp); + return; + } + if ((arg instanceof ApplyExp) && (((ApplyExp)arg).getFunction() instanceof QuoteExp)) + { + Object ensTP = ((QuoteExp)((ApplyExp)arg).getFunction()).getValue(); + if (ensTP != null && (ensTP instanceof EnsureTypeProc)) + { + Target t = new CheckedTarget(((EnsureTypeProc)ensTP).getReturnType(((ApplyExp)arg).getArgs()), + "nice.tools.code.EnsureTypeProc", gnu.mapping.WrongType.ARG_DESCRIPTION); + ((ApplyExp)arg).getArgs()[0].compile(comp, t); + return; + } + } + arg.compile(comp, target); + } + public Type getReturnType (Expression[] args) |
From: <ar...@us...> - 2003-03-29 20:19:01
|
Update of /cvsroot/nice/Nice/testsuite/compiler/expressions/operators In directory sc8-pr-cvs1:/tmp/cvs-serv4189/F:/nice/testsuite/compiler/expressions/operators Modified Files: null.testsuite Log Message: fix typo in testcase Index: null.testsuite =================================================================== RCS file: /cvsroot/nice/Nice/testsuite/compiler/expressions/operators/null.testsuite,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** null.testsuite 27 Mar 2003 23:42:26 -0000 1.3 --- null.testsuite 29 Mar 2003 20:18:52 -0000 1.4 *************** *** 37,39 **** map.put(s,1); int i = map.get(s) || 0; ! assert(i==0); --- 37,39 ---- map.put(s,1); int i = map.get(s) || 0; ! assert(i==1); |
From: <ar...@us...> - 2003-03-29 19:26:27
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv14029/F:/nice/src/bossa/syntax Modified Files: Pattern.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: Pattern.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/Pattern.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Pattern.java 19 Mar 2003 21:19:47 -0000 1.42 --- Pattern.java 29 Mar 2003 19:26:23 -0000 1.43 *************** *** 537,541 **** { if (atNull()) ! return Inline.inline(IsNullProc.instance, parameter); if (atAny()) --- 537,541 ---- { if (atNull()) ! return Gen.isNullExp(parameter); if (atAny()) *************** *** 545,556 **** { if (atFalse()) ! return Inline.inline(nice.lang.inline.BoolNotOp.instance, parameter); return parameter; } if (atIntValue) ! return Inline.inline(nice.lang.inline.CompOp.create("lEq"), ! new gnu.expr.QuoteExp(new Long(value), gnu.bytecode.Type.long_type), ! parameter); gnu.bytecode.Type ct = nice.tools.code.Types.javaType(tc); --- 545,554 ---- { if (atFalse()) ! return Gen.boolNotExp(parameter); return parameter; } if (atIntValue) ! return Gen.integerComparison("Eq", parameter, value); gnu.bytecode.Type ct = nice.tools.code.Types.javaType(tc); *************** *** 567,571 **** //return QuoteExp.trueExp; ! return InstanceOfProc.instanceOfExp(parameter, ct); } --- 565,569 ---- //return QuoteExp.trueExp; ! return Gen.instanceOfExp(parameter, ct); } |
From: <ar...@us...> - 2003-03-29 19:26:27
|
Update of /cvsroot/nice/Nice/debian In directory sc8-pr-cvs1:/tmp/cvs-serv14029/F:/nice/debian Modified Files: changelog 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: changelog =================================================================== RCS file: /cvsroot/nice/Nice/debian/changelog,v retrieving revision 1.145 retrieving revision 1.146 diff -C2 -d -r1.145 -r1.146 *** changelog 23 Mar 2003 23:03:04 -0000 1.145 --- changelog 29 Mar 2003 19:26:24 -0000 1.146 *************** *** 3,7 **** * Some error messages are more usefull. * All operators are inlined and some operators(&&, ||, ! and comparisons) ! generate better bytecode now. * Improved bytecode generation of pre\post-condition. * Implemented the enhanced for loop(similar to java 1.5 proposal). --- 3,7 ---- * Some error messages are more usefull. * All operators are inlined and some operators(&&, ||, ! and comparisons) ! and if-statements generate better bytecode now. * Improved bytecode generation of pre\post-condition. * Implemented the enhanced for loop(similar to java 1.5 proposal). |
From: <ar...@us...> - 2003-03-29 19:26:27
|
Update of /cvsroot/nice/Nice/src/bossa/link In directory sc8-pr-cvs1:/tmp/cvs-serv14029/F:/nice/src/bossa/link Modified Files: Alternative.java Compilation.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: Alternative.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Alternative.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Alternative.java 19 Mar 2003 21:14:29 -0000 1.39 --- Alternative.java 29 Mar 2003 19:26:24 -0000 1.40 *************** *** 25,28 **** --- 25,30 ---- import gnu.expr.*; + import nice.tools.code.Gen; + import java.util.*; *************** *** 144,153 **** " for " + this); Expression result = QuoteExp.trueExp; ! ! for(int n = parameters.length; --n >= 0; ) ! result = gnu.expr.IfExp.make(patterns[n].matchTest(parameters[n]), ! result, ! QuoteExp.falseExp); return result; --- 146,171 ---- " for " + this); + if (parameters.length == 0) + return QuoteExp.trueExp; + + if (parameters.length == 1) + return patterns[0].matchTest(parameters[0]); + Expression result = QuoteExp.trueExp; ! int index = 0; ! ! //find the first non-trivial test ! for(; index<parameters.length; index++) ! if (!patterns[index].atAny()) ! { ! result = patterns[index].matchTest(parameters[index]); ! index++; ! break; ! } ! ! for(; index<parameters.length; index++) ! if (!patterns[index].atAny()) ! result = Gen.shortCircuitAnd(result, ! patterns[index].matchTest(parameters[index])); return result; Index: Compilation.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/link/Compilation.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Compilation.java 25 Oct 2002 13:06:08 -0000 1.9 --- Compilation.java 29 Mar 2003 19:26:24 -0000 1.10 *************** *** 94,98 **** return matchCase; else ! return gnu.expr.IfExp.make (alt.matchTest(params), matchCase, --- 94,98 ---- return matchCase; else ! return gnu.expr.SimpleIfExp.make (alt.matchTest(params), matchCase, |
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); + } + /** |
From: <ar...@us...> - 2003-03-29 00:30:35
|
Update of /cvsroot/nice/Nice/src/gnu/expr In directory sc8-pr-cvs1:/tmp/cvs-serv15151/F:/nice/src/gnu/expr Added Files: SimpleIfExp.java Log Message: added SimpleIfExp to gnu.expr it can make use of the Branchable interface to generate better code. --- NEW FILE: SimpleIfExp.java --- package gnu.expr; import gnu.bytecode.*; import gnu.mapping.*; /** * A simplified IfExp that makes use of the Branchable interface */ public class SimpleIfExp extends IfExp { public SimpleIfExp (Expression i, Expression t, Expression e) { super(i,t,e); } public static Expression make(Expression i, Expression t, Expression e) { return new SimpleIfExp(i, t, e); } public void compile (Compilation comp, Target target) { compile(test, then_clause, else_clause == null ? QuoteExp.voidExp : else_clause, comp, target); } public static void compile (Expression test, Expression then_clause, Expression else_clause, Compilation comp, Target target) { gnu.bytecode.CodeAttr code = comp.getCode(); Label elseLabel; elseLabel = new Label(code); Branchable branchOp = test.getBranchable(); if (branchOp != null) { branchOp.compileJumpNot(comp, ((ApplyExp)test).getArgs(), elseLabel); } else { Target stack = new StackTarget(Type.boolean_type); test.compile(comp, stack); code.emitGotoIfIntEqZero(elseLabel); } code.emitIfThen(); then_clause.compileWithPosition(comp, target); if (else_clause instanceof QuoteExp && ((QuoteExp)else_clause).getValue()==Values.empty) { code.setUnreachable(); elseLabel.define(code); } else { code.emitElse(); elseLabel.define(code); else_clause.compileWithPosition(comp, target); } code.emitFi(); } } |
From: <ar...@us...> - 2003-03-29 00:30:35
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv15151/F:/nice/src/bossa/syntax Modified Files: IfExp.java Log Message: added SimpleIfExp to gnu.expr it can make use of the Branchable interface to generate better code. Index: IfExp.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/IfExp.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** IfExp.java 21 Feb 2002 14:45:16 -0000 1.13 --- IfExp.java 29 Mar 2003 00:30:28 -0000 1.14 *************** *** 63,67 **** elseCode = voidify(elseCode); ! return new gnu.expr.IfExp(condition.generateCode(), thenCode, elseCode); --- 63,67 ---- elseCode = voidify(elseCode); ! return new gnu.expr.SimpleIfExp(condition.generateCode(), thenCode, elseCode); |