From: <mt...@us...> - 2010-05-18 06:34:27
|
Revision: 14185 http://x10.svn.sourceforge.net/x10/?rev=14185&view=rev Author: mtake Date: 2010-05-18 06:34:19 +0000 (Tue, 18 May 2010) Log Message: ----------- Fix for XTENLANG-1348 Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10c/visit/Desugarer.java Added Paths: ----------- trunk/x10.runtime/src-java/x10/core/UnaryPost.java trunk/x10.runtime/src-x10/x10/compiler/UnaryPost.x10 Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-05-17 21:30:16 UTC (rev 14184) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-05-18 06:34:19 UTC (rev 14185) @@ -624,7 +624,7 @@ * node factory screws up. * @throws SemanticException */ - private Assign assign(Position pos, Expr e, Assign.Operator asgn, Expr val) throws SemanticException { + protected Assign assign(Position pos, Expr e, Assign.Operator asgn, Expr val) throws SemanticException { Assign a = (Assign) xnf.Assign(pos, e, asgn, val).type(e.type()); if (a instanceof FieldAssign) { assert (e instanceof Field); @@ -659,7 +659,7 @@ } // x++ -> ((t:Int)=>t-1)(x+=1) or x-- -> ((t:Int)=>t+1)(x-=1) - private Expr unaryPost(Position pos, X10Unary_c.Operator op, Expr e) throws SemanticException { + protected Expr unaryPost(Position pos, X10Unary_c.Operator op, Expr e) throws SemanticException { Type ret = e.type(); CanonicalTypeNode retTN = xnf.CanonicalTypeNode(pos, ret); Expr one = xnf.X10Cast(pos, retTN, Modified: trunk/x10.compiler/src/x10c/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10c/visit/Desugarer.java 2010-05-17 21:30:16 UTC (rev 14184) +++ trunk/x10.compiler/src/x10c/visit/Desugarer.java 2010-05-18 06:34:19 UTC (rev 14185) @@ -11,16 +11,29 @@ package x10c.visit; +import java.util.Collections; +import java.util.List; + import polyglot.ast.Assign; +import polyglot.ast.CanonicalTypeNode; import polyglot.ast.Expr; +import polyglot.ast.IntLit; import polyglot.ast.NodeFactory; +import polyglot.ast.Unary.Operator; import polyglot.frontend.Job; +import polyglot.types.Name; +import polyglot.types.QName; import polyglot.types.SemanticException; +import polyglot.types.Type; import polyglot.types.TypeSystem; +import polyglot.util.Position; import x10.ast.SettableAssign_c; import x10.ast.X10Call; import x10.ast.X10NodeFactory; +import x10.ast.X10Unary_c; +import x10.types.X10MethodInstance; import x10.types.X10TypeSystem; +import x10.types.checker.Converter; /** * Visitor to desugar the AST before code gen. @@ -34,7 +47,30 @@ this.xnf = (X10NodeFactory) nf; } + private static final QName UNARY_POST = QName.make("x10.compiler.UnaryPost"); + private static final Name BEFORE_INCREMENT = Name.make("beforeIncrement"); + private static final Name BEFORE_DECREMENT = Name.make("beforeDecrement"); + @Override + protected Expr unaryPost(Position pos, Operator op, Expr e) throws SemanticException { + Type ret = e.type(); + if (ret.isNumeric()) { + CanonicalTypeNode retTN = xnf.CanonicalTypeNode(pos, ret); + Expr one = xnf.X10Cast(pos, retTN, (Expr) xnf.IntLit(pos, IntLit.INT, 1).typeCheck(this), Converter.ConversionType.PRIMITIVE).type(ret); + Assign.Operator asgn = (op == X10Unary_c.POST_INC) ? Assign.ADD_ASSIGN : Assign.SUB_ASSIGN; + Expr incr = assign(pos, e, asgn, one); + if (e instanceof X10Call) incr = visitSettableAssign((SettableAssign_c) incr); + List<Expr> args = Collections.singletonList(incr); + Type unaryPost = xts.typeForName(UNARY_POST); + Name beforeIncDec = (op == X10Unary_c.POST_INC) ? BEFORE_INCREMENT : BEFORE_DECREMENT; + List<Type> actualTypes = Collections.singletonList(ret); + X10MethodInstance mi = xts.findMethod(unaryPost, xts.MethodMatcher(unaryPost, beforeIncDec, Collections.EMPTY_LIST, actualTypes, context)); + return xnf.X10Call(pos, xnf.CanonicalTypeNode(pos, unaryPost), xnf.Id(pos, beforeIncDec), Collections.EMPTY_LIST, args).methodInstance(mi).type(ret); + } + return super.unaryPost(pos, op, e); + } + + @Override protected Expr visitSettableAssign(SettableAssign_c n) throws SemanticException { if (n.operator() != Assign.ASSIGN) { X10Call left = (X10Call) n.left(xnf, this); Added: trunk/x10.runtime/src-java/x10/core/UnaryPost.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/UnaryPost.java (rev 0) +++ trunk/x10.runtime/src-java/x10/core/UnaryPost.java 2010-05-18 06:34:19 UTC (rev 14185) @@ -0,0 +1,27 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.core; + +public class UnaryPost { + public static byte beforeIncrement(byte t) { return (byte)(t - 1); } + public static byte beforeDecrement(byte t) { return (byte)(t + 1); } + public static short beforeIncrement(short t) { return (short)(t - 1); } + public static short beforeDecrement(short t) { return (short)(t + 1); } + public static int beforeIncrement(int t) { return t - 1; } + public static int beforeDecrement(int t) { return t + 1; } + public static long beforeIncrement(long t) { return t - 1L; } + public static long beforeDecrement(long t) { return t + 1L; } + public static float beforeIncrement(float t) { return t - 1.0F; } + public static float beforeDecrement(float t) { return t + 1.0F; } + public static double beforeIncrement(double t) { return t - 1.0; } + public static double beforeDecrement(double t) { return t + 1.0; } +} Property changes on: trunk/x10.runtime/src-java/x10/core/UnaryPost.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime/src-x10/x10/compiler/UnaryPost.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/UnaryPost.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/UnaryPost.x10 2010-05-18 06:34:19 UTC (rev 14185) @@ -0,0 +1,41 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.compiler; + +import x10.compiler.Native; + +public abstract class UnaryPost { + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Byte): Byte = (v - 1) as Byte; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Byte): Byte = (v + 1) as Byte; + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Short): Short = (v - 1) as Short; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Short): Short = (v + 1) as Short; + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Int): Int = v - 1; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Int): Int = v + 1; + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Long): Long = v - 1L; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Long): Long = v + 1L; + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Float): Float = v - 1.0F; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Float): Float = v + 1.0F; + @Native("java", "x10.core.UnaryPost.beforeIncrement(#1)") + public static global safe def beforeIncrement(v:Double): Double = v - 1.0; + @Native("java", "x10.core.UnaryPost.beforeDecrement(#1)") + public static global safe def beforeDecrement(v:Double): Double = v + 1.0; +} Property changes on: trunk/x10.runtime/src-x10/x10/compiler/UnaryPost.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mt...@us...> - 2010-05-24 08:56:30
|
Revision: 14261 http://x10.svn.sourceforge.net/x10/?rev=14261&view=rev Author: mtake Date: 2010-05-24 08:56:23 +0000 (Mon, 24 May 2010) Log Message: ----------- In response to Bard's comment to XTENLANG-1366, reverted my original change at r14245, and applied a new fix. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-java/x10/rtt/Equality.java trunk/x10.runtime/src-x10/x10/lang/Place.x10 Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-05-24 04:37:05 UTC (rev 14260) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-05-24 08:56:23 UTC (rev 14261) @@ -320,6 +320,8 @@ boxPrimitives = false; if (mi.name() == Name.make("equals") && mi.formalTypes().size() == 1) boxPrimitives = false; + if (mi.name() == Name.make("structEquals") && mi.formalTypes().size() == 1) + boxPrimitives = false; if (mi.name() == Name.make("hasNext") && mi.formalTypes().size() == 0) boxPrimitives = false; Modified: trunk/x10.runtime/src-java/x10/core/Struct.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Struct.java 2010-05-24 04:37:05 UTC (rev 14260) +++ trunk/x10.runtime/src-java/x10/core/Struct.java 2010-05-24 08:56:23 UTC (rev 14261) @@ -24,7 +24,7 @@ public Struct() {} - public boolean equals(Object o) { + public boolean structEquals(Object o) { if (o == null) return false; if (o == this) Modified: trunk/x10.runtime/src-java/x10/rtt/Equality.java =================================================================== --- trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-05-24 04:37:05 UTC (rev 14260) +++ trunk/x10.runtime/src-java/x10/rtt/Equality.java 2010-05-24 08:56:23 UTC (rev 14261) @@ -84,7 +84,7 @@ return a.equals(b); } } - public static boolean equalsequals(Struct a, Struct b) { return a.equals(b); } + public static boolean equalsequals(Struct a, Struct b) { return a.structEquals(b); } public static boolean equalsequals(Ref a, Ref b) { return a == b; } public static boolean equalsequals(Object a, boolean b) { return equalsequals(a, (Object) b); } @@ -109,7 +109,7 @@ if (a instanceof Number && b instanceof Number) return equalsNumbers(a, b); if (a instanceof Comparable) return ((Comparable) a).compareTo(b) == 0; - if (a instanceof Struct) return ((Struct) a).equals(b); + if (a instanceof Struct) return ((Struct) a).structEquals(b); return false; } Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-05-24 04:37:05 UTC (rev 14260) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-05-24 08:56:23 UTC (rev 14261) @@ -126,5 +126,6 @@ public global safe def toString() = "(Place " + this.id + ")"; public global safe def equals(p:Any) = p instanceof Place && (p as Place).id==this.id; + public global safe def structEquals(p:Any) = p instanceof Place && (p as Place).id==this.id; public global safe def hashCode()=id; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mt...@us...> - 2010-05-25 10:03:44
|
Revision: 14266 http://x10.svn.sourceforge.net/x10/?rev=14266&view=rev Author: mtake Date: 2010-05-25 10:03:37 +0000 (Tue, 25 May 2010) Log Message: ----------- Fix for XTENLANG-1366 again. Now compiler generates structEquals for all structs. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/core/Struct.java trunk/x10.runtime/src-x10/x10/lang/Place.x10 Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-05-25 02:28:53 UTC (rev 14265) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-05-25 10:03:37 UTC (rev 14266) @@ -27,6 +27,7 @@ import polyglot.ast.CanonicalTypeNode; import polyglot.ast.CanonicalTypeNode_c; import polyglot.ast.Catch; +import polyglot.ast.ClassMember; import polyglot.ast.ConstructorCall; import polyglot.ast.Expr; import polyglot.ast.FieldAssign_c; @@ -320,8 +321,6 @@ boxPrimitives = false; if (mi.name() == Name.make("equals") && mi.formalTypes().size() == 1) boxPrimitives = false; - if (mi.name() == Name.make("structEquals") && mi.formalTypes().size() == 1) - boxPrimitives = false; if (mi.name() == Name.make("hasNext") && mi.formalTypes().size() == 0) boxPrimitives = false; @@ -592,7 +591,7 @@ if (n.typeParameters().size() > 0) { w.newline(4); w.begin(0); - if (! n.flags().flags().isInterface()) { + if (! flags.isInterface()) { for (TypeParamNode tp : n.typeParameters()) { w.write("private final "); w.write(X10_RUNTIME_TYPE_CLASS); @@ -605,7 +604,7 @@ w.end(); } - if (! n.flags().flags().isInterface()) { + if (! flags.isInterface()) { if (n.properties().size() > 0) { w.newline(4); w.begin(0); @@ -618,6 +617,36 @@ } n.print(n.body(), w, tr); + w.newline(); + + // Generate structEquals for structs + if (flags.isStruct()) { + w.write("final public boolean structEquals(final java.lang.Object o) {"); + w.newline(4); + w.begin(0); + w.write("if (!(o instanceof " + def.fullName() +")) return false;"); + w.newline(); + for (PropertyDecl pd : n.properties()) { + w.write("if (!x10.rtt.Equality.equalsequals(this." + pd.name() + ", ((" + def.fullName() + ") o)." + pd.name() + ")) return false;"); + w.newline(); + } + for (ClassMember member : n.body().members()) { + if (member instanceof FieldDecl_c) { + FieldDecl_c field = (FieldDecl_c) member; + if (field.flags().flags().isStatic()) continue; + w.write("if (!x10.rtt.Equality.equalsequals(this." + field.name() + ", ((" + def.fullName() + ") o)." + field.name() + ")) return false;"); + w.newline(); + } + } + w.write("return true;"); + w.newline(); + w.end(); + w.write("}"); + w.newline(); + + w.newline(); + } + w.write("}"); w.newline(0); Modified: trunk/x10.runtime/src-java/x10/core/Struct.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Struct.java 2010-05-25 02:28:53 UTC (rev 14265) +++ trunk/x10.runtime/src-java/x10/core/Struct.java 2010-05-25 10:03:37 UTC (rev 14266) @@ -11,11 +11,6 @@ package x10.core; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import x10.rtt.Equality; import x10.rtt.RuntimeType; import x10.rtt.Type; @@ -24,56 +19,12 @@ public Struct() {} - public boolean structEquals(Object o) { - if (o == null) - return false; - if (o == this) - return true; - Class<?> c = this.getClass(); - Object o1 = this; - Object o2 = o; - if (c != o2.getClass()) - return false; - try { - while (c != null) { - Field[] fs = c.getDeclaredFields(); - for (int i = fs.length - 1; i >= 0; i--) { - Field f = fs[i]; - if (Modifier.isStatic(f.getModifiers())) - continue; - f.setAccessible(true); - Object a1 = f.get(o1); - Object a2 = f.get(o2); - if (f.getType().isPrimitive()) { - if (!Equality.equalsequals(a1, a2)) - return false; - } - else if (f.getType().isArray()) { - int len = Array.getLength(a1); - if (len != Array.getLength(a2)) - return false; - for (int j = 0; j < len; j++) - if (!Equality.equalsequals(Array.get(a1, j), Array.get(a2, j))) - return false; - } - else { - // I assume here that value types are immutable - // and can thus not contain mutually recursive - // structures. If that is wrong, we would have to do - // more work here to avoid dying with a StackOverflow. - if (!Equality.equalsequals(a1, a2)) - return false; - } - } - c = c.getSuperclass(); - } - } - catch (IllegalAccessException iae) { - throw new Error(iae); // fatal, should never happen - } - return true; + public boolean equals(Object o) { + return structEquals(o); } + abstract public boolean structEquals(Object o); + public static final RuntimeType<Struct> _RTT = new RuntimeType<Struct>(Struct.class); public RuntimeType getRTT() {return _RTT;} public Type<?> getParam(int i) {return null;} Modified: trunk/x10.runtime/src-x10/x10/lang/Place.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-05-25 02:28:53 UTC (rev 14265) +++ trunk/x10.runtime/src-x10/x10/lang/Place.x10 2010-05-25 10:03:37 UTC (rev 14266) @@ -126,6 +126,5 @@ public global safe def toString() = "(Place " + this.id + ")"; public global safe def equals(p:Any) = p instanceof Place && (p as Place).id==this.id; - public global safe def structEquals(p:Any) = p instanceof Place && (p as Place).id==this.id; public global safe def hashCode()=id; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-05-26 21:26:48
|
Revision: 14285 http://x10.svn.sourceforge.net/x10/?rev=14285&view=rev Author: vj0 Date: 2010-05-26 21:26:40 +0000 (Wed, 26 May 2010) Log Message: ----------- WIP for collecting finish. Includes changes to the parser and the frontend to permit: Expression ::= finish ( Expression ) Block Statement::= offer Expression; Also, finish is not a soft key word. Includes commits to Runtime.x10 --- the runtime support for collecting finish. Still missing the actual code generation for finish expressions and offer statements to link it to the Runtime. (So programs containing these syntax elements will parse but not run.) Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.compiler/src/x10/parser/X10KWLexer.gi trunk/x10.compiler/src/x10/parser/X10KWLexer.java trunk/x10.compiler/src/x10/parser/X10KWLexerprs.java trunk/x10.compiler/src/x10/parser/X10KWLexersym.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/X10Parsersym.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/X10Context.java trunk/x10.compiler/src/x10/types/X10Context_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/ast/FinishExpr.java trunk/x10.compiler/src/x10/ast/FinishExpr_c.java trunk/x10.compiler/src/x10/ast/Offer.java trunk/x10.compiler/src/x10/ast/Offer_c.java trunk/x10.runtime/src-x10/x10/lang/Reducible.x10 Added: trunk/x10.compiler/src/x10/ast/FinishExpr.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FinishExpr.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/FinishExpr.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -0,0 +1,25 @@ +/** + * + */ +package x10.ast; + +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.Stmt; +import polyglot.ast.Term; +import polyglot.util.Position; +import polyglot.visit.CFGBuilder; + +/** + * An implementation of collecting finish. + * @author vj + * + */ +public interface FinishExpr extends Expr{ + + + Expr reducer(); + Stmt body(); +} Added: trunk/x10.compiler/src/x10/ast/FinishExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/FinishExpr_c.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/FinishExpr_c.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -0,0 +1,142 @@ +package x10.ast; + +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.If; +import polyglot.ast.If_c; +import polyglot.ast.Node; +import polyglot.ast.NodeList; +import polyglot.ast.Stmt; +import polyglot.ast.Term; +import polyglot.types.Context; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.util.Position; +import polyglot.visit.AscriptionVisitor; +import polyglot.visit.CFGBuilder; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import polyglot.visit.PruningVisitor; +import x10.errors.Errors; +import x10.types.ClosureDef; +import x10.types.X10Context; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; +import x10.types.constraints.XConstrainedTerm; +import x10.visit.X10TypeChecker; + +public class FinishExpr_c extends Expr_c implements FinishExpr { + + Expr reducer; + Stmt body; + + /** + * @param pos + */ + public FinishExpr_c(Position pos, Expr r, Stmt body) { + super(pos); + this.reducer = r; + this.body = body; + + } + + public Expr reducer() { + return reducer; + } + + public Stmt body() { + return body; + } + + /* + * (non-Javadoc) + * + * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, + * java.util.List) + */ + @Override + public List<Term> acceptCFG(CFGBuilder v, List<Term> succs) { + v.visitCFG(reducer, body, ENTRY); + v.visitCFG(body, this, EXIT); + return succs; + } + + + @Override + public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { + + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + NodeVisitor v = tc.enter(parent, this); + + if (v instanceof PruningVisitor) { + return this; + } + // Check that reducer is a Reducer, throwing an exception if not. + Expr e = (Expr) visitChild(reducer, v); + Type r = X10TypeMixin.reducerType(e.type()); + if (r == null) { + throw new Errors.IsNotReducible(e, e.position()); + } + Context childScope = enterChildScope(body, tc.context()); + ContextVisitor childVisitor = tc.context(childScope); + Stmt b = (Stmt) visitChild(body, childVisitor); + return reconstruct(e,b).type(r); + } + /** + * When visiting the body set the collectingFinishType in the context to be + * the type of the reducer. + */ + @Override + public Context enterChildScope(Node child, Context c) { + X10Context xc = (X10Context) super.enterChildScope(child, c); + if (child == body) { + Type type = reducer.type(); + if (type != null) { + xc = (X10Context) xc.pushCollectingFinishScope(type); + } + addDecls(xc); + } + return xc; + } + + /** Type check the statement. + public Node typeCheck(ContextVisitor tc) throws SemanticException { + // This must succeed, otherwise typeCheckOverride has already + // thrown an exception. + Type reducerBase = X10TypeMixin.reducerType(reducer.type()); + assert reducerBase != null; + return type(reducerBase); + } +*/ + /* + * (non-Javadoc) + * + * @see polyglot.ast.Term#firstChild() + */ + public Term firstChild() { + return reducer; + } + + /** Set the consequent of the statement. */ + public FinishExpr reconstruct(Expr e, Stmt b) { + if (e == reducer && body == b) + return this; + + FinishExpr_c n = (FinishExpr_c) copy(); + n.reducer = e; + n.body = b; + return n; + } + + /** Visit the children of the statement. */ + public Node visitChildren(NodeVisitor v) { + Expr reducer = (Expr) visitChild(this.reducer, v); + Stmt body = (Stmt) visitChild(this.body, v); + return reconstruct(reducer, body); + } + +} Added: trunk/x10.compiler/src/x10/ast/Offer.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Offer.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/Offer.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -0,0 +1,21 @@ +/** + * + */ +package x10.ast; + +import polyglot.ast.Expr; +import polyglot.ast.Return; +import polyglot.ast.Stmt; + +/** + * @author vj + * + */ +public interface Offer extends Stmt { + + /** The expression to return. */ + Expr expr(); + /** Set the expression to return. */ + Offer expr(Expr expr); + +} Added: trunk/x10.compiler/src/x10/ast/Offer_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Offer_c.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/Offer_c.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -0,0 +1,129 @@ +/** + * + */ +package x10.ast; + +import java.util.Collections; +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.Node; +import polyglot.ast.Return; +import polyglot.ast.Return_c; +import polyglot.ast.Stmt_c; +import polyglot.ast.Term; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.CodeWriter; +import polyglot.util.Position; +import polyglot.visit.CFGBuilder; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import polyglot.visit.PrettyPrinter; +import x10.errors.Errors; +import x10.types.X10Context; +import x10.types.X10TypeMixin; + +/** + * An implementation of the offer e; construct in X10. + * Patterned after return e. However does not have the control flow + * connotations of return e. e.g. does not interact with finish blocks. + * Control flow continues from an offer statement just as it would from + * a normal statement. + * @author vj + * + */ +public class Offer_c extends Stmt_c implements Offer { + + Expr expr; + /** + * @param pos + */ + public Offer_c(Position pos, Expr e) { + super(pos); + this.expr = e; + } + + /** Get the expression to return, or null. */ + public Expr expr() { + return this.expr; + } + + /** Set the expression to return, or null. */ + public Offer expr(Expr expr) { + Offer_c n = (Offer_c) copy(); + n.expr = expr; + return n; + } + + /** Reconstruct the statement. */ + protected Offer_c reconstruct(Expr expr) { + if (expr != this.expr) { + Offer_c n = (Offer_c) copy(); + n.expr = expr; + return n; + } + + return this; + } + + /** Type check the statement. */ + public Node typeCheck(ContextVisitor tc) throws SemanticException { + // Find a T such that t is an instance of Reducer[T]. + // check that the type of the expression e is a subtype of T. + Type rType = ((X10Context) tc.context()).collectingFinishType(); + if (rType != null) { + Type eType = expr().type(); + rType = X10TypeMixin.reducerType(rType); + if (rType != null && ! tc.typeSystem().isSubtype(eType, rType, tc.context())) + throw new Errors.OfferDoesNotMatchCollectingFinishType(eType, rType, position()); + return this; + } + throw new Errors.NoCollectingFinishFound(this.toString(), position()); + + } + + /** Visit the children of the statement. */ + public Node visitChildren(NodeVisitor v) { + Expr expr = (Expr) visitChild(this.expr, v); + return reconstruct(expr); + } + + /* (non-Javadoc) + * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) + */ + @Override + public List<Term> acceptCFG(CFGBuilder v, List<Term> succs) { + if (expr != null) { + v.visitCFG(expr, this, EXIT); + } + return Collections.EMPTY_LIST; + } + + /* (non-Javadoc) + * @see polyglot.ast.Term#firstChild() + */ + public Term firstChild() { + if (expr != null) return expr; + return null; + } + + public String toString() { + return "offer" + (expr != null ? " " + expr : "") + ";"; + } + + /** Write the statement to an output file. */ + public void prettyPrint(CodeWriter w, PrettyPrinter tr) { + w.write("offer") ; + if (expr != null) { + w.write(" "); + print(expr, w, tr); + } + w.write(";"); + } + + + + +} Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -176,4 +176,6 @@ Closure Closure(Closure c, Position pos); TypeNode HasType(TypeNode tn); + Offer Offer(Position pos, Expr e); + FinishExpr FinishExpr(Position p, Expr e, Stmt s); } Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -347,7 +347,18 @@ n = (Next) n.ext(extFactory().extStmt()); return (Next) n.del(delFactory().delStmt()); } + + public Offer Offer(Position pos, Expr e) { + Offer n = new Offer_c(pos,e); + n = (Offer) n.ext(extFactory().extStmt()); + return (Offer) n.del(delFactory().delStmt()); + } + public FinishExpr FinishExpr(Position pos, Expr e, Stmt s) { + FinishExpr n = new FinishExpr_c(pos, e, s); + n = (FinishExpr) n.ext(extFactory().extStmt()); + return (FinishExpr) n.del(delFactory().delStmt()); + } public Now Now(Position pos, Expr expr, Stmt stmt) { Now n = new Now_c(pos, expr, stmt); n = (Now) n.ext(extFactory().extStmt()); Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -716,7 +716,7 @@ return((CannotGenerateCast)o).position().equals(position()); } } - + public static class StructMustHaveStructSupertype extends SemanticException { private static final long serialVersionUID = -7826831387240378409L; public StructMustHaveStructSupertype(Ref<? extends Type> superType, ClassDef type, Position pos) { @@ -729,4 +729,46 @@ return((StructMustHaveStructSupertype)o).position().equals(position()); } } + public static class NoCollectingFinishFound extends SemanticException { + private static final long serialVersionUID = 9107601200096892236L; + public NoCollectingFinishFound(String offer, Position position) { + super("Cannot find enclosing collecting finish for offer statement." + + "\n\t Offer: " + offer, + + position); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof NoCollectingFinishFound) ) + return false; + return((NoCollectingFinishFound)o).position().equals(position()); + } + } + public static class OfferDoesNotMatchCollectingFinishType extends SemanticException { + private static final long serialVersionUID = -4277756733682836855L; + public OfferDoesNotMatchCollectingFinishType(Type eType, Type fType, Position position) { + super("The type of the offer expression does not match the type of the collecting finish." + + "\n\t Offer expression type: " + eType + + "\n\t Collecting finish type: " + fType, + position); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof OfferDoesNotMatchCollectingFinishType) ) + return false; + return((OfferDoesNotMatchCollectingFinishType)o).position().equals(position()); + } + } + public static class IsNotReducible extends SemanticException { + + public IsNotReducible(Expr expr, Position position) { + super("The reducer must be of type Reducible[T], for some type T." + + "\n\t Reducer: " + expr + + "\n\t Reducer type: " + expr.type(), + position); + } + public boolean equals(Object o) { + if (o==null || ! (o instanceof OfferDoesNotMatchCollectingFinishType) ) + return false; + return((OfferDoesNotMatchCollectingFinishType)o).position().equals(position()); + } + } } Modified: trunk/x10.compiler/src/x10/parser/X10KWLexer.gi =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexer.gi 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/parser/X10KWLexer.gi 2010-05-26 21:26:40 UTC (rev 14285) @@ -120,6 +120,7 @@ nonblocking now null + offer or operator package @@ -604,4 +605,9 @@ $setResult($_while); $EndAction ./ + | o f f e r + /.$BeginAction + $setResult($_offer); + $EndAction + ./ %End Modified: trunk/x10.compiler/src/x10/parser/X10KWLexer.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexer.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/parser/X10KWLexer.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -17,7 +17,7 @@ public class X10KWLexer extends X10KWLexerprs { private char[] inputChars; - private final int keywordKind[] = new int[79 + 1]; + private final int keywordKind[] = new int[80 + 1]; public int[] getKeywordKinds() { return keywordKind; } @@ -643,6 +643,13 @@ keywordKind[79] = (X10Parsersym.TK_while); + // + // Rule 80: KeyWord ::= o f f e r + // + + keywordKind[80] = (X10Parsersym.TK_offer); + + for (int i = 0; i < keywordKind.length; i++) { if (keywordKind[i] == 0) Modified: trunk/x10.compiler/src/x10/parser/X10KWLexerprs.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexerprs.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/parser/X10KWLexerprs.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -24,19 +24,19 @@ public final static int MAX_NAME_LENGTH = 0; public final int getMaxNameLength() { return MAX_NAME_LENGTH; } - public final static int NUM_STATES = 267; + public final static int NUM_STATES = 270; public final int getNumStates() { return NUM_STATES; } public final static int NT_OFFSET = 27; public final int getNtOffset() { return NT_OFFSET; } - public final static int LA_STATE_OFFSET = 429; + public final static int LA_STATE_OFFSET = 434; public final int getLaStateOffset() { return LA_STATE_OFFSET; } public final static int MAX_LA = 1; public final int getMaxLa() { return MAX_LA; } - public final static int NUM_RULES = 79; + public final static int NUM_RULES = 80; public final int getNumRules() { return NUM_RULES; } public final static int NUM_NONTERMINALS = 2; @@ -48,7 +48,7 @@ public final static int SEGMENT_SIZE = 8192; public final int getSegmentSize() { return SEGMENT_SIZE; } - public final static int START_STATE = 80; + public final static int START_STATE = 81; public final int getStartState() { return START_STATE; } public final static int IDENTIFIER_SYMBOL = 0; @@ -60,10 +60,10 @@ public final static int EOLT_SYMBOL = 28; public final int getEoltSymbol() { return EOLT_SYMBOL; } - public final static int ACCEPT_ACTION = 349; + public final static int ACCEPT_ACTION = 353; public final int getAcceptAction() { return ACCEPT_ACTION; } - public final static int ERROR_ACTION = 350; + public final static int ERROR_ACTION = 354; public final int getErrorAction() { return ERROR_ACTION; } public final static boolean BACKTRACK = false; @@ -110,7 +110,7 @@ 2,4,7,5,5,7,3,4,6,2, 10,6,10,9,6,3,4,8,7,7, 9,5,6,6,6,6,8,6,5,6, - 12,4,5,6,9,4,3,8,5 + 12,4,5,6,9,4,3,8,5,5 }; }; public final static byte baseCheck[] = BaseCheck.baseCheck; @@ -128,33 +128,34 @@ 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, - 1,82,30,81,83,160,21,103,86,28, - 70,34,84,47,24,46,92,94,101,62, - 63,42,166,18,168,169,149,48,163,174, - 176,177,88,99,178,180,181,184,187,188, - 190,191,106,109,193,194,196,114,118,200, - 202,197,69,204,206,208,120,207,212,215, - 123,61,128,217,218,221,130,129,223,110, - 219,229,232,234,236,238,242,239,243,246, - 248,251,249,255,226,135,256,260,141,258, - 262,267,268,269,270,273,136,278,271,279, - 283,281,148,287,289,290,295,297,298,293, - 285,55,153,302,305,306,307,308,312,311, - 315,316,321,318,323,325,328,327,332,329, - 334,336,338,339,340,343,347,349,351,156, - 353,352,356,357,359,360,363,364,366,374, - 371,375,382,379,385,387,388,377,393,389, - 390,398,402,158,403,396,394,407,409,408, - 413,414,415,416,418,421,423,428,432,425, - 434,436,438,437,439,440,442,445,447,441, - 455,456,459,460,461,462,451,465,467,463, - 470,474,481,469,482,485,486,487,473,494, - 493,489,502,495,498,503,140,506,507,508, - 509,511,510,519,514,521,525,526,527,533, - 535,537,538,541,543,544,545,546,522,548, - 551,553,552,554,556,565,567,558,563,570, - 569,573,574,579,583,576,585,586,588,589, - 591,592,593,594,595,599,604,600,350,350 + 1,1,83,142,78,85,154,159,62,54, + 28,155,42,86,43,24,55,95,97,103, + 61,56,34,161,18,162,163,169,105,164, + 171,175,173,178,99,101,82,181,182,185, + 186,188,190,191,110,113,193,195,196,119, + 87,197,200,202,74,207,205,206,121,208, + 213,214,126,77,128,218,217,219,129,133, + 223,224,226,228,234,230,238,239,240,243, + 245,248,249,250,253,254,255,258,136,260, + 262,138,265,268,270,271,274,273,276,21, + 282,279,283,285,287,141,288,292,293,296, + 299,300,301,304,305,57,308,306,310,311, + 312,316,317,319,322,328,324,330,333,335, + 334,340,336,342,344,343,345,349,356,350, + 358,360,352,149,359,367,363,364,370,371, + 372,373,375,378,381,386,391,393,394,396, + 380,388,399,398,402,403,404,151,412,405, + 410,414,417,416,420,424,422,421,423,432, + 433,435,439,441,442,444,447,445,448,449, + 452,454,461,456,462,466,467,470,471,473, + 430,472,477,476,479,481,482,459,491,492, + 494,495,496,497,501,502,503,507,509,510, + 511,514,518,517,520,519,533,521,527,534, + 536,537,538,544,546,548,549,552,554,555, + 539,556,560,562,563,565,564,566,569,574, + 577,579,580,581,582,584,586,585,594,592, + 598,590,599,602,603,606,604,607,608,611, + 615,618,354,354 }; }; public final static char baseAction[] = BaseAction.baseAction; @@ -166,68 +167,69 @@ public final static byte termCheck[] = {0, 0,1,2,3,4,5,6,7,8,9, 10,11,12,13,14,15,16,0,18,2, - 0,21,22,0,1,2,3,0,1,0, - 3,4,12,0,11,12,3,4,11,16, - 17,0,9,2,11,0,0,0,1,3, - 4,10,6,8,0,26,9,16,13,18, - 0,0,0,3,3,20,5,5,0,0, - 2,11,11,4,12,7,22,17,10,17, - 0,1,0,0,4,0,4,0,6,6, - 5,0,1,0,3,8,3,4,0,14, - 0,1,0,16,4,0,23,2,0,0, - 8,3,4,0,16,10,3,0,5,0, - 11,23,0,6,5,6,4,0,0,0, - 1,9,5,4,0,0,9,3,10,0, - 0,24,2,9,9,17,11,0,0,1, - 10,4,0,6,2,0,17,0,1,0, - 5,4,0,8,5,0,14,0,0,4, - 2,4,10,0,1,0,0,0,2,0, - 0,6,2,0,7,6,0,0,5,0, - 0,2,0,0,8,0,0,10,8,0, - 8,0,9,0,3,0,0,0,5,14, - 14,0,13,6,0,10,0,0,0,13, - 0,7,0,3,2,0,1,10,0,18, - 14,0,4,0,3,0,18,0,0,6, - 3,0,0,8,6,0,5,0,0,2, - 0,9,0,3,0,0,1,0,10,0, - 1,0,1,18,7,11,0,0,0,0, - 0,2,0,1,7,7,10,0,0,2, - 0,11,0,1,0,5,0,1,0,0, - 2,13,0,4,0,1,0,0,6,3, - 3,0,1,19,0,0,0,0,1,4, - 0,0,8,2,0,0,10,0,3,9, - 0,1,0,1,0,8,0,0,0,5, - 3,0,1,0,20,0,3,0,0,0, - 1,13,0,6,6,19,0,5,0,3, - 0,0,0,2,6,0,0,22,0,0, - 10,9,0,0,0,0,10,12,5,7, - 0,12,7,0,0,1,0,19,0,9, - 7,0,1,5,0,1,0,0,0,0, - 3,5,0,0,2,0,20,0,9,11, - 3,0,0,1,3,10,0,0,0,16, - 2,5,0,0,0,0,9,0,5,7, - 0,7,0,1,0,8,6,0,4,2, - 15,0,1,0,1,0,0,0,0,0, - 0,0,7,6,0,1,0,8,12,8, - 0,5,12,15,0,0,2,2,0,0, - 0,0,0,2,0,7,0,8,0,0, - 20,0,0,0,8,15,14,13,9,6, - 0,0,10,2,0,0,0,7,0,21, - 5,7,0,0,0,9,3,0,4,7, - 12,0,0,2,7,0,0,0,0,0, - 0,2,4,0,12,10,3,11,0,1, - 0,0,15,13,0,0,0,7,2,8, - 6,6,0,1,0,1,0,0,2,2, - 0,1,0,0,0,0,1,0,5,7, - 0,0,0,0,1,0,1,0,7,9, - 8,14,0,19,0,1,0,1,0,0, - 8,2,0,0,17,0,3,9,0,4, - 2,9,0,1,0,0,2,0,0,2, - 0,0,0,0,0,1,8,6,0,0, - 15,0,10,0,1,0,13,0,0,0, - 0,0,0,0,15,25,0,0,0,21, - 0,0,0,0,0,0,0,0,0,0, - 0 + 0,21,22,0,1,2,3,0,1,9, + 3,11,5,0,11,2,13,0,11,16, + 17,0,0,10,3,3,5,5,6,16, + 9,18,11,0,0,0,0,4,2,4, + 0,0,8,3,4,12,12,14,13,8, + 14,11,17,0,20,2,0,0,1,3, + 7,0,5,10,0,0,0,11,7,5, + 6,6,6,17,0,1,0,3,0,3, + 0,5,0,1,0,1,8,5,23,0, + 24,2,0,9,16,3,16,5,0,10, + 0,3,4,23,4,0,6,0,0,1, + 5,4,0,5,9,0,9,0,3,2, + 0,0,10,0,9,5,6,10,0,17, + 0,1,4,0,0,5,8,4,0,5, + 0,0,0,0,2,5,5,26,0,1, + 0,13,0,10,0,1,0,0,6,2, + 0,0,12,2,0,0,6,0,4,0, + 0,2,0,8,0,0,0,10,8,0, + 8,0,3,9,0,0,0,0,12,14, + 4,6,0,0,10,14,0,0,0,12, + 7,3,0,0,2,0,10,0,0,0, + 18,14,5,0,11,6,3,0,0,0, + 1,3,0,18,0,8,4,0,0,0, + 6,2,0,0,0,3,9,0,1,0, + 1,0,1,10,0,11,18,0,1,0, + 0,7,0,0,2,0,1,7,0,10, + 7,0,0,2,0,1,0,0,1,11, + 4,0,0,2,12,0,1,5,0,0, + 0,3,3,0,0,0,6,0,1,0, + 0,0,1,8,5,0,0,2,0,0, + 10,0,19,0,3,9,22,0,1,0, + 1,8,0,0,0,0,4,3,20,0, + 1,0,0,0,0,4,3,12,0,0, + 6,0,19,4,6,0,1,0,0,0, + 3,10,0,0,22,6,0,9,2,0, + 0,0,0,10,0,13,4,0,7,0, + 0,7,3,13,7,0,1,0,19,9, + 0,1,0,0,1,0,4,0,0,4, + 2,0,0,0,0,3,3,20,11,0, + 9,0,1,0,10,0,0,4,2,0, + 0,0,0,0,9,16,7,4,7,0, + 8,0,0,1,0,15,2,6,0,1, + 0,0,1,0,0,5,0,0,0,20, + 7,0,6,0,1,0,8,13,0,8, + 0,0,15,2,4,0,0,2,13,0, + 0,0,0,7,2,0,0,8,0,21, + 0,0,0,12,8,15,6,9,7,14, + 0,0,2,0,0,0,0,4,7,3, + 0,0,0,9,2,10,0,7,0,0, + 0,5,0,0,13,7,0,0,0,0, + 0,1,13,10,5,0,0,17,11,3, + 12,15,0,0,2,0,0,0,0,2, + 7,6,6,0,1,0,1,0,0,2, + 2,0,1,0,0,0,1,19,4,0, + 7,0,0,0,0,0,1,8,0,1, + 7,9,8,0,1,14,0,1,0,0, + 0,0,2,0,0,0,2,8,3,0, + 9,0,9,0,1,17,5,0,0,2, + 2,0,0,0,15,0,0,0,1,8, + 0,6,0,10,0,1,0,0,12,0, + 0,0,0,0,0,0,0,25,0,0, + 0,21,15,0,0,0,0,0,0,0, + 0,0,0,0,0 }; }; public final static byte termCheck[] = TermCheck.termCheck; @@ -235,68 +237,70 @@ public interface TermAction { public final static char termAction[] = {0, - 350,92,100,101,88,83,90,93,89,95, - 94,87,96,91,99,98,86,350,85,149, - 350,84,97,350,128,127,129,350,113,350, - 111,112,107,350,126,130,115,117,110,125, - 124,350,118,146,116,350,350,350,154,122, - 121,147,123,132,350,349,153,145,400,144, - 350,350,350,194,139,131,140,141,10,350, - 183,193,138,114,142,185,242,427,184,143, - 350,103,350,350,102,350,105,350,104,119, - 376,350,133,350,134,159,136,135,350,109, - 350,137,350,375,391,350,120,169,350,350, - 108,171,172,350,406,170,177,350,176,350, - 205,160,350,179,357,356,192,350,8,3, - 201,191,195,200,350,350,196,217,202,350, - 350,178,220,218,229,203,228,350,350,152, - 221,233,350,234,243,350,396,350,285,350, - 265,412,350,264,106,350,244,350,350,148, - 151,150,155,350,156,350,350,350,158,350, - 350,157,163,350,161,162,350,350,164,350, - 350,167,350,350,165,350,350,166,168,350, - 173,350,174,350,181,350,350,350,186,175, - 182,350,180,187,350,359,350,350,350,188, - 350,190,350,199,204,47,216,198,350,189, - 197,350,398,350,207,350,206,350,350,208, - 209,350,350,381,407,350,210,350,350,373, - 350,211,350,213,350,350,392,350,214,350, - 219,350,385,212,222,215,350,350,350,350, - 350,226,350,227,224,225,223,350,350,230, - 350,231,350,377,350,232,350,235,350,350, - 236,378,350,237,350,371,350,5,240,238, - 239,350,426,241,350,350,350,350,352,246, - 350,350,245,247,350,350,422,350,250,248, - 350,251,350,253,350,252,350,350,350,254, - 255,350,429,350,249,350,257,350,350,350, - 394,256,350,259,372,384,350,260,350,261, - 350,350,350,388,262,350,350,258,350,350, - 263,266,350,350,350,350,387,386,419,269, - 350,268,270,350,350,273,350,267,350,272, - 271,350,274,275,350,276,350,350,350,350, - 278,277,350,350,280,350,279,350,282,281, - 283,350,350,286,284,287,350,350,350,288, - 365,289,350,350,350,350,290,350,292,291, - 350,351,350,380,350,414,399,350,294,293, - 415,350,405,350,370,350,350,45,350,350, - 350,350,295,296,350,299,350,367,368,298, - 350,300,420,297,350,350,418,301,350,350, - 350,350,350,402,350,416,350,302,350,350, - 303,350,73,350,305,362,306,304,307,308, - 350,350,424,310,350,350,350,413,350,309, - 312,311,350,350,350,313,314,350,315,364, - 363,350,350,383,316,350,350,350,350,350, - 350,320,318,350,369,393,322,317,350,321, - 350,350,366,319,350,350,350,323,390,331, - 324,325,350,409,350,410,350,350,326,327, - 350,328,350,350,350,350,389,350,408,329, - 350,350,350,350,335,350,336,350,334,332, - 333,417,350,330,350,428,350,337,350,350, - 338,382,350,350,354,350,341,339,350,343, - 342,340,350,404,350,350,344,350,350,425, - 350,350,350,350,350,361,345,379,350,350, - 411,350,401,350,347,350,403,350,350,350, - 350,350,350,350,421,346,350,350,350,374 + 354,93,101,102,84,89,91,94,90,96, + 95,88,92,97,100,99,87,354,86,151, + 354,85,98,354,130,129,131,354,115,233, + 113,232,114,354,128,148,132,354,112,127, + 126,354,354,149,117,124,119,123,125,147, + 120,146,118,354,354,354,354,380,247,143, + 354,354,134,141,142,110,404,111,144,109, + 248,140,145,10,133,186,354,354,104,197, + 188,354,103,187,354,354,354,196,164,106, + 105,121,182,431,354,135,354,136,354,138, + 354,137,354,139,354,156,162,395,122,354, + 181,172,354,155,379,174,410,175,354,173, + 354,180,179,163,361,354,360,354,3,204, + 195,198,8,203,194,354,199,354,221,224, + 354,354,205,354,222,237,238,225,354,206, + 354,289,269,354,354,416,268,107,354,116, + 354,354,354,354,153,150,152,353,354,154, + 354,108,354,157,354,159,354,354,160,161, + 354,354,158,166,354,354,165,354,167,354, + 354,170,354,168,354,354,354,169,171,354, + 176,354,184,177,354,354,354,354,183,178, + 189,190,354,354,363,185,354,354,354,191, + 193,202,354,354,207,354,201,354,354,354, + 192,200,402,354,208,211,210,354,354,354, + 213,212,354,209,354,385,214,354,354,354, + 411,377,354,354,354,217,215,47,220,354, + 396,354,223,218,354,219,216,354,389,354, + 354,226,354,354,230,354,231,228,354,227, + 229,354,354,234,354,381,354,354,239,235, + 236,354,354,240,382,354,375,241,354,5, + 354,242,243,354,354,354,244,354,430,354, + 354,354,356,249,250,354,354,251,354,354, + 426,354,245,354,254,252,246,354,255,354, + 257,256,354,354,354,354,258,259,253,354, + 433,354,354,354,354,434,261,260,354,354, + 263,354,388,264,376,354,398,354,354,354, + 265,267,354,354,262,266,354,270,392,354, + 354,354,354,391,354,390,423,354,273,354, + 354,274,282,272,275,354,277,354,271,276, + 354,278,354,354,280,354,279,354,354,281, + 284,354,354,354,354,287,288,283,285,354, + 286,354,290,354,291,354,354,293,369,354, + 354,354,354,354,294,292,295,296,355,354, + 418,354,354,384,354,419,297,403,354,409, + 354,354,374,354,354,298,45,354,354,307, + 299,354,300,354,303,354,371,372,354,302, + 354,354,301,422,304,354,354,305,424,354, + 354,354,354,420,406,354,354,306,354,313, + 354,354,354,308,309,366,312,311,417,310, + 354,354,314,354,354,73,354,316,315,318, + 354,354,354,317,387,428,354,368,354,354, + 354,319,354,354,367,320,354,354,354,354, + 354,325,373,397,322,354,354,400,321,326, + 323,370,354,354,324,354,354,354,354,394, + 327,328,329,354,413,354,414,354,354,330, + 331,354,332,354,354,354,393,334,412,354, + 333,354,354,354,354,354,339,335,354,340, + 338,336,337,354,432,421,354,341,354,354, + 354,354,386,354,354,354,346,342,345,354, + 343,354,344,354,408,358,347,354,354,348, + 429,354,354,354,415,354,354,354,365,349, + 354,383,354,405,354,351,354,354,407,354, + 354,354,354,354,354,354,354,350,354,354, + 354,378,425 }; }; public final static char termAction[] = TermAction.termAction; Modified: trunk/x10.compiler/src/x10/parser/X10KWLexersym.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexersym.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/parser/X10KWLexersym.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -18,19 +18,19 @@ Char_c = 7, Char_d = 15, Char_e = 1, - Char_f = 13, + Char_f = 12, Char_g = 21, - Char_h = 12, + Char_h = 13, Char_i = 9, Char_j = 27, Char_k = 19, Char_l = 6, Char_m = 20, Char_n = 8, - Char_o = 4, + Char_o = 5, Char_p = 14, Char_q = 24, - Char_r = 5, + Char_r = 4, Char_s = 10, Char_t = 2, Char_u = 11, @@ -46,16 +46,16 @@ "e", "t", "a", + "r", "o", - "r", "l", "c", "n", "i", "s", "u", + "f", "h", - "f", "p", "d", "w", Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-05-26 20:57:21 UTC (rev 14284) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-05-26 21:26:40 UTC (rev 14285) @@ -13,7 +13,7 @@ import lpg.runtime.*; -//#line 32 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" +//#line 32 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; @@ -292,7 +292,7 @@ // - //#line 327 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 327 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" private ErrorQueue eq; private X10TypeSystem ts; private X10NodeFactory nf; @@ -874,10 +874,10 @@ // Rule 1: TypeName ::= TypeName . ErrorId // case 1: { - //#line 8 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 6 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 8 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 6 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 8 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -890,10 +890,10 @@ // Rule 2: PackageName ::= PackageName . ErrorId // case 2: { - //#line 18 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 16 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 18 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 16 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageName = (ParsedName) getRhsSym(1); - //#line 18 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -906,10 +906,10 @@ // Rule 3: ExpressionName ::= AmbiguousName . ErrorId // case 3: { - //#line 28 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 26 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 28 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 26 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 28 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -922,10 +922,10 @@ // Rule 4: MethodName ::= AmbiguousName . ErrorId // case 4: { - //#line 38 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 36 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 38 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 36 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 38 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -938,10 +938,10 @@ // Rule 5: PackageOrTypeName ::= PackageOrTypeName . ErrorId // case 5: { - //#line 48 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 46 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 48 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 46 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); - //#line 48 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -954,10 +954,10 @@ // Rule 6: AmbiguousName ::= AmbiguousName . ErrorId // case 6: { - //#line 58 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 56 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 58 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 56 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 58 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -970,10 +970,10 @@ // Rule 7: FieldAccess ::= Primary . ErrorId // case 7: { - //#line 68 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 66 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 68 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 66 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 68 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(), Primary, nf.Id(pos(getRightSpan()), "*"))); break; @@ -983,9 +983,9 @@ // Rule 8: FieldAccess ::= super . ErrorId // case 8: { - //#line 74 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 74 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getLeftSpan())), nf.Id(pos(getRightSpan()), "*"))); break; @@ -995,12 +995,12 @@ // Rule 9: FieldAccess ::= ClassName . super$sup . ErrorId // case 9: { - //#line 80 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 78 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 80 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 78 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 78 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 78 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 80 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1010,12 +1010,12 @@ // Rule 10: MethodInvocation ::= MethodPrimaryPrefix ( ArgumentListopt ) // case 10: { - //#line 87 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 85 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 87 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 85 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" Object MethodPrimaryPrefix = (Object) getRhsSym(1); - //#line 85 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 85 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 87 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" Expr Primary = (Expr) ((Object[]) MethodPrimaryPrefix)[0]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodPrimaryPrefix)[1]; setResult(nf.Call(pos(), Primary, nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); @@ -1026,12 +1026,12 @@ // Rule 11: MethodInvocation ::= MethodSuperPrefix ( ArgumentListopt ) // case 11: { - //#line 94 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 92 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 94 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 92 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" polyglot.lex.Identifier MethodSuperPrefix = (polyglot.lex.Identifier) getRhsSym(1); - //#line 92 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 92 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 94 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" polyglot.lex.Identifier identifier = MethodSuperPrefix; setResult(nf.Call(pos(), nf.Super(pos(getLeftSpan())), nf.Id(pos(), identifier.getIdentifier()), ArgumentListopt)); break; @@ -1041,12 +1041,12 @@ // Rule 12: MethodInvocation ::= MethodClassNameSuperPrefix ( ArgumentListopt ) // case 12: { - //#line 100 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 98 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 100 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 98 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" Object MethodClassNameSuperPrefix = (Object) getRhsSym(1); - //#line 98 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 98 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" List ArgumentListopt = (List) getRhsSym(3); - //#line 100 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" ParsedName ClassName = (ParsedName) ((Object[]) MethodClassNameSuperPrefix)[0]; JPGPosition super_pos = (JPGPosition) ((Object[]) MethodClassNameSuperPrefix)[1]; polyglot.lex.Identifier identifier = (polyglot.lex.Identifier) ((Object[]) MethodClassNameSuperPrefix)[2]; @@ -1058,12 +1058,12 @@ // Rule 13: MethodPrimaryPrefix ::= Primary . ErrorId$ErrorId // case 13: { - //#line 109 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 107 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 109 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 107 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 107 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 107 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 109 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[2]; a[0] = Primary; a[1] = id(getRhsFirstTokenIndex(3)); @@ -1075,10 +1075,10 @@ // Rule 14: MethodSuperPrefix ::= super . ErrorId$ErrorId // case 14: { - //#line 117 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 115 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 117 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 115 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 117 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(id(getRhsFirstTokenIndex(3))); break; } @@ -1087,14 +1087,14 @@ // Rule 15: MethodClassNameSuperPrefix ::= ClassName . super$sup . ErrorId$ErrorId // case 15: { - //#line 122 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 120 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 122 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 120 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 120 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 120 "C:/eclipsews/head4/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head5/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(5); - //#line 122 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[3]; a[0] = ClassName; a[1] = pos(getRhsFirstTokenIndex(3)); @@ -1107,20 +1107,20 @@ // Rule 16: TypeDefDeclaration ::= TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; // case 16: { - //#line 904 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 904 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List TypeDefModifiersopt = (List) getRhsSym(1); - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List FormalParametersopt = (List) getRhsSym(5); - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 902 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 902 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 904 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 904 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { @@ -1136,18 +1136,18 @@ // Rule 17: TypeDefDeclaration ::= TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt ; // case 17: { - //#line 916 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 914 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 916 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 914 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List TypeDefModifiersopt = (List) getRhsSym(1); - //#line 914 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 914 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 914 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 914 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List TypeParametersopt = (List) getRhsSym(4); - //#line 914 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 914 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List FormalParametersopt = (List) getRhsSym(5); - //#line 914 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 914 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 916 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 916 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { @@ -1163,10 +1163,10 @@ // Rule 18: Properties ::= ( PropertyList ) // case 18: { - //#line 929 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 927 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 929 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 927 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List PropertyList = (List) getRhsSym(2); - //#line 929 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 929 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(PropertyList); break; } @@ -1174,10 +1174,10 @@ // Rule 19: PropertyList ::= Property // case 19: { - //#line 934 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 932 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 934 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 932 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(1); - //#line 934 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 934 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" List l = new TypedList(new LinkedList(), PropertyDecl.class, false); l.add(Property); setResult(l); @@ -1188,12 +1188,12 @@ // Rule 20: PropertyList ::= PropertyList , Property // case 20: { - //#line 941 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 939 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 941 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 939 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List PropertyList = (List) getRhsSym(1); - //#line 939 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 939 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(3); - //#line 941 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 941 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" PropertyList.add(Property); break; } @@ -1202,14 +1202,14 @@ // Rule 21: Property ::= Annotationsopt Identifier ResultType // case 21: { - //#line 948 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 946 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 948 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 946 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List Annotationsopt = (List) getRhsSym(1); - //#line 946 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 946 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); - //#line 946 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 946 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" TypeNode ResultType = (TypeNode) getRhsSym(3); - //#line 948 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 948 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" List annotations = extractAnnotations(Annotationsopt); PropertyDecl cd = nf.PropertyDecl(pos(), nf.FlagsNode(pos(), Flags.PUBLIC.Final()), ResultType, Identifier); cd = (PropertyDecl) ((X10Ext) cd.ext()).annotations(annotations); @@ -1221,24 +1221,24 @@ // Rule 22: MethodDeclaration ::= MethodModifiersopt def Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Throwsopt MethodBody // case 22: { - //#line 957 "C:/eclipsews/head4/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 955 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 957 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 955 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" List MethodModifiersopt = (List) getRhsSym(1); - //#line 955 "C:/eclipsews/head4/x10.compiler/src/x10/parser/x10.g" + //#line 955 "C:/eclipsews/head5/x10.compiler... [truncated message content] |
From: <ipe...@us...> - 2010-06-03 02:44:20
|
Revision: 14380 http://x10.svn.sourceforge.net/x10/?rev=14380&view=rev Author: ipeshansky Date: 2010-06-03 02:44:14 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Factor out parser fixes into Polyglot proper. Update to new Polyglot scheduler APIs. Rename CodeGenBarrier to TypeCheckBarrier. Move passes that change the AST (X10Casted, MoveFieldInitializers, X10RewriteExtern, X10RewriteAtomicMethods) to after TypeCheckBarrier. Move EnsureNoErrors to after TypeCheckBarrier. Factor out CodeGenBarrier from the C++ backend. Update comment in FieldInitializerMover. Remove unused CastRewriter. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java trunk/x10.compiler/src/x10cpp/ExtensionInfo.java trunk/x10.doc/src/x10doc/ExtensionInfo.java Removed Paths: ------------- trunk/x10.compiler/src/x10/visit/CastRewriter.java Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-03 02:42:54 UTC (rev 14379) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-03 02:44:14 UTC (rev 14380) @@ -31,11 +31,7 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; -import polyglot.ast.ClassMember; import polyglot.ast.NodeFactory; -import polyglot.ast.SourceFile; -import polyglot.ast.TopLevelDecl; -import polyglot.ast.TypeNode; import polyglot.frontend.AbstractGoal_c; import polyglot.frontend.AllBarrierGoal; import polyglot.frontend.BarrierGoal; @@ -55,7 +51,6 @@ import polyglot.frontend.VisitorGoal; import polyglot.main.Options; import polyglot.main.Report; -import polyglot.types.Flags; import polyglot.types.MemberClassResolver; import polyglot.types.MethodDef; import polyglot.types.QName; @@ -83,7 +78,6 @@ import x10.types.X10TypeSystem; import x10.types.X10TypeSystem_c; import x10.visit.AssignPropertyChecker; -import x10.visit.CastRewriter; import x10.visit.CheckNativeAnnotationsVisitor; import x10.visit.Desugarer; import x10.visit.ExprFlattener; @@ -346,8 +340,6 @@ goals.add(X10MLTypeChecked(job)); } - goals.add(CastRewritten(job)); - // Do not include LoadPlugins in list. It would cause prereqs to be added // goals.add(LoadPlugins()); goals.add(PropagateAnnotations(job)); @@ -355,19 +347,12 @@ goals.add(RegisterPlugins(job)); goals.add(PreTypeCheck(job)); - goals.add(TypesInitializedForCommandLine()); - goals.add(EnsureNoErrors(job)); + goals.add(TypesInitializedForCommandLineBarrier()); goals.add(TypeChecked(job)); goals.add(ReassembleAST(job)); - - // goals.add(X10Boxed(job)); - goals.add(X10Casted(job)); - goals.add(MoveFieldInitializers(job)); + goals.add(ConformanceChecked(job)); - goals.add(X10RewriteExtern(job)); - goals.add(X10RewriteAtomicMethods(job)); - // Data-flow analyses goals.add(ReachabilityChecked(job)); goals.add(ExceptionsChecked(job)); @@ -376,73 +361,49 @@ goals.add(ConstructorCallsChecked(job)); goals.add(ForwardReferencesChecked(job)); goals.add(PropertyAssignmentsChecked(job)); + goals.add(TypeCheckBarrier()); + goals.add(EnsureNoErrors(job)); + + goals.add(X10Casted(job)); + goals.add(MoveFieldInitializers(job)); goals.add(X10Expanded(job)); + goals.add(X10RewriteExtern(job)); + goals.add(X10RewriteAtomicMethods(job)); goals.add(NativeClassVisitor(job)); goals.add(Serialized(job)); -// goals.add(CodeGenBarrier()); goals.add(CheckNativeAnnotations(job)); - + if (x10.Configuration.WORK_STEALING) { Goal wsCodeGenGoal = WSCodeGenerator(job); - if(wsCodeGenGoal != null){ - goals.add(wsCodeGenGoal); + if (wsCodeGenGoal != null) { + goals.add(wsCodeGenGoal); + wsCodeGenGoal.addPrereq(TypeCheckBarrier()); } } goals.add(InnerClassRemover(job)); goals.addAll(Optimizer.goals(this, job)); goals.add(Desugarer(job)); + goals.add(CodeGenerated(job)); goals.add(End(job)); + InnerClassRemover(job).addPrereq(Serialized(job)); + InnerClassRemover(job).addPrereq(TypeCheckBarrier()); + // the barrier will handle prereqs on its own CodeGenerated(job).addPrereq(CodeGenBarrier()); - - return goals; - } - public Goal EnsureNoErrors(Job job) { - return new SourceGoal_c("EnsureNoErrors", job) { - public boolean runTask() { - return !job.reportedErrors(); - } - }.intern(this); - } - - public Goal Parsed(Job job) { - return new X10ParserGoal(extInfo.compiler(), job).intern(this); - } - - /** - * This goal never fails. Instead, if the parser does not create an AST, this - * creates a dummy AST with a single class with the expected name, and succeeds. - * The {@link #EnsureNoErrors(Job)} goal should be used to check before proceeding - * to typecheck the job. - * @author igor - */ - static class X10ParserGoal extends ParserGoal { - public X10ParserGoal(Compiler compiler, Job job) { - super(compiler, job); + Desugarer(job).addPrereq(TypeCheckBarrier()); + CodeGenerated(job).addPrereq(Desugarer(job)); + List<Goal> optimizations = Optimizer.goals(this, job); + for (Goal goal : optimizations) { + goal.addPrereq(TypeCheckBarrier()); + CodeGenerated(job).addPrereq(goal); } - private SourceFile createDummyAST() { - NodeFactory nf = job().extensionInfo().nodeFactory(); - String fName = job.source().name(); - Position pos = new Position(job.source().name(), fName); - String name = fName.substring(fName.lastIndexOf(File.separatorChar)+1, fName.lastIndexOf('.')); - TopLevelDecl decl = nf.ClassDecl(pos, nf.FlagsNode(pos, Flags.PUBLIC), - nf.Id(pos, name), null, Collections.<TypeNode>emptyList(), - nf.ClassBody(pos, Collections.<ClassMember>emptyList())); - SourceFile ast = nf.SourceFile(pos, Collections.singletonList(decl)).source(job.source()); - return ast; - } - public boolean runTask() { - boolean result = super.runTask(); - if (job().ast() == null) { - job().ast(createDummyAST()); - } - return true; - } + + return goals; } Goal PrintWeakCallsCount; @@ -486,32 +447,61 @@ } } - - public Goal CodeGenBarrier() { - if (Globals.Options().compile_command_line_only) { - return new BarrierGoal("CodeGenBarrier", commandLineJobs()) { - @Override - public Goal prereqForJob(Job job) { - return Serialized(job); - } - }; - } - else { - return new AllBarrierGoal("CodeGenBarrier", this) { - @Override - public Goal prereqForJob(Job job) { - if (!scheduler.commandLineJobs().contains(job) && - ((ExtensionInfo) extInfo).manifestContains(job.source().path())) - { - return null; - } - return Serialized(job); - } - }; - } + + public Goal TypeCheckBarrier() { + String name = "TypeCheckBarrier"; + if (Globals.Options().compile_command_line_only) { + return new BarrierGoal(name, commandLineJobs()) { + @Override + public Goal prereqForJob(Job job) { + return ReassembleAST(job); + } + }.intern(this); + } + else { + return new AllBarrierGoal(name, this) { + @Override + public Goal prereqForJob(Job job) { + if (!scheduler.commandLineJobs().contains(job) && + ((ExtensionInfo) extInfo).manifestContains(job.source().path())) + { + return null; + } + return ReassembleAST(job); + } + }.intern(this); + } } - - + + protected Goal codegenPrereq(Job job) { + return InnerClassRemover(job); + } + + public Goal CodeGenBarrier() { + String name = "CodeGenBarrier"; + if (Globals.Options().compile_command_line_only) { + return new BarrierGoal(name, commandLineJobs()) { + @Override + public Goal prereqForJob(Job job) { + return codegenPrereq(job); + } + }.intern(this); + } + else { + return new AllBarrierGoal(name, this) { + @Override + public Goal prereqForJob(Job job) { + if (!scheduler.commandLineJobs().contains(job) && + ((ExtensionInfo) extInfo).manifestContains(job.source().path())) + { + return null; + } + return codegenPrereq(job); + } + }.intern(this); + } + } + public Goal Serialized(Job job) { Compiler compiler = job.extensionInfo().compiler(); X10TypeSystem ts = (X10TypeSystem) job.extensionInfo().typeSystem(); @@ -524,7 +514,6 @@ }.intern(this); } - // @Override // public Goal ImportTableInitialized(Job job) { // TypeSystem ts = job.extensionInfo().typeSystem(); @@ -615,14 +604,6 @@ return new VisitorGoal("X10ExprFlattened", job, new ExprFlattener(job, ts, nf)).intern(this); } - // after disambiguation, before type elaboration - public Goal CastRewritten(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("CastRewritten", job, new CastRewriter(job, ts, nf)).intern(this); - } - - public Goal PropertyAssignmentsChecked(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); Deleted: trunk/x10.compiler/src/x10/visit/CastRewriter.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CastRewriter.java 2010-06-03 02:42:54 UTC (rev 14379) +++ trunk/x10.compiler/src/x10/visit/CastRewriter.java 2010-06-03 02:44:14 UTC (rev 14380) @@ -1,90 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.visit; - -import polyglot.ast.Cast; -import polyglot.ast.Instanceof; -import polyglot.ast.Node; -import polyglot.ast.NodeFactory; -import polyglot.ast.TypeNode; -import polyglot.frontend.Job; -import polyglot.frontend.SetResolverGoal; -import polyglot.types.SemanticException; -import polyglot.types.TypeSystem; -import polyglot.types.Types; -import polyglot.visit.ContextVisitor; -import polyglot.visit.NodeVisitor; -import x10.ast.AmbDepTypeNode; -import x10.ast.DepParameterExpr; -import x10.ast.X10Cast; -import x10.ast.X10NodeFactory; - -/** - * Instanceof and cast need the depexpr containedin the the type (if any) as a DepExpr, so that - * code can be generated from it for runtime checks. - * So the depexpr must be retrieved and stored as an Expr before TypeElaboration has run. - * This separate pass does that. (This can also be handled during parsing.) - * @author vj 12/2007 - * - */ -public class CastRewriter extends ContextVisitor { - - /** - * @param job - * @param ts - * @param nf - */ - public CastRewriter(Job job, TypeSystem ts, NodeFactory nf) { - super(job, ts, nf); - } - - // DISABLE the pass - @Override - public Node override(Node parent, Node n) { - return n; - } - - protected Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { - X10NodeFactory nf = (X10NodeFactory) this.nf; - - Node result = n; - -// if (n instanceof X10Cast) { -// X10Cast nn = (X10Cast) n; -// TypeNode xn = (TypeNode) nn.castType(); -// DepParameterExpr e = null; -// -// if (xn instanceof AmbDepTypeNode) { -// AmbDepTypeNode adtn = (AmbDepTypeNode) xn; -// TypeNode base = nf.X10AmbTypeNode(xn.position(), adtn.prefix(), adtn.name()); -// base = base.typeRef(Types.lazyRef(ts.unknownType(base.position()), new SetResolverGoal(job))); -// DepParameterExpr dep = adtn.constraint(); -// return nf.DepCast(n.position(), base, dep, nn.expr(), nn.convert()); -// } -// } -// if (n instanceof Instanceof) { -// Instanceof nn = (Instanceof) n; -// TypeNode xn = (TypeNode) nn.compareType(); -// DepParameterExpr e = null; -// -// if (xn instanceof AmbDepTypeNode) { -// AmbDepTypeNode adtn = (AmbDepTypeNode) xn; -// TypeNode base = nf.X10AmbTypeNode(xn.position(), adtn.prefix(), adtn.name()); -// base = base.typeRef(Types.lazyRef(ts.unknownType(base.position()), new SetResolverGoal(job))); -// DepParameterExpr dep = adtn.constraint(); -// return nf.DepInstanceof(n.position(), base, dep, nn.expr()); -// } -// } - return result; - } - -} Modified: trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java =================================================================== --- trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java 2010-06-03 02:42:54 UTC (rev 14379) +++ trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java 2010-06-03 02:44:14 UTC (rev 14380) @@ -37,7 +37,7 @@ import x10.types.X10TypeSystem; /** - * Visitor that inserts boxing and unboxing code into the AST. + * Visitor that moves field initializers to the constructor. */ public class FieldInitializerMover extends ContextVisitor { X10TypeSystem xts; Modified: trunk/x10.compiler/src/x10cpp/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2010-06-03 02:42:54 UTC (rev 14379) +++ trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2010-06-03 02:44:14 UTC (rev 14380) @@ -137,21 +137,11 @@ NodeFactory nf = extInfo.nodeFactory(); return new VisitorGoal("CheckNativeAnnotations", job, new CheckNativeAnnotationsVisitor(job, ts, nf, "c++")).intern(this); } - public Goal NativeClassVisitor(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "c++")).intern(this); - } - public Goal InnerClassesRemoved(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("InnerClassRemover", job, new X10InnerClassRemover(job, ts, nf)).intern(this); + public Goal NativeClassVisitor(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "c++")).intern(this); } - public Goal StaticNestedClassesRemoved(Job job) { - TypeSystem ts = extInfo.typeSystem(); - NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("StaticNestedClassRemover", job, new StaticNestedClassRemover(job, ts, nf)).intern(this); - } @Override public Goal CodeGenerated(Job job) { TypeSystem ts = extInfo.typeSystem(); @@ -168,42 +158,15 @@ } }.intern(this); } - public Goal NewCodeGenBarrier() { - if (Globals.Options().compile_command_line_only) { - return new BarrierGoal("NewCodeGenBarrier", commandLineJobs()) { - @Override - public Goal prereqForJob(Job job) { - return StaticNestedClassesRemoved(job); - } - }; - } - else { - return new AllBarrierGoal("NewCodeGenBarrier", this) { - @Override - public Goal prereqForJob(Job job) { - if (!scheduler.commandLineJobs().contains(job) && - ((ExtensionInfo) extInfo).manifestContains(job.source().path())) - { - return null; - } - return StaticNestedClassesRemoved(job); - } - }; - } + @Override + protected Goal codegenPrereq(Job job) { + return StaticNestedClassRemover(job); } @Override public List<Goal> goals(Job job) { - List<Goal> res = super.goals(job); - InnerClassesRemoved(job).addPrereq(Serialized(job)); - InnerClassesRemoved(job).addPrereq(CodeGenBarrier()); - StaticNestedClassesRemoved(job).addPrereq(InnerClassesRemoved(job)); - CodeGenerated(job).addPrereq(NewCodeGenBarrier()); - CodeGenerated(job).addPrereq(Desugarer(job)); - List<Goal> optimizations = Optimizer.goals(this, job); - for (Goal goal : optimizations) { - CodeGenerated(job).addPrereq(goal); - } - return res; + List<Goal> goals = super.goals(job); + StaticNestedClassRemover(job).addPrereq(InnerClassRemover(job)); + return goals; } } Modified: trunk/x10.doc/src/x10doc/ExtensionInfo.java =================================================================== --- trunk/x10.doc/src/x10doc/ExtensionInfo.java 2010-06-03 02:42:54 UTC (rev 14379) +++ trunk/x10.doc/src/x10doc/ExtensionInfo.java 2010-06-03 02:44:14 UTC (rev 14380) @@ -50,10 +50,8 @@ goals.add(TypesInitialized(job)); goals.add(ImportTableInitialized(job)); - goals.add(CastRewritten(job)); - goals.add(PreTypeCheck(job)); - goals.add(TypesInitializedForCommandLine()); + goals.add(TypesInitializedForCommandLineBarrier()); goals.add(TypeChecked(job)); goals.add(ReassembleAST(job)); @@ -61,7 +59,7 @@ goals.add(End(job)); // the barrier will handle prereqs on its own - X10DocGenerated(job).addPrereq(CodeGenBarrier()); + X10DocGenerated(job).addPrereq(TypeCheckBarrier()); return goals; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-06-04 02:22:50
|
Revision: 14401 http://x10.svn.sourceforge.net/x10/?rev=14401&view=rev Author: ipeshansky Date: 2010-06-04 02:22:44 +0000 (Fri, 04 Jun 2010) Log Message: ----------- Bump polyglot version to 3.2.0. Modified Paths: -------------- trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.dist/build.xml Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-06-03 21:51:17 UTC (rev 14400) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-06-04 02:22:44 UTC (rev 14401) @@ -6,7 +6,7 @@ Bundle-Localization: plugin Require-Bundle: x10.common, x10.constraints, - polyglot3, + polyglot3;bundle-version="3.2.0", polyglot.bytecode;bundle-version="1.0.0", lpg.runtime.java;bundle-version="2.0.18" Export-Package: x10, Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2010-06-03 21:51:17 UTC (rev 14400) +++ trunk/x10.dist/build.xml 2010-06-04 02:22:44 UTC (rev 14401) @@ -14,7 +14,7 @@ <property name="ecj.jar.url" value="http://dist.codehaus.org/x10/dependencies/ecj-3.5.1.jar"/> <property name="polyglot.jar" value="polyglot3.jar"/> <property name="polyglot.url" value="http://polyglot-compiler.googlecode.com/svn/trunk/updates/plugins"/> - <property name="polyglot.jar.url" value="${polyglot.url}/polyglot3_3.1.3.jar"/> + <property name="polyglot.jar.url" value="${polyglot.url}/polyglot3_3.2.0.jar"/> <property name="polyglot.bytecode.jar" value="polyglot-bytecode.jar"/> <property name="polyglot.bytecode.url" value="http://polyglot-compiler.googlecode.com/svn/trunk/polyglot.bytecode/lib"/> <property name="polyglot.bytecode.jar.url" value="${polyglot.bytecode.url}/polyglot-bytecode.jar"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-06-04 04:00:28
|
Revision: 14404 http://x10.svn.sourceforge.net/x10/?rev=14404&view=rev Author: dgrove-oss Date: 2010-06-04 04:00:21 +0000 (Fri, 04 Jun 2010) Log Message: ----------- XTENLANG-1398: Implement Byte,toString() and parse() patch, including test case, from Josh. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10aux/byte_utils.cc trunk/x10.runtime/src-x10/x10/lang/Byte.x10 Added Paths: ----------- trunk/x10.runtime/src-java/x10/core/Bytes.java trunk/x10.tests/examples/Misc/TestByteToString.x10 Modified: trunk/x10.runtime/src-cpp/x10aux/byte_utils.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/byte_utils.cc 2010-06-04 02:52:37 UTC (rev 14403) +++ trunk/x10.runtime/src-cpp/x10aux/byte_utils.cc 2010-06-04 04:00:21 UTC (rev 14404) @@ -7,21 +7,40 @@ * http://www.opensource.org/licenses/eclipse-1.0.php * * (C) Copyright IBM Corporation 2006-2010. + * (C) Copyright Australian National University 2010. */ #include <x10aux/byte_utils.h> #include <x10aux/basic_functions.h> -#include <x10/lang/String.h> \ +#include <x10/lang/String.h> using namespace x10::lang; using namespace std; using namespace x10aux; const ref<String> x10aux::byte_utils::toString(x10_byte value, x10_int radix) { - (void) value; (void) radix; - assert(false); /* FIXME: STUBBED NATIVE */ - return null; + assert(radix>=2); + assert(radix<=16); + static char numerals[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + // worst case is binary -- needs 8 digits and a '\0' + char buf[9] = ""; //zeroes entire buffer (S6.7.8.21) + x10_int value2; + if (value < 0) { + value2 = 0x80 - (value & 0x7F); + } else { + value2 = value; + } + char *b; + // start on the '\0', will predecrement so will not clobber it + for (b=&buf[8] ; value2>0 ; value2/=radix) { + *(--b) = numerals[value2 % radix]; + } + if (value < 0) { + *(--b) = '-'; + } + return String::Steal(alloc_printf("%s",b)); } const ref<String> x10aux::byte_utils::toHexString(x10_byte value) { @@ -41,15 +60,15 @@ } x10_byte x10aux::byte_utils::parseByte(const ref<String>& s, x10_int radix) { - (void) s; - assert(false); /* FIXME: STUBBED NATIVE */ - return radix; /* Bogus, but use radix to avoid warning about unused parameter */ + nullCheck(s); + char* dummy; + return strtol(s.operator->()->c_str(), &dummy, radix); } x10_byte x10aux::byte_utils::parseByte(const ref<String>& s) { - (void) s; - assert(false); /* FIXME: STUBBED NATIVE */ - return 0; + nullCheck(s); + // FIXME: NumberFormatException? + return atoi(nullCheck(s)->c_str()); } // vim:tabstop=4:shiftwidth=4:expandtab Added: trunk/x10.runtime/src-java/x10/core/Bytes.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Bytes.java (rev 0) +++ trunk/x10.runtime/src-java/x10/core/Bytes.java 2010-06-04 04:00:21 UTC (rev 14404) @@ -0,0 +1,24 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright Australian National University 2009-2010. + * + * @author milthorpe + */ +package x10.core; + +public class Bytes { + public static String toString(byte a, int radix) { + if (a >= 0) { + return Integer.toString(a, radix); + } else { + int b = (0x80000000 - a) & 0x7FFFFFFF; + return "-" + Integer.toString(b, radix); + } + } +} Property changes on: trunk/x10.runtime/src-java/x10/core/Bytes.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-x10/x10/lang/Byte.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-06-04 02:52:37 UTC (rev 14403) +++ trunk/x10.runtime/src-x10/x10/lang/Byte.x10 2010-06-04 04:00:21 UTC (rev 14404) @@ -307,13 +307,12 @@ @Native("c++", "((x10_byte)0x7f)") public const MAX_VALUE = 0x7f as Byte; - /** * Returns a String representation of this Byte in the specified radix. * @param radix the radix to use in the String representation * @return a String representation of this Byte in the specified radix. */ - @Native("java", "java.lang.Integer.toString(#0, #1)") + @Native("java", "x10.core.Bytes.toString(#0, #1)") @Native("c++", "x10aux::byte_utils::toString(#0, #1)") public global safe native def toString(radix:Int): String; @@ -321,7 +320,7 @@ * Returns a String representation of this Byte as a hexadecimal number. * @return a String representation of this Byte as a hexadecimal number. */ - @Native("java", "java.lang.Integer.toHexString(#0)") + @Native("java", "x10.core.Bytes.toString(#0, 16)") @Native("c++", "x10aux::byte_utils::toHexString(#0)") public global safe native def toHexString(): String; @@ -329,7 +328,7 @@ * Returns a String representation of this Byte as an octal number. * @return a String representation of this Byte as an octal number. */ - @Native("java", "java.lang.Integer.toOctalString(#0)") + @Native("java", "x10.core.Bytes.toString(#0, 8)") @Native("c++", "x10aux::byte_utils::toOctalString(#0)") public global safe native def toOctalString(): String; @@ -337,7 +336,7 @@ * Returns a String representation of this Byte as a binary number. * @return a String representation of this Byte as a binary number. */ - @Native("java", "java.lang.Integer.toBinaryString(#0)") + @Native("java", "x10.core.Bytes.toString(#0, 2)") @Native("c++", "x10aux::byte_utils::toBinaryString(#0)") public global safe native def toBinaryString(): String; Added: trunk/x10.tests/examples/Misc/TestByteToString.x10 =================================================================== --- trunk/x10.tests/examples/Misc/TestByteToString.x10 (rev 0) +++ trunk/x10.tests/examples/Misc/TestByteToString.x10 2010-06-04 04:00:21 UTC (rev 14404) @@ -0,0 +1,66 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright Australian National University 2009-2010. + * @author milthorpe + */ +import harness.x10Test; + +public class TestByteToString extends x10Test { + public def run() { + val a = 42 as Byte; + chk("42".equals(a.toString())); + chk("101010".equals(a.toBinaryString())); + chk("52".equals(a.toOctalString())); + chk("2a".equals(a.toHexString())); + + chk(a == Byte.parse("42")); + chk(a == Byte.parse("101010", 2)); + chk(a == Byte.parse("52", 8)); + chk(a == Byte.parse("2a", 16)); + + val b = -23 as Byte; + chk("-23".equals(b.toString())); + chk("-10111".equals(b.toBinaryString()));; + chk("-27".equals(b.toOctalString())); + chk("-17".equals(b.toHexString())); + + chk(b == Byte.parse("-23")); + chk(b == Byte.parse("-10111", 2)); + chk(b == Byte.parse("-27", 8)); + chk(b == Byte.parse("-17", 16)); + + val c = 127 as Byte; + chk("127".equals(c.toString())); + chk("1111111".equals(c.toBinaryString())); + chk("177".equals(c.toOctalString())); + chk("7f".equals(c.toHexString())); + + chk(c == Byte.parse("127")); + chk(c == Byte.parse("1111111", 2)); + chk(c == Byte.parse("177", 8)); + chk(c == Byte.parse("7f", 16)); + + val d = -128 as Byte; + chk("-128".equals(d.toString())); + chk("-10000000".equals(d.toBinaryString())); + chk("-200".equals(d.toOctalString())); + chk("-80".equals(d.toHexString())); + + chk(d == Byte.parse("-128")); + chk(d == Byte.parse("-10000000", 2)); + chk(d == Byte.parse("-200", 8)); + chk(d == Byte.parse("-80", 16)); + + return true; + } + + public static def main(Rail[String]) { + new TestByteToString().execute(); + } +} Property changes on: trunk/x10.tests/examples/Misc/TestByteToString.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-06-04 17:51:05
|
Revision: 14426 http://x10.svn.sourceforge.net/x10/?rev=14426&view=rev Author: ipeshansky Date: 2010-06-04 17:50:57 +0000 (Fri, 04 Jun 2010) Log Message: ----------- XTENLANG-1372: patches from Jochen Keil (applied or adapted). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java trunk/x10.dist/build.xml trunk/x10.runtime/Make.rules trunk/x10.runtime/build.xml trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc trunk/x10.runtime/src-cpp/x10aux/long_utils.cc trunk/x10.runtime/src-cpp/x10aux/math.h Added Paths: ----------- trunk/x10.compiler/src/x10cpp/postcompiler/FreeBSD_CXXCommandBuilder.java Modified: trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.compiler/src/x10cpp/postcompiler/CXXCommandBuilder.java 2010-06-04 17:50:57 UTC (rev 14426) @@ -307,6 +307,8 @@ return new SunOS_CXXCommandBuilder(options, eq); if (PLATFORM.startsWith("macosx_")) return new MacOSX_CXXCommandBuilder(options, eq); + if (PLATFORM.startsWith("freebsd_")) + return new FreeBSD_CXXCommandBuilder(options, eq); eq.enqueue(ErrorInfo.WARNING, "Unknown platform '"+PLATFORM+"'; using the default post-compiler (g++)"); return new CXXCommandBuilder(options, eq); Added: trunk/x10.compiler/src/x10cpp/postcompiler/FreeBSD_CXXCommandBuilder.java =================================================================== --- trunk/x10.compiler/src/x10cpp/postcompiler/FreeBSD_CXXCommandBuilder.java (rev 0) +++ trunk/x10.compiler/src/x10cpp/postcompiler/FreeBSD_CXXCommandBuilder.java 2010-06-04 17:50:57 UTC (rev 14426) @@ -0,0 +1,54 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10cpp.postcompiler; + +import java.util.ArrayList; + +import polyglot.main.Options; +import polyglot.util.ErrorQueue; + +public class FreeBSD_CXXCommandBuilder extends CXXCommandBuilder { + protected static final boolean USE_X86 = CXXCommandBuilder.PLATFORM.endsWith("_x86"); + protected static final boolean USE_BFD = System.getenv("USE_BFD")!=null; + + public FreeBSD_CXXCommandBuilder(Options options, ErrorQueue eq) { + super(options, eq); + assert (CXXCommandBuilder.PLATFORM.startsWith("freebsd_")); + } + + protected void addPreArgs(ArrayList<String> cxxCmd) { + super.addPreArgs(cxxCmd); + cxxCmd.add("-Wno-long-long"); + cxxCmd.add("-Wno-unused-parameter"); + cxxCmd.add("-pthread"); + if (USE_X86) { + cxxCmd.add("-msse2"); + cxxCmd.add("-mfpmath=sse"); + } + } + + protected void addPostArgs(ArrayList<String> cxxCmd) { + super.addPostArgs(cxxCmd); + + cxxCmd.remove("-ldl"); + // Support for loading shared libraries from x10.dist/lib + cxxCmd.add("-Wl,--rpath"); + cxxCmd.add("-Wl,"+X10_DIST+"/lib"); + + cxxCmd.add("-Wl,-export-dynamic"); + cxxCmd.add("-lrt"); + if (USE_BFD) { + cxxCmd.add("-lbfd"); + cxxCmd.add("-liberty"); + } + } +} Modified: trunk/x10.dist/build.xml =================================================================== --- trunk/x10.dist/build.xml 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.dist/build.xml 2010-06-04 17:50:57 UTC (rev 14426) @@ -390,6 +390,7 @@ Darwin,*,i*86) export X10_PLATFORM='macosx_x86';; Darwin,*,powerpc) export X10_PLATFORM='macosx_ppc';; SunOS,*,sparc) export X10_PLATFORM='sunos_sparc';; + FreeBSD,*64*,*) export X10_PLATFORM='freebsd_amd64';; *) echo "Unrecognized platform: '$UNAME'"; exit 1;; esac # NOTE: the above assumes that Cygwin==win32 (probably valid) Modified: trunk/x10.runtime/Make.rules =================================================================== --- trunk/x10.runtime/Make.rules 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.runtime/Make.rules 2010-06-04 17:50:57 UTC (rev 14426) @@ -47,19 +47,15 @@ ifdef JAVA_HOME ifeq ($(shell uname -s),AIX) JNI_INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/inclue/aix - else - ifeq ($(shell uname -s),Linux) - JNI_INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux - else - ifeq ($(firstword $(subst _, ,$(shell uname -s))),CYGWIN) - JAVA_CYGPATH = "$(shell cygpath $(JAVA_HOME))" - JNI_INCLUDES = -I$(JAVA_CYGPATH)/include -I$(JAVA_CYGPATH)/include/win32 - else - ifeq ($(shell uname -s),Darwin) - # TODO!! - endif - endif - endif + else ifeq ($(shell uname -s),Linux) + JNI_INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux + else ifeq ($(firstword $(subst _, ,$(shell uname -s))),CYGWIN) + JAVA_CYGPATH = "$(shell cygpath $(JAVA_HOME))" + JNI_INCLUDES = -I$(JAVA_CYGPATH)/include -I$(JAVA_CYGPATH)/include/win32 + else ifeq ($(shell uname -s),Darwin) + # TODO!! + else ifeq ($(shell uname -s),FreeBSD) + JNI_INCLUDES = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/freebsd endif endif @@ -127,54 +123,53 @@ override CXXFLAGS += -ansi -pedantic -Wall -Wextra -Wno-long-long -Wno-unused-parameter ifeq ($(shell uname -s),Linux) - override CXXFLAGS += -pthread + override CXXFLAGS += -pthread override CXXFLAGS_SHARED += -shared -fPIC export X10RT_TEST_LDFLAGS = -Wl,--rpath -Wl,$(X10_HOME)/x10.runtime/x10rt/lib ifeq ($(shell uname -m),x86_64) export X10RT_PLATFORM=linux_x86_64 + else ifeq ($(shell uname -m),ppc64) + export X10RT_PLATFORM=linux_ppc_64 else - ifeq ($(shell uname -m),ppc64) - export X10RT_PLATFORM=linux_ppc_64 - else - export X10RT_PLATFORM=linux_x86_32 - endif + export X10RT_PLATFORM=linux_x86_32 endif - else - ifeq ($(firstword $(subst _, ,$(shell uname -s))),CYGWIN) - ifndef X10_SHARED_LIB_DEFAULT_OVERRIDE - export X10_STATIC_LIB=1 - endif - export X10RT_PLATFORM=cygwin - override CXXFLAGS_SHARED += -shared -Wl,--export-all-symbols -Wl,--enable-auto-import - LIBPREFIX := - LIBSUFFIX := .dll - ifndef DEFAULT_X10RT_LIB - DEFAULT_X10RT_LIB = pgas_sockets - endif - else - ifeq ($(shell uname -s),Darwin) - export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 && echo darwin64 || echo darwin) - override CXXFLAGS_SHARED += -fPIC - override LDFLAGS_SHARED += -dynamiclib -undefined dynamic_lookup -install_name '@rpath/$@' - export X10RT_TEST_LDFLAGS = -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt/lib -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt - ifdef USE_32BIT - override CXXFLAGS += -arch i386 - endif - ifdef USE_64BIT - override CXXFLAGS += -arch x86_64 - endif - AR = libtool - # Warning: Order matters! The "-o" has to be at the end. - ARFLAGS = -static -o - else - ifeq ($(shell uname -s),SunOS) - ifndef X10_SHARED_LIB_DEFAULT_OVERRIDE - export X10_STATIC_LIB=1 - endif - export X10RT_PLATFORM=sunos - endif - endif + else ifeq ($(firstword $(subst _, ,$(shell uname -s))),CYGWIN) + ifndef X10_SHARED_LIB_DEFAULT_OVERRIDE + export X10_STATIC_LIB=1 endif + export X10RT_PLATFORM=cygwin + override CXXFLAGS_SHARED += -shared -Wl,--export-all-symbols -Wl,--enable-auto-import + LIBPREFIX := + LIBSUFFIX := .dll + ifndef DEFAULT_X10RT_LIB + DEFAULT_X10RT_LIB = pgas_sockets + endif + else ifeq ($(shell uname -s),Darwin) + export X10RT_PLATFORM=$(shell echo | gcc -E -dM - | grep -q x86_64 && echo darwin64 || echo darwin) + override CXXFLAGS_SHARED += -fPIC + override LDFLAGS_SHARED += -dynamiclib -undefined dynamic_lookup -install_name '@rpath/$@' + export X10RT_TEST_LDFLAGS = -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt/lib -Wl,-rpath -Wl,$(X10_HOME)/x10.runtime/x10rt + ifdef USE_32BIT + override CXXFLAGS += -arch i386 + endif + ifdef USE_64BIT + override CXXFLAGS += -arch x86_64 + endif + AR = libtool + # Warning: Order matters! The "-o" has to be at the end. + ARFLAGS = -static -o + else ifeq ($(shell uname -s),SunOS) + ifndef X10_SHARED_LIB_DEFAULT_OVERRIDE + export X10_STATIC_LIB=1 + endif + export X10RT_PLATFORM=sunos + else ifeq ($(shell uname -s),FreeBSD) + override CXXFLAGS += -pthread + override CXXFLAGS_SHARED += -shared -fPIC + export X10RT_TEST_LDFLAGS = -Wl,--rpath -Wl,$(X10_HOME)/x10.runtime/x10rt/lib + ifeq ($(shell uname -m),amd64) + export X10RT_PLATFORM=freebsd_amd64 + endif endif endif endif Modified: trunk/x10.runtime/build.xml =================================================================== --- trunk/x10.runtime/build.xml 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.runtime/build.xml 2010-06-04 17:50:57 UTC (rev 14426) @@ -75,6 +75,7 @@ <os family="unix" name="linux"/> <os family="mac"/> <os family="windows"/> + <os family="unix" name="freebsd"/> </or> </and> </condition> @@ -366,6 +367,19 @@ </exec> </sequential> </if> + <if> + <conditions> + <os family="unix" name="freebsd"/> + </conditions> + <sequential> + <exec executable="${bash.exe}" dir="${bdwgc.dir}/src" failonerror="true"> + <arg value="${bdwgc.dir}/src/configure" /> + <arg value="-enable-threads=posix" /> + <arg value="-enable-thread-local-alloc" /> + <arg value="--prefix=${bdwgc.platform.dir}/install" /> + </exec> + </sequential> + </if> <exec executable="${make.exe}" dir="${bdwgc.dir}/src" failonerror="true"> <env key="OBJECT_MODE" value="32_64" /> <arg value="-j${available.procs}" /> Modified: trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.runtime/src-cpp/x10/io/File__NativeFile.cc 2010-06-04 17:50:57 UTC (rev 14426) @@ -20,6 +20,10 @@ #include <sys/stat.h> #include <sys/time.h> +#if defined(__FreeBSD__) +#include <sys/types.h> +#endif + #include <limits.h> using namespace x10::lang; @@ -105,6 +109,9 @@ #elif defined (_AIX) # define STAT_TIME_SEC(type) st_##type##time # define STAT_TIME_NSEC(type) st_##type##time_n +#elif defined (__FreeBSD__) +# define STAT_TIME_SEC(type) st_##type##timespec.tv_sec +# define STAT_TIME_NSEC(type) st_##type##timespec.tv_nsec #else # define STAT_TIME_SEC(type) st_##type##tim.tv_sec # define STAT_TIME_NSEC(type) st_##type##tim.tv_nsec Modified: trunk/x10.runtime/src-cpp/x10aux/long_utils.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/long_utils.cc 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.runtime/src-cpp/x10aux/long_utils.cc 2010-06-04 17:50:57 UTC (rev 14426) @@ -15,7 +15,7 @@ #include <x10aux/basic_functions.h> #include <x10/lang/String.h> -#ifdef __CYGWIN__ +#if defined(__CYGWIN__) || defined(__FreeBSD__) extern "C" long long atoll(const char *); #endif Modified: trunk/x10.runtime/src-cpp/x10aux/math.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/math.h 2010-06-04 17:39:23 UTC (rev 14425) +++ trunk/x10.runtime/src-cpp/x10aux/math.h 2010-06-04 17:50:57 UTC (rev 14426) @@ -25,6 +25,9 @@ #ifdef M_LOG2_E # define SAVE_EXTRA_CONSTANTS #endif +#ifdef DOMAIN +# define SAVE_MATHERR_CONSTANTS +#endif #ifdef signgam # define SAVE_SIGNGAM #endif @@ -96,13 +99,15 @@ #ifdef SAVE_SIGNGAM SAVE_MATH_CONST(int, signgam); #endif - #ifdef SAVE_CONSTANTS + #ifdef SAVE_MATHERR_CONSTANTS SAVE_MATH_CONST(int, DOMAIN); SAVE_MATH_CONST(int, SING); SAVE_MATH_CONST(int, OVERFLOW); SAVE_MATH_CONST(int, UNDERFLOW); SAVE_MATH_CONST(int, TLOSS); SAVE_MATH_CONST(int, PLOSS); + #endif + #ifdef SAVE_CONSTANTS SAVE_MATH_CONST(double, M_E); SAVE_MATH_CONST(double, M_LOG2E); SAVE_MATH_CONST(double, M_LOG10E); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-06-04 18:15:41
|
Revision: 14428 http://x10.svn.sourceforge.net/x10/?rev=14428&view=rev Author: sparksparkspark Date: 2010-06-04 18:15:34 +0000 (Fri, 04 Jun 2010) Log Message: ----------- CUDA flies once more Modified Paths: -------------- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/network.h trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-06-04 18:00:21 UTC (rev 14427) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-06-04 18:15:34 UTC (rev 14428) @@ -380,13 +380,35 @@ return r; } - protected MultipleValues processLoop(For loop) { + protected MultipleValues processLoop(Block for_block) { + /* example of the loop we're trying to absorb + { + final x10.lang.Int{self==0} block321min322 = 0; + final x10.lang.Int block321max323 = x10.lang.Int{self==8, blocks==8}.operator-(blocks, 1); + for (x10.lang.Int{self==0} block321 = block321min322;; x10.lang.Int{self==0}.operator<=(block321, block321max323)eval(block321 += 1);) { + final x10.lang.Int block = block321; + { + ... + } + } + } + */ + + assert for_block.statements().size() == 3 : for_block.statements().size(); + // test that it is of the form for (blah in region) + Stmt i_ = for_block.statements().get(0); + Stmt j_ = for_block.statements().get(1); + Stmt for_block2 = for_block.statements().get(2); + assert for_block2 instanceof For : for_block2.getClass(); // FIXME: proper + // error + For loop = (For) for_block2; MultipleValues r = new MultipleValues(); - assert loop.inits().size() == 2 : loop.inits(); - ForInit i_ = loop.inits().get(0); + assert loop.inits().size() == 1 : loop.inits(); + // loop inits are not actually used + //ForInit i_ = loop.inits().get(0); assert i_ instanceof LocalDecl : i_.getClass(); LocalDecl i = (LocalDecl) i_; - ForInit j_ = loop.inits().get(1); + //ForInit j_ = loop.inits().get(1); assert j_ instanceof LocalDecl : j_.getClass(); LocalDecl j = (LocalDecl) j_; assert loop.cond() instanceof X10Call : loop.cond().getClass(); @@ -459,6 +481,33 @@ super.visit(b); if (blockIsKernel(b)) { Block_c closure_body = b; + //System.out.println(b); + /* example of KMeansCUDA kernel + { + [OPTIONAL] final x10.lang.Int{self==8} blocks = x10.compiler.CUDAUtilities.autoBlocks(); + [OPTIONAL] final x10.lang.Int{self==1} threads = x10.compiler.CUDAUtilities.autoThreads(); + { + final x10.lang.Int{self==0} block321min322 = 0; + final x10.lang.Int block321max323 = x10.lang.Int{self==8, blocks==8}.operator-(blocks, 1); + for (x10.lang.Int{self==0} block321 = block321min322;; x10.lang.Int{self==0}.operator<=(block321, block321max323)eval(block321 += 1);) { + final x10.lang.Int block = block321; + { + final x10.lang.Rail[x10.lang.Float]{self.home==gpu} clustercache = x10.lang.Rail.make[x10.lang.Float](x10.lang.Int{self==num_clusters}.operator*(num_clusters, 4), clusters_copy); + { + final x10.lang.Int{self==0} thread318min319 = 0; + final x10.lang.Int thread318max320 = x10.lang.Int{self==1, threads==1}.operator-(threads, 1); + for (x10.lang.Int{self==0} thread318 = thread318min319;; x10.lang.Int{self==0}.operator<=(thread318, thread318max320)eval(thread318 += 1);) { + final x10.lang.Int thread = thread318; + { + eval(x10.lang.Runtime.runAsync( (){}: x10.lang.Void => { ... })); + } + } + } + } + } + } + } + */ assert !generatingKernel() : "Nesting of cuda annotation makes no sense."; // TODO: assert the block is the body of an async @@ -467,21 +516,20 @@ checkAutoVar(b.statements().get(0)); checkAutoVar(b.statements().get(1)); } - Stmt loop_ = b.statements().get(b.statements().size()-1); - // test that it is of the form for (blah in region) - assert loop_ instanceof For : loop_.getClass(); // FIXME: proper - // error - For loop = (For) loop_; + Stmt for_block_ = b.statements().get(b.statements().size()-1); + assert for_block_ instanceof Block : for_block_.getClass(); // FIXME: proper + // error + Block for_block = (Block) for_block_; - MultipleValues outer = processLoop(loop); + MultipleValues outer = processLoop(for_block); // System.out.println("outer loop: "+outer.var+" // "+outer.iterations); b = (Block_c) outer.body; Stmt last = b.statements().get(b.statements().size() - 1); //System.out.println(last); - assert last instanceof For; // FIXME: proper error - loop = (For) last; + assert last instanceof Block; // FIXME: proper error + Block for_block2 = (Block) last; SharedMem shm = new SharedMem(); // look at all but the last statement to find shm decls @@ -511,7 +559,7 @@ shm.addRail(ld, num_elements, rail_init_closure); } - MultipleValues inner = processLoop(loop); + MultipleValues inner = processLoop(for_block2); // System.out.println("outer loop: "+outer.var+" // "+outer.iterations); b = (Block_c) inner.body; Modified: trunk/x10.runtime/src-cpp/x10aux/network.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-06-04 18:00:21 UTC (rev 14427) +++ trunk/x10.runtime/src-cpp/x10aux/network.cc 2010-06-04 18:15:34 UTC (rev 14428) @@ -96,8 +96,22 @@ 0 /* terminator */ }; -void x10aux::blocks_threads (place p, msg_type t, int shm, int &bs, int &ts, const int *cfgs) +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_ubyte &bs, x10_ubyte &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_byte &bs, x10_byte &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_ushort &bs, x10_ushort &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_short &bs, x10_short &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_uint &bs, x10_uint &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_int &bs, x10_int &ts, const int *cfgs) { x10rt_blocks_threads(p,t,shm,&bs,&ts,cfgs); } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_ulong &bs, x10_ulong &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } +void x10aux::blocks_threads (place p, msg_type t, x10_int shm, x10_long &bs, x10_long &ts, const int *cfgs) +{ x10_int a,b; x10rt_blocks_threads(p,t,shm,&a,&b,cfgs); bs=a,ts=b; } Modified: trunk/x10.runtime/src-cpp/x10aux/network.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/network.h 2010-06-04 18:00:21 UTC (rev 14427) +++ trunk/x10.runtime/src-cpp/x10aux/network.h 2010-06-04 18:15:34 UTC (rev 14428) @@ -49,7 +49,14 @@ inline void event_probe (void) { x10rt_probe(); } extern const int cuda_cfgs[]; - void blocks_threads (place p, msg_type t, int shm, int &bs, int &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_ubyte &bs, x10_ubyte &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_byte &bs, x10_byte &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_ushort &bs, x10_ushort &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_short &bs, x10_short &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_uint &bs, x10_uint &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_int &bs, x10_int &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_ulong &bs, x10_ulong &ts, const int *cfgs=cuda_cfgs); + void blocks_threads (place p, msg_type t, int shm, x10_long &bs, x10_long &ts, const int *cfgs=cuda_cfgs); inline x10_ulong remote_alloc (place p, size_t sz) { Modified: trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-06-04 18:00:21 UTC (rev 14427) +++ trunk/x10.runtime/src-x10/x10/util/DistributedRail.x10 2010-06-04 18:15:34 UTC (rev 14428) @@ -20,6 +20,7 @@ public final class DistributedRail[T] implements Settable[Int,T], Iterable[T] { global val data : PlaceLocalHandle[Rail[T]]; global val firstPlace : Place; + // The HashMap should contain rails that are local to the hashmap itself but we cannot express this yet in X10 global val localRails = PlaceLocalHandle.make[HashMap[Activity, Rail[T]]](Dist.makeUnique(), ()=>new HashMap[Activity, Rail[T]]()); @@ -46,9 +47,9 @@ public static safe operator[S] (x:DistributedRail[S]) = x() as ValRail[S]; - public global safe def apply () { + public global safe def apply () : Rail[T]! { val a = Runtime.activity(); - val r:Rail[T] = localRails().getOrElse(a, null); + val r = localRails().getOrElse(a, null) as Rail[T]!; if (r==null) { val r_ = Rail.make[T](original_len, original); localRails().put(a, r_); Modified: trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 2010-06-04 18:00:21 UTC (rev 14427) +++ trunk/x10.runtime/src-x10/x10/util/OptionsParser.x10 2010-06-04 18:15:34 UTC (rev 14428) @@ -75,15 +75,88 @@ public def apply (key:String) = set.containsKey(key) || map.containsKey(key); public def apply (key:String, d:String) = map.getOrElse(key, d); + /* Uncomment on resolution of XTENLANG-1413 + public def apply (key:String, d:UByte) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return UByte.parseUByte(v); + } catch (e:NumberFormatException) { + throw new Err("Expected UByte, got: \""+v+"\""); + } + } + */ + public def apply (key:String, d:Byte) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return Byte.parseByte(v); + } catch (e:NumberFormatException) { + throw new Err("Expected Byte, got: \""+v+"\""); + } + } + /* Uncomment on resolution of XTENLANG-1413 + public def apply (key:String, d:UShort) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return UShort.parseUShort(v); + } catch (e:NumberFormatException) { + throw new Err("Expected UShort, got: \""+v+"\""); + } + } + */ + public def apply (key:String, d:Short) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return Short.parseShort(v); + } catch (e:NumberFormatException) { + throw new Err("Expected Short, got: \""+v+"\""); + } + } + /* Uncomment on resolution of XTENLANG-1413 + public def apply (key:String, d:UInt) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return UInt.parseUInt(v); + } catch (e:NumberFormatException) { + throw new Err("Expected UInt, got: \""+v+"\""); + } + } + */ public def apply (key:String, d:Int) throws Err { if (!map.containsKey(key)) return d; val v = map.getOrElse(key, "???"); try { return Int.parseInt(v); } catch (e:NumberFormatException) { + throw new Err("Expected Long, got: \""+v+"\""); + } + } + /* Uncomment on resolution of XTENLANG-1413 + public def apply (key:String, d:ULong) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return ULong.parseULong(v); + } catch (e:NumberFormatException) { + throw new Err("Expected ULong, got: \""+v+"\""); + } + } + */ + public def apply (key:String, d:Long) throws Err { + if (!map.containsKey(key)) return d; + val v = map.getOrElse(key, "???"); + try { + return Long.parseLong(v); + } catch (e:NumberFormatException) { throw new Err("Expected Int, got: \""+v+"\""); } } + + public def apply (key:String, d:Double) throws Err { if (!map.containsKey(key)) return d; val v = map.getOrElse(key, "???"); @@ -104,5 +177,4 @@ } } -// vim: shiftwidth=8:tabstop=8:expandtab - +// vim: shiftwidth=4:tabstop=4:expandtab This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-06-04 19:24:18
|
Revision: 14432 http://x10.svn.sourceforge.net/x10/?rev=14432&view=rev Author: sparksparkspark Date: 2010-06-04 19:24:12 +0000 (Fri, 04 Jun 2010) Log Message: ----------- Fix XTENLANG-1319 Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10/lang/String.cc trunk/x10.tests/examples/Misc/StringTest.x10 Modified: trunk/x10.runtime/src-cpp/x10/lang/String.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-06-04 19:23:11 UTC (rev 14431) +++ trunk/x10.runtime/src-cpp/x10/lang/String.cc 2010-06-04 19:24:12 UTC (rev 14432) @@ -56,22 +56,46 @@ return hc; } +static const char *strnstrn(const char *haystack, size_t haystack_sz, + const char *needle, size_t needle_sz) +{ + for (size_t i=0 ; i<haystack_sz ; ++i) { + for (size_t j=0 ; j<needle_sz ; ++j) { + if (haystack[i] != needle[j]) goto abandon; + } + return &haystack[i]; + abandon: {} + } + return NULL; +} + x10_int String::indexOf(ref<String> str, x10_int i) { nullCheck(str); const char *needle = str->FMGL(content); + size_t needle_sz = str->FMGL(content_length); // TODO: bounds check const char *haystack = &FMGL(content)[i]; - const char *pos = strstr(haystack, needle); + size_t haystack_sz = FMGL(content_length); + const char *pos = strnstrn(haystack, haystack_sz, needle, needle_sz); if (pos == NULL) return (x10_int) -1; return i + (x10_int) (pos - haystack); } +static const char *strnchr(const char *haystack, size_t haystack_sz, char needle) +{ + for (size_t i=0 ; i<haystack_sz ; ++i) { + if (haystack[i] == needle) return &haystack[i]; + } + return NULL; +} + x10_int String::indexOf(x10_char c, x10_int i) { int needle = (int)c.v; // TODO: bounds check const char *haystack = &FMGL(content)[i]; - const char *pos = strchr(haystack, needle); + size_t haystack_sz = FMGL(content_length); + const char *pos = strnchr(haystack, haystack_sz, needle); if (pos == NULL) return (x10_int) -1; return i + (x10_int) (pos - haystack); @@ -294,7 +318,7 @@ if (!x10aux::instanceof<ref<x10::lang::String> >(p0)) return false; ref<String> that = (ref<String>) p0; if (this->FMGL(content_length) != that->FMGL(content_length)) return false; // short-circuit trivial dis-equality - if (strcmp(this->FMGL(content), that->FMGL(content))) + if (strncmp(this->FMGL(content), that->FMGL(content), this->length())) return false; return true; } @@ -308,7 +332,7 @@ if (s.isNull()) return false; if (ref<String>(s).operator->() == this) return true; // short-circuit trivial equality if (this->FMGL(content_length) != s->FMGL(content_length)) return false; // short-circuit trivial dis-equality - if (strcasecmp(this->FMGL(content), s->FMGL(content))) + if (strncasecmp(this->FMGL(content), s->FMGL(content), this->length())) return false; return true; } @@ -357,7 +381,7 @@ int length_diff = this->FMGL(content_length) - s->FMGL(content_length); if (length_diff != 0) return length_diff; - return (x10_int) strcmp(this->FMGL(content), s->FMGL(content)); + return (x10_int) strncmp(this->FMGL(content), s->FMGL(content), this->length()); } /* FIXME: Unicode support */ @@ -367,7 +391,7 @@ int length_diff = this->FMGL(content_length) - s->FMGL(content_length); if (length_diff != 0) return length_diff; - return (x10_int) strcasecmp(this->FMGL(content), s->FMGL(content)); + return (x10_int) strncasecmp(this->FMGL(content), s->FMGL(content), this->length()); } const serialization_id_t String::_serialization_id = Modified: trunk/x10.tests/examples/Misc/StringTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/StringTest.x10 2010-06-04 19:23:11 UTC (rev 14431) +++ trunk/x10.tests/examples/Misc/StringTest.x10 2010-06-04 19:24:12 UTC (rev 14432) @@ -25,6 +25,13 @@ var foo: String = "the number is "+v; if (!(v == 10 && foo.equals("the number is "+"10"))) return false; if (foo.charAt(2) != 'e') return false; + + val start = "Start Twelve "; + chk(start.trim().equals("Start Twelve")); + val end = " Total Ten."; + chk(end.trim().equals("Total Ten.")); + val bothEnds = " Four "; + chk(bothEnds.trim().equals("Four")); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-06-05 21:25:01
|
Revision: 14449 http://x10.svn.sourceforge.net/x10/?rev=14449&view=rev Author: dgrove-oss Date: 2010-06-05 21:24:55 +0000 (Sat, 05 Jun 2010) Log Message: ----------- mirror the make ==> makeAligned change in Rail in ValRail so that the APIs are parallel. Fix test cases where change in Rail.make overloading caused type inference to not be able to correctly infer the type of the Rail being created. Modified Paths: -------------- trunk/x10.dist/samples/KMeansSPMD.x10 trunk/x10.runtime/src-cpp/x10/lang/ValRail.h trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 trunk/x10.tests/examples/Constructs/Rail/RailAlignment.x10 Modified: trunk/x10.dist/samples/KMeansSPMD.x10 =================================================================== --- trunk/x10.dist/samples/KMeansSPMD.x10 2010-06-05 20:42:13 UTC (rev 14448) +++ trunk/x10.dist/samples/KMeansSPMD.x10 2010-06-05 21:24:55 UTC (rev 14449) @@ -89,7 +89,7 @@ // these are pretty big so allocate up front val host_points = Rail.make(num_slice_points_stride*dim, init); - val host_nearest = Rail.make(num_slice_points, (Int)=>0); + val host_nearest = Rail.make(num_slice_points, 0); val host_clusters : Rail[Float]! = clusters(); val host_cluster_counts : Rail[Int]! = cluster_counts(); Modified: trunk/x10.runtime/src-cpp/x10/lang/ValRail.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-06-05 20:42:13 UTC (rev 14448) +++ trunk/x10.runtime/src-cpp/x10/lang/ValRail.h 2010-06-05 21:24:55 UTC (rev 14449) @@ -84,13 +84,23 @@ virtual x10aux::ref<x10::lang::String> toString(); - static x10aux::ref<ValRail<T> > make(x10_int length, x10_int alignment=8); + static x10aux::ref<ValRail<T> > make(x10_int length) { + return makeAligned(length, 8); + } + static x10aux::ref<ValRail<T> > makeAligned(x10_int length, x10_int alignment); static x10aux::ref<ValRail<T> > make(x10_int length, - x10aux::ref<Fun_0_1<x10_int,T> > init, - x10_int alignment=8); + x10aux::ref<Fun_0_1<x10_int,T> > init) { + return makeAligned(length, init, 8); + } + static x10aux::ref<ValRail<T> > makeAligned(x10_int length, + x10aux::ref<Fun_0_1<x10_int,T> > init, + x10_int alignment); - static x10aux::ref<ValRail<T> > make(x10aux::ref<Rail<T> > other, x10_int alignment=8); + static x10aux::ref<ValRail<T> > make(x10aux::ref<Rail<T> > other) { + return makeAligned(other, 8); + } + static x10aux::ref<ValRail<T> > makeAligned(x10aux::ref<Rail<T> > other, x10_int alignment); // All ValRails are mortal virtual x10_boolean _isMortal() { return true; } @@ -182,14 +192,14 @@ return true; } - template<class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length, x10_int alignment) { + template<class T> x10aux::ref<ValRail<T> > ValRail<T>::makeAligned(x10_int length, x10_int alignment) { x10aux::ref<ValRail<T> > rail = x10aux::alloc_aligned_rail<T,ValRail<T> >(length, alignment); // Memset both for efficiency and to allow T to be a struct. memset(rail->raw(), 0, length * sizeof(T)); return rail; } - template<class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10_int length, + template<class T> x10aux::ref<ValRail<T> > ValRail<T>::makeAligned(x10_int length, x10aux::ref<Fun_0_1<x10_int,T> > init, x10_int alignment) { x10aux::ref<ValRail<T> > rail = x10aux::alloc_aligned_rail<T,ValRail<T> >(length, alignment); @@ -201,7 +211,7 @@ return rail; } - template <class T> x10aux::ref<ValRail<T> > ValRail<T>::make(x10aux::ref<Rail<T> > other, x10_int alignment) { + template <class T> x10aux::ref<ValRail<T> > ValRail<T>::makeAligned(x10aux::ref<Rail<T> > other, x10_int alignment) { x10aux::nullCheck(other); x10_int length = other->FMGL(length); x10aux::ref<ValRail<T> > rail = x10aux::alloc_aligned_rail<T,ValRail<T> >(length, alignment); Modified: trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 2010-06-05 20:42:13 UTC (rev 14448) +++ trunk/x10.runtime/src-x10/x10/lang/ValRail.x10 2010-06-05 21:24:55 UTC (rev 14449) @@ -46,8 +46,8 @@ * @return The reference to the new ValRail. */ @Native("java", "x10.core.RailFactory.<#2>makeValRail(#3, #4, #5)") - @Native("c++", "x10::lang::ValRail<#1 >::make(#4, #5, #6)") - public native static def make[T](length: Int, init: (Int) => T, alignment: Int): ValRail[T](length)!; + @Native("c++", "x10::lang::ValRail<#1 >::makeAligned(#4, #5, #6)") + public native static def makeAligned[T](length: Int, init: (Int) => T, alignment: Int): ValRail[T](length)!; /** * Cast operator that creates a new ValRail from a Rail. Modified: trunk/x10.tests/examples/Constructs/Rail/RailAlignment.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Rail/RailAlignment.x10 2010-06-05 20:42:13 UTC (rev 14448) +++ trunk/x10.tests/examples/Constructs/Rail/RailAlignment.x10 2010-06-05 21:24:55 UTC (rev 14449) @@ -18,25 +18,25 @@ var failures:Int = 0; for ((i) in 0..999) { { - val r = Rail.make(555, (i:Int)=>0 as Float,16); + val r = Rail.makeAligned[float](555, (i:Int)=>0 as Float,16); if (!alignedTo(r, 16)) { failures++; } } { - val r = Rail.make(555, (i:Int)=>0 as Float,512); + val r = Rail.makeAligned[float](555, (i:Int)=>0 as Float,512); if (!alignedTo(r, 512)) { failures++; } } { - val r = ValRail.make(555, (i:Int)=>0 as Float,16); + val r = ValRail.makeAligned[float](555, (i:Int)=>0 as Float,16); if (!alignedTo(r, 16)) { failures++; } } { - val r = ValRail.make(555, (i:Int)=>0 as Float,512); + val r = ValRail.makeAligned[float](555, (i:Int)=>0 as Float,512); if (!alignedTo(r, 512)) { failures++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-06-06 23:16:15
|
Revision: 14453 http://x10.svn.sourceforge.net/x10/?rev=14453&view=rev Author: dgrove-oss Date: 2010-06-06 23:16:06 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Bump version numbers to 2.0.4; switch pgas.mk to pulling from 2.0.4 dir Modified Paths: -------------- trunk/x10.compiler/src/x10/Version.java trunk/x10.compiler/src/x10cpp/Version.java trunk/x10.runtime/x10rt/pgas/pgas.mk Modified: trunk/x10.compiler/src/x10/Version.java =================================================================== --- trunk/x10.compiler/src/x10/Version.java 2010-06-06 18:22:37 UTC (rev 14452) +++ trunk/x10.compiler/src/x10/Version.java 2010-06-06 23:16:06 UTC (rev 14453) @@ -19,5 +19,5 @@ public int major() { return 2; } public int minor() { return 0; } - public int patch_level() { return 3; } + public int patch_level() { return 4; } } Modified: trunk/x10.compiler/src/x10cpp/Version.java =================================================================== --- trunk/x10.compiler/src/x10cpp/Version.java 2010-06-06 18:22:37 UTC (rev 14452) +++ trunk/x10.compiler/src/x10cpp/Version.java 2010-06-06 23:16:06 UTC (rev 14453) @@ -19,5 +19,5 @@ public int major() { return 2; } public int minor() { return 0; } - public int patch_level() { return 3; } + public int patch_level() { return 4; } } Modified: trunk/x10.runtime/x10rt/pgas/pgas.mk =================================================================== --- trunk/x10.runtime/x10rt/pgas/pgas.mk 2010-06-06 18:22:37 UTC (rev 14452) +++ trunk/x10.runtime/x10rt/pgas/pgas.mk 2010-06-06 23:16:06 UTC (rev 14453) @@ -9,7 +9,7 @@ # (C) Copyright IBM Corporation 2006-2010. # -X10_VERSION=svn head +X10_VERSION=2.0.4 VERSION=20100508 SOCKETS_TGZ = pgas-$(VERSION)-$(WPLATFORM)-sockets.tgz LAPI_TGZ = pgas-$(VERSION)-$(WPLATFORM)-lapi.tgz This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-06 23:51:07
|
Revision: 14454 http://x10.svn.sourceforge.net/x10/?rev=14454&view=rev Author: yzibin Date: 2010-06-06 23:51:00 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Handled more issues in the test suite, and added an option to stop after type-checking (before doing optimizations or code generation). Modified Paths: -------------- trunk/x10.compiler/src/x10/Configuration.java trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/util/RunTestSuite.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10.aside trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10.aside trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_1.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_248.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_38.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_47.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_51.x10.aside trunk/x10.tests/examples/Issues/XTENLANG_60.x10.aside trunk/x10.tests/examples/Misc/BasicList.x10.aside trunk/x10.tests/examples/Misc/ListTest.x10.bug.aside trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 Removed Paths: ------------- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10 trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10 trunk/x10.tests/examples/Issues/XTENLANG_1.x10 trunk/x10.tests/examples/Issues/XTENLANG_248.x10 trunk/x10.tests/examples/Issues/XTENLANG_38.x10 trunk/x10.tests/examples/Issues/XTENLANG_47.x10 trunk/x10.tests/examples/Issues/XTENLANG_51.x10 trunk/x10.tests/examples/Issues/XTENLANG_60.x10 trunk/x10.tests/examples/Misc/BasicList.x10 trunk/x10.tests/examples/Misc/ListTest.x10 trunk/x10.tests/examples/Misc/RefA.x10 Modified: trunk/x10.compiler/src/x10/Configuration.java =================================================================== --- trunk/x10.compiler/src/x10/Configuration.java 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.compiler/src/x10/Configuration.java 2010-06-06 23:51:00 UTC (rev 14454) @@ -41,6 +41,10 @@ public static boolean CHECK_INVARIANTS = true; private static final String CHECK_INVARIANTS_desc = "Check AST invariants such as position containment, existance of xxxInstance(), etc"; + public static boolean ONLY_TYPE_CHECKING = false; + private static final String ONLY_TYPE_CHECKING_desc = "Do only type-checking, without optimizations or code generation"; + + public static boolean OPTIMIZE = false; private static final String OPTIMIZE_desc = "Generate optimized code"; Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-06 23:51:00 UTC (rev 14454) @@ -349,6 +349,10 @@ Goal typeCheckedGoal = TypeChecked(job); goals.add(typeCheckedGoal); + if (x10.Configuration.ONLY_TYPE_CHECKING) { + goals.add(End(job)); + } else { + goals.add(EnsureNoErrors(job)); goals.add(ReassembleAST(job)); @@ -404,6 +408,8 @@ CodeGenerated(job).addPrereq(goal); } + } + if (x10.Configuration.CHECK_INVARIANTS) { ArrayList<Goal> newGoals = new ArrayList<Goal>(goals.size()*2); boolean reachedTypeChecking = false; Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-06 23:51:00 UTC (rev 14454) @@ -11,6 +11,10 @@ }; private static final String[] EXCLUDE_FILES = { }; + private static final String[] EXCLUDE_FILES_WITH = { + "TypedefOverloading" + }; + static { Arrays.sort(EXCLUDE_FILES); } @@ -19,6 +23,9 @@ for (String suffix : EXCLUDE_FILES_WITH_SUFFIX) if (name.endsWith(suffix)) return true; + for (String mid : EXCLUDE_FILES_WITH) + if (name.contains(mid)) + return true; return false; } private static final int MAX_FILES_NUM = Integer.MAX_VALUE; // Change it if you want to process only a small number of files @@ -32,6 +39,7 @@ * C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests * @throws Throwable */ + public static boolean ONE_FILE_AT_A_TIME = false; public static void main(String[] args) throws Throwable { assert args.length>0 : "The first command line argument must be an x10 filename or the directory of x10.tests"; File dir = new File(args[0]); @@ -41,6 +49,18 @@ ArrayList<String> files = new ArrayList<String>(10); recurse(dir,files); assert files.size()>0 : "Didn't find any .x10 files to compile in any subdirectory of "+dir; + if (ONE_FILE_AT_A_TIME) { + for (String f : files) { + newArgs[0] = f; + // adding to -sourcepath + for (int i=1; i<newArgs.length; i++) + if (newArgs[i].contains("/x10.runtime/src-x10;")) + newArgs[i] += ";"+f.substring(0,f.lastIndexOf('/')); + System.out.println("Running: "+ Arrays.toString(newArgs)); + polyglot.main.Main.main(newArgs); + } + return; + } newArgs = new String[args.length-1+files.size()]; files.toArray(newArgs); System.arraycopy(args,1,newArgs,files.size(),args.length-1); Deleted: trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,46 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; -import x10.util.*; - -/** - * Inference for return types. - * - * @author bard 5/2010 - */ -public class TypeArgInference1 extends x10Test { - def choose[T] (a:T, b:T):T = a; - - public def run(): boolean = { - chk( Set[Int] <: Collection[Int], "pre-1"); - chk( List[Int] <: Collection[Int], "pre-2"); - chk( Sub <: Super, "pre-3"); - val intSet = new HashSet[Int](); - val stringList = new ArrayList[String](); - val x = choose(intSet, stringList); - val xx : Collection[Any] = x; - val intList = new ArrayList[Int](); - val y = choose(intSet, intList); - val yy : Collection[Int] = y; - return true; - } - - public static def main(var args: Rail[String]): void = { - new TypeArgInference1().execute(); - } - private static class Super {} - private static class Sub extends Super{} - -} - - - Copied: trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside (from rev 14398, trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,46 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; +import x10.util.*; + +/** + * Inference for return types. + * + * @author bard 5/2010 + */ +public class TypeArgInference1 extends x10Test { + def choose[T] (a:T, b:T):T = a; + + public def run(): boolean = { + chk( Set[Int] <: Collection[Int], "pre-1"); + chk( List[Int] <: Collection[Int], "pre-2"); + chk( Sub <: Super, "pre-3"); + val intSet = new HashSet[Int](); + val stringList = new ArrayList[String](); + val x = choose(intSet, stringList); + val xx : Collection[Any] = x; + val intList = new ArrayList[Int](); + val y = choose(intSet, intList); + val yy : Collection[Int] = y; + return true; + } + + public static def main(var args: Rail[String]): void = { + new TypeArgInference1().execute(); + } + private static class Super {} + private static class Sub extends Super{} + +} + + + Deleted: trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,40 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * The partition method of region is called, which should never - * be. Whether the run time error occurs or not depends on the number - * of places used (for instance, 3)and the value of k. - * - * @author Tong @date 10/31/06 - */ - -public class RegionDifference extends x10Test { - - // need fix for XTENLANG-51, or change test - - public def run(): boolean = { - val size: int = 10; - val k: int = 5; - val factor: int = 8; - val r: Region{rank==2} = [k..size-1, k..k]; - //x10.io.Console.OUT.println(([k:k+factor-1,k:k]-r).toString()); - val d: Dist = Dist.makeCyclic(([k..k+factor-1, k..k] as Region{rank==2})-r, 0); - - return true; - } - - public static def main(var args: Rail[String]): void = { - new RegionDifference().execute(); - } -} Copied: trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10.aside (from rev 14398, trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/Region/RegionDifference.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,40 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * The partition method of region is called, which should never + * be. Whether the run time error occurs or not depends on the number + * of places used (for instance, 3)and the value of k. + * + * @author Tong @date 10/31/06 + */ + +public class RegionDifference extends x10Test { + + // need fix for XTENLANG-51, or change test + + public def run(): boolean = { + val size: int = 10; + val k: int = 5; + val factor: int = 8; + val r: Region{rank==2} = [k..size-1, k..k]; + //x10.io.Console.OUT.println(([k:k+factor-1,k:k]-r).toString()); + val d: Dist = Dist.makeCyclic(([k..k+factor-1, k..k] as Region{rank==2})-r, 0); + + return true; + } + + public static def main(var args: Rail[String]): void = { + new RegionDifference().execute(); + } +} Deleted: trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,53 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -public class RegionWithHoles2 extends x10Test { - - public def run(): boolean = { - - // all of those are contiguous - var r: Region{rank==1} = [0..10]; - var r1: Region{rank==1} = [1..2]; - var r2: Region{rank==1} = [5..6]; - - // create holes in r - r = r - r1; - r = r - r2; - - x10.io.Console.OUT.println("r " + r); - x10.io.Console.OUT.println("r.boundingBox() " + r.boundingBox()); - - val a = new Array[short](r); - - // check if r is convex - it should not! - var cv: boolean = r.isConvex(); - x10.io.Console.OUT.println("convex: " + cv + " (should be false)"); - chk(!cv); - - x10.io.Console.OUT.print("indexes: "); - for (val (i): Point in r) { - x10.io.Console.OUT.print(i + " "); - } - - x10.io.Console.OUT.println(); - for (val (i): Point in r) { - x10.io.Console.OUT.println("val[" + i + "] = " + a(i)); - } - - return true; - } - - public static def main(var args: Rail[String]): void = { - new RegionWithHoles2().execute(); - } -} Copied: trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10.aside (from rev 14398, trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/Region/RegionWithHoles2.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,53 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +public class RegionWithHoles2 extends x10Test { + + public def run(): boolean = { + + // all of those are contiguous + var r: Region{rank==1} = [0..10]; + var r1: Region{rank==1} = [1..2]; + var r2: Region{rank==1} = [5..6]; + + // create holes in r + r = r - r1; + r = r - r2; + + x10.io.Console.OUT.println("r " + r); + x10.io.Console.OUT.println("r.boundingBox() " + r.boundingBox()); + + val a = new Array[short](r); + + // check if r is convex - it should not! + var cv: boolean = r.isConvex(); + x10.io.Console.OUT.println("convex: " + cv + " (should be false)"); + chk(!cv); + + x10.io.Console.OUT.print("indexes: "); + for (val (i): Point in r) { + x10.io.Console.OUT.print(i + " "); + } + + x10.io.Console.OUT.println(); + for (val (i): Point in r) { + x10.io.Console.OUT.println("val[" + i + "] = " + a(i)); + } + + return true; + } + + public static def main(var args: Rail[String]): void = { + new RegionWithHoles2().execute(); + } +} Deleted: trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,31 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * Check a local variable can have a has type. - * - * @author vj - */ -public class HasTypeClosure extends x10Test { - - def m(x:Int{self==1}) = x; - public def run(): boolean = { - val x = (y:Int)<: Int => y; - val z <:Int(1) = x(1); - return true; - } - - public static def main(Rail[String]) { - new HasTypeClosure().execute(); - } -} Copied: trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10.aside (from rev 14415, trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/Types/HasTypeClosure.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,31 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * Check a local variable can have a has type. + * + * @author vj + */ +public class HasTypeClosure extends x10Test { + + def m(x:Int{self==1}) = x; + public def run(): boolean = { + val x = (y:Int)<: Int => y; + val z <:Int(1) = x(1); + return true; + } + + public static def main(Rail[String]) { + new HasTypeClosure().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_1.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_1.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,40 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -class XTENLANG_1 extends x10Test { - - public class C[T] { - - private class It implements Iterator[T] { - incomplete public def hasNext(): boolean; - incomplete public def next(): T; - incomplete public def remove(): void; - } - - public def iterator(): Iterator[T] { - return new It(); - } - } - - public def run(): boolean { - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_1().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_1.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_1.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_1.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,40 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +class XTENLANG_1 extends x10Test { + + public class C[T] { + + private class It implements Iterator[T] { + incomplete public def hasNext(): boolean; + incomplete public def next(): T; + incomplete public def remove(): void; + } + + public def iterator(): Iterator[T] { + return new It(); + } + } + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_1().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_248.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_248.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_248.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,38 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 12/2008 - */ - -class XTENLANG_248 extends x10Test { - - public def run():boolean { - - val r = (0..2) - (1..1); - - x10.io.Console.OUT.println("r " + r); - x10.io.Console.OUT.println("rect " + r.rect); - - x10.io.Console.OUT.print("indexes: "); - for (val (i): Point in r) { - x10.io.Console.OUT.print(i + " "); - if (i==1) return false; - } - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_248().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_248.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_248.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_248.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_248.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,38 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 12/2008 + */ + +class XTENLANG_248 extends x10Test { + + public def run():boolean { + + val r = (0..2) - (1..1); + + x10.io.Console.OUT.println("r " + r); + x10.io.Console.OUT.println("rect " + r.rect); + + x10.io.Console.OUT.print("indexes: "); + for (val (i): Point in r) { + x10.io.Console.OUT.print(i + " "); + if (i==1) return false; + } + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_248().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_38.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_38.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_38.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,45 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -import x10.io.Printer; -import x10.io.StringWriter; -import x10.io.IOException; - -class XTENLANG_38 extends x10Test { - - public def run():boolean { - - val b = 'a' as byte; - - // the bug as originally reported was that this would output - // the string "97" instead of the byte "a", but that's not - // testable by our automated test scripts - //x10.io.Console.OUT.write(b); - - // however we can reproduce the same bug in a testable way - val os = new StringWriter(); - val ps = new Printer(os); - try { ps.write(b); } catch (e:IOException) {} - x10.io.Console.OUT.println("got " + os.toString()); - - return os.result().equals("a"); - } - - public static def main(Rail[String]) { - new XTENLANG_38().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_38.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_38.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_38.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_38.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,45 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +import x10.io.Printer; +import x10.io.StringWriter; +import x10.io.IOException; + +class XTENLANG_38 extends x10Test { + + public def run():boolean { + + val b = 'a' as byte; + + // the bug as originally reported was that this would output + // the string "97" instead of the byte "a", but that's not + // testable by our automated test scripts + //x10.io.Console.OUT.write(b); + + // however we can reproduce the same bug in a testable way + val os = new StringWriter(); + val ps = new Printer(os); + try { ps.write(b); } catch (e:IOException) {} + x10.io.Console.OUT.println("got " + os.toString()); + + return os.result().equals("a"); + } + + public static def main(Rail[String]) { + new XTENLANG_38().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_47.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_47.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_47.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,42 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -class XTENLANG_47 extends x10Test { - - class C(rank:int) { - def this(r:int) = property(r); - } - - class CL(rank2:int) { - - private class It implements Iterator[C{self.rank==rank2}] { - incomplete public def hasNext(): boolean; - incomplete public def next(): C{self.rank==rank2}; - incomplete public def remove(): void; - } - - def this(r:int) = property(r); - } - - public def run(): boolean { - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_47().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_47.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_47.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_47.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_47.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,42 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +class XTENLANG_47 extends x10Test { + + class C(rank:int) { + def this(r:int) = property(r); + } + + class CL(rank2:int) { + + private class It implements Iterator[C{self.rank==rank2}] { + incomplete public def hasNext(): boolean; + incomplete public def next(): C{self.rank==rank2}; + incomplete public def remove(): void; + } + + def this(r:int) = property(r); + } + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_47().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_51.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_51.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_51.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,51 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -class XTENLANG_51 extends x10Test { - - // standin for Region - static public class R { - incomplete public static operator (rs: ValRail[R!]): R!; - incomplete public operator this || (r:R!):R!; - } - - // standin for val r:Region = [a..b, c..d] - val r:R! = [new R(), new R()]; - - // this works as expected - val w = r || r; - - // this works - // standin for val z = r || [a..b, c..d] - val x = r || [new R(), new R()]; - - // this doesn't work - // standin for val w = [a..b, c..d] || r - val y = [new R(), new R()] || r; - - // this doesn't work - // standin for val y = [a..b, c..d] || [a..b, c..d] - val z = [new R(), new R()] || [new R(), new R()]; - - public def run(): boolean { - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_51().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_51.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_51.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_51.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_51.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,51 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +class XTENLANG_51 extends x10Test { + + // standin for Region + static public class R { + incomplete public static operator (rs: ValRail[R!]): R!; + incomplete public operator this || (r:R!):R!; + } + + // standin for val r:Region = [a..b, c..d] + val r:R! = [new R(), new R()]; + + // this works as expected + val w = r || r; + + // this works + // standin for val z = r || [a..b, c..d] + val x = r || [new R(), new R()]; + + // this doesn't work + // standin for val w = [a..b, c..d] || r + val y = [new R(), new R()] || r; + + // this doesn't work + // standin for val y = [a..b, c..d] || [a..b, c..d] + val z = [new R(), new R()] || [new R(), new R()]; + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_51().execute(); + } +} Deleted: trunk/x10.tests/examples/Issues/XTENLANG_60.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_60.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Issues/XTENLANG_60.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,33 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -/** - * @author bdlucas 10/2008 - */ - -class XTENLANG_60 extends x10Test { - - public class D implements (Point)=>Place, (Place)=>Region { - - incomplete public def apply(Point):Place; - incomplete public def apply(Place):Region; - } - - public def run(): boolean { - return true; - } - - public static def main(Rail[String]) { - new XTENLANG_60().execute(); - } -} Copied: trunk/x10.tests/examples/Issues/XTENLANG_60.x10.aside (from rev 14415, trunk/x10.tests/examples/Issues/XTENLANG_60.x10) =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_60.x10.aside (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_60.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,33 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +class XTENLANG_60 extends x10Test { + + public class D implements (Point)=>Place, (Place)=>Region { + + incomplete public def apply(Point):Place; + incomplete public def apply(Place):Region; + } + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_60().execute(); + } +} Deleted: trunk/x10.tests/examples/Misc/BasicList.x10 =================================================================== --- trunk/x10.tests/examples/Misc/BasicList.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Misc/BasicList.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,40 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -public class BasicList(n: int{self >=0}) { - - protected var value: Object; - protected var tail: BasicList; - - public def this(var o: Object, var t: BasicList): BasicList = { - property(t.n+1 as int{self>=0}); - tail = t; - value = o; - } - public def this(): BasicList = { - property(n as int{self>=0}); - } - public def a(l: BasicList): BasicList = { - return (n==0) ? l : new BasicList(value, tail.append(l)); - } - - public def append(var l: BasicList): BasicList = { - return n==0? (this as BasicList{n==0}).a(l) : (this as BasicList{n>0}).a(l); - } - - public def nth(var k: int{self >= 1 && self <= n}): Object = { - return k==1 ? value : tail.nth(k-1); - } - - public def gen(val k: int{self >= 0}): BasicList = { - return k==0 ? new BasicList() : new BasicList(k, gen(k-1)); - } -} Copied: trunk/x10.tests/examples/Misc/BasicList.x10.aside (from rev 14415, trunk/x10.tests/examples/Misc/BasicList.x10) =================================================================== --- trunk/x10.tests/examples/Misc/BasicList.x10.aside (rev 0) +++ trunk/x10.tests/examples/Misc/BasicList.x10.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,40 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +public class BasicList(n: int{self >=0}) { + + protected var value: Object; + protected var tail: BasicList; + + public def this(var o: Object, var t: BasicList): BasicList = { + property(t.n+1 as int{self>=0}); + tail = t; + value = o; + } + public def this(): BasicList = { + property(n as int{self>=0}); + } + public def a(l: BasicList): BasicList = { + return (n==0) ? l : new BasicList(value, tail.append(l)); + } + + public def append(var l: BasicList): BasicList = { + return n==0? (this as BasicList{n==0}).a(l) : (this as BasicList{n>0}).a(l); + } + + public def nth(var k: int{self >= 1 && self <= n}): Object = { + return k==1 ? value : tail.nth(k-1); + } + + public def gen(val k: int{self >= 0}): BasicList = { + return k==0 ? new BasicList() : new BasicList(k, gen(k-1)); + } +} Deleted: trunk/x10.tests/examples/Misc/ListTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/ListTest.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Misc/ListTest.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,72 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; -/** - * Simple test to check that List compiles and runs. -This produces an infinite loop for the type checker, on 06/25/06 -*/ - -public class ListTest extends x10Test { - public static class List { - public val n: int; - protected var value: Int; - protected var tail: List!; - - public def this(o: Int, t: List!) { - n=t.n+1; - tail = t; - value = o; - } - public def this() { - n=0; - value=0; - tail=null; - } - public def append(l: List!):List! = { - return (n==0)? l : new List(value, tail.append(l)); - // follow code successfully compiles - /* - if (n == 0) { - return l; - } else { - return new List(value, tail.append(l)); - } - */ - } - public def nth(k: int): Int = { - return k==1 ? value : tail.nth(k-1); - - } - - public def gen(k: int) = { - // following code successfully compiles if return type of gen(Int) is explicitly specified as List! - return k==0 ? new List() : new List(k, gen(k-1)); - // following code successfully compiles even the return type is not explicitly specified. - /* - if (k == 0) { - return new List(); - } else { - return new List(k, gen(k-1)); - } - */ - } - } - public def run(): boolean = { - a: List! = new List(1, new List(2, new List())); - b: Int = a.nth(2); - return b==2; - } - - public static def main(var args: Rail[String]): void = { - new ListTest().execute(); - } -} Copied: trunk/x10.tests/examples/Misc/ListTest.x10.bug.aside (from rev 14415, trunk/x10.tests/examples/Misc/ListTest.x10) =================================================================== --- trunk/x10.tests/examples/Misc/ListTest.x10.bug.aside (rev 0) +++ trunk/x10.tests/examples/Misc/ListTest.x10.bug.aside 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,81 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; +/** + * Simple test to check that List compiles and runs. +This produces an infinite loop for the type checker, on 06/25/06 + +Yoav reported bug: +C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Misc\ListTest.x10:35: Cannot return expression of type ListTest.List{self.home==here} from method public ListTest.List.append(l:ListTest.List{self.home==here}): ListTest.List{self.home==here}. +C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Misc\ListTest.x10:52: Constructor this(x10.lang.Int, ListTest.List{self.home==here}) + cannot be invoked with arguments + (x10.lang.Int{self==k}, x10.lang.Void). +C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests\examples\Misc\ListTest.x10:52: Constructor this(x10.lang.Int, ListTest.List{self.home==here}) + cannot be invoked with arguments + (x10.lang.Int{self==k}, x10.lang.Void). +*/ + +public class ListTest extends x10Test { + public static class List { + public val n: int; + protected var value: Int; + protected var tail: List!; + + public def this(o: Int, t: List!) { + n=t.n+1; + tail = t; + value = o; + } + public def this() { + n=0; + value=0; + tail=null; + } + public def append(l: List!):List! = { + return (n==0)? l : new List(value, tail.append(l)); + // follow code successfully compiles + /* + if (n == 0) { + return l; + } else { + return new List(value, tail.append(l)); + } + */ + } + public def nth(k: int): Int = { + return k==1 ? value : tail.nth(k-1); + + } + + public def gen(k: int) = { + // following code successfully compiles if return type of gen(Int) is explicitly specified as List! + return k==0 ? new List() : new List(k, gen(k-1)); + // following code successfully compiles even the return type is not explicitly specified. + /* + if (k == 0) { + return new List(); + } else { + return new List(k, gen(k-1)); + } + */ + } + } + public def run(): boolean = { + a: List! = new List(1, new List(2, new List())); + b: Int = a.nth(2); + return b==2; + } + + public static def main(var args: Rail[String]): void = { + new ListTest().execute(); + } +} Deleted: trunk/x10.tests/examples/Misc/RefA.x10 =================================================================== --- trunk/x10.tests/examples/Misc/RefA.x10 2010-06-06 23:16:06 UTC (rev 14453) +++ trunk/x10.tests/examples/Misc/RefA.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -1,26 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -public class RefA(f0: RefB{self.f2.f1==this.f1}, f1:int) extends x10Test { - public def this(f0_: RefB{self.f2.f1==f1}, f1_: int): RefA { - // should give an error the type of an arg to a constructor - // cannot reference this -- there is no this to refer to!! - property(f0_, f1_); - } - public def run(): boolean { - return true; - } - public static def main(var args: Rail[String]): void { - new RefA(null, 1).execute(); - } -} Copied: trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 (from rev 14415, trunk/x10.tests/examples/Misc/RefA.x10) =================================================================== --- trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 2010-06-06 23:51:00 UTC (rev 14454) @@ -0,0 +1,28 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +public class RefA(f0: RefB{self.f2.f1==this.f1}, f1:int) extends x10Test { + public def this(f0_: RefB{self.f2.f1==f1}, f1_: int): RefA { + // should give an error the type of an arg to a constructor + // cannot reference this -- there is no this to refer to!! + // And indeed it gives that error: + // \x10.tests\examples\Misc\RefA.x10:15: Cannot access a non-static field or method, or refer to "this" or "super" from a static context. + property(f0_, f1_); + } + public def run(): boolean { + return true; + } + public static def main(var args: Rail[String]): void { + new RefA(null, 1).execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-07 21:27:21
|
Revision: 14472 http://x10.svn.sourceforge.net/x10/?rev=14472&view=rev Author: yzibin Date: 2010-06-07 21:27:14 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Resolved XTENLANG_1367 Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.constraints/src/x10/constraint/XSubst.java trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG_1367.x10 Removed Paths: ------------- trunk/x10.tests/examples/Misc/RefB.x10 Modified: trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-06-07 21:27:14 UTC (rev 14472) @@ -77,8 +77,8 @@ */ @Override public void addDecls(Context c) { - super.addDecls(c); - + if (li!=null) // if we had errors in type checking, li might be null (e.g., "var x = ...") + super.addDecls(c); } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-06-07 21:27:14 UTC (rev 14472) @@ -2281,7 +2281,11 @@ - + private boolean isIn(Collection<FieldInstance> newFields, FieldInstance fi) { + for (FieldInstance fi2 : newFields) + if (fi.def()==fi2.def()) return true; + return false; + } public FieldInstance findField(Type container, TypeSystem_c.FieldMatcher matcher) throws SemanticException { @@ -2291,10 +2295,22 @@ Collection<FieldInstance> fields = findFields(container, matcher); if (fields.size() >= 2) { + // if the field is defined in a class, then it will appear only once in "fields". + // if it is defined in an interface (then it is either a "static val" or a property such as home), then it may appear multiple times in "fields", so we need to filter duplicates. + // e.g., +// interface I1 { static val a = 1;} +// interface I2 extends I1 {} +// interface I3 extends I1 {} +// interface I4 extends I2,I3 {} +// class Example implements I4 { +// def example() = a; +// def m(a:Example{self.home.home.home==here}) = 1; +// } Collection<FieldInstance> newFields = new HashSet<FieldInstance>(); for (FieldInstance fi : fields) { if ((fi.flags().isStatic())){ - newFields.add(fi); + if (!isIn(newFields,fi)) + newFields.add(fi); continue; } Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-07 21:27:14 UTC (rev 14472) @@ -41,14 +41,19 @@ */ public static boolean ONE_FILE_AT_A_TIME = false; public static void main(String[] args) throws Throwable { - assert args.length>0 : "The first command line argument must be an x10 filename or the directory of x10.tests"; - File dir = new File(args[0]); + assert args.length>0 : "The first command line argument must be an x10 filename or a comma separated list of the directories.\n"+ + "E.g.,\n"+ + "C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.tests,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.dist\\samples,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.runtime\\src-x10"; String[] newArgs = args; - if (!dir.getName().endsWith(".x10")) { - assert dir.isDirectory() : "The first command line argument must be the directory of x10.tests, and you passed: "+dir; + if (!args[0].endsWith(".x10")) { ArrayList<String> files = new ArrayList<String>(10); - recurse(dir,files); - assert files.size()>0 : "Didn't find any .x10 files to compile in any subdirectory of "+dir; + for (String dirStr : args[0].split(",")) { + File dir = new File(dirStr); + assert dir.isDirectory() : "The first command line argument must be the directory of x10.tests, and you passed: "+dir; + int before = files.size(); + recurse(dir,files); + assert before<files.size() : "Didn't find any .x10 files to compile in any subdirectory of "+dir; + } if (ONE_FILE_AT_A_TIME) { for (String f : files) { newArgs[0] = f; Modified: trunk/x10.constraints/src/x10/constraint/XSubst.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XSubst.java 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.constraints/src/x10/constraint/XSubst.java 2010-06-07 21:27:14 UTC (rev 14472) @@ -60,7 +60,6 @@ // System.out.print(""); } - private static int count = 0; @Override public XConstraint compute() { Modified: trunk/x10.dist/samples/NQueensPar.x10 =================================================================== --- trunk/x10.dist/samples/NQueensPar.x10 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.dist/samples/NQueensPar.x10 2010-06-07 21:27:14 UTC (rev 14472) @@ -64,22 +64,28 @@ /** Search for all solutions in parallel, on finding * a solution update nSolutions. */ - def search(R: Region(1)){at(NQueensPar.this)}{ + def search2(R: Region(1)){ for ((k) in R) if (safe(k)) new Board(q, k).search(); } - def search(){at(NQueensPar.this)} { + def search() { if (q.length == N) { atomic nSolutions++; return; } + if (q.length == 0) { val R = block(0..N-1, P); - foreach ((q) in 0..P-1) - search(R(q)); - } else search(0..N-1); + foreach ((q) in 0..P-1) { + // search(R(q)); + +val R3 = block(0..N-1, P); +search2(R3(0)); + } + + } else search2(0..N-1); } } Added: trunk/x10.tests/examples/Issues/XTENLANG_1367.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1367.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_1367.x10 2010-06-07 21:27:14 UTC (rev 14472) @@ -0,0 +1,33 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author bdlucas 10/2008 + */ + +public class XTENLANG_1367 extends x10Test { + public def run(): boolean { + return true; + } + public static def main(Rail[String]) { + new XTENLANG_1367().execute(); + } +} +interface I1 { static val a = 1;} +interface I2 extends I1 {} +interface I3 extends I1 {} +interface I4 extends I2,I3 {} +class Example implements I4 { + def example() = a; + def m(arg:Example{self.home.home.home==here}) = 1; +} Property changes on: trunk/x10.tests/examples/Issues/XTENLANG_1367.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.tests/examples/Misc/RefA_MustFailCompile.x10 2010-06-07 21:27:14 UTC (rev 14472) @@ -11,8 +11,8 @@ import harness.x10Test; -public class RefA(f0: RefB{self.f2.f1==this.f1}, f1:int) extends x10Test { - public def this(f0_: RefB{self.f2.f1==f1}, f1_: int): RefA { +public class RefA_MustFailCompile(f0: RefB{self.f2.f1==this.f1}, f1:int) extends x10Test { + public def this(f0_: RefB{self.f2.f1==f1}, f1_: int) { // should give an error the type of an arg to a constructor // cannot reference this -- there is no this to refer to!! // And indeed it gives that error: @@ -23,6 +23,13 @@ return true; } public static def main(var args: Rail[String]): void { - new RefA(null, 1).execute(); + new RefA_MustFailCompile(null, 1).execute(); } } +class RefB(f2: RefA_MustFailCompile) extends x10Test { + public def this(f2: RefA_MustFailCompile) { + property(f2); + } + + public def run(): boolean { return true;} +} \ No newline at end of file Deleted: trunk/x10.tests/examples/Misc/RefB.x10 =================================================================== --- trunk/x10.tests/examples/Misc/RefB.x10 2010-06-07 18:49:41 UTC (rev 14471) +++ trunk/x10.tests/examples/Misc/RefB.x10 2010-06-07 21:27:14 UTC (rev 14472) @@ -1,20 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; - -public class RefB(f2: RefA) extends x10Test { - public def this(f2: RefA) { - property(f2); - } - - public def run(): boolean { return true;} -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-08 21:11:02
|
Revision: 14496 http://x10.svn.sourceforge.net/x10/?rev=14496&view=rev Author: yzibin Date: 2010-06-08 21:10:56 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Changed the position of "apply" to COMPILER_GENERATED in expression such as "args(0)" Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.compiler/src/x10/visit/PositionInvariantChecker.java trunk/x10.dist/samples/NQueensPar.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 Removed Paths: ------------- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside Modified: trunk/x10.compiler/src/x10/ast/ClosureCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2010-06-08 19:22:59 UTC (rev 14495) +++ trunk/x10.compiler/src/x10/ast/ClosureCall_c.java 2010-06-08 21:10:56 UTC (rev 14496) @@ -297,7 +297,7 @@ // throw new SemanticException("Invalid closure call; target does not implement " + ct + ".", position()); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); X10Call_c n = (X10Call_c) nf.X10Call(position(), target(), - nf.Id(position(), mi.name().toString()), Collections.EMPTY_LIST, args); + nf.Id(Position.COMPILER_GENERATED, mi.name().toString()), Collections.EMPTY_LIST, args); n = (X10Call_c) n.methodInstance(mi).type(mi.returnType()); return n; } Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-08 19:22:59 UTC (rev 14495) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-08 21:10:56 UTC (rev 14496) @@ -12,7 +12,7 @@ private static final String[] EXCLUDE_FILES = { }; private static final String[] EXCLUDE_FILES_WITH = { - "TypedefOverloading" + "TypedefOverloading","NQueens" }; static { Modified: trunk/x10.compiler/src/x10/visit/PositionInvariantChecker.java =================================================================== --- trunk/x10.compiler/src/x10/visit/PositionInvariantChecker.java 2010-06-08 19:22:59 UTC (rev 14495) +++ trunk/x10.compiler/src/x10/visit/PositionInvariantChecker.java 2010-06-08 21:10:56 UTC (rev 14496) @@ -44,14 +44,13 @@ assert (n != null) : "Cannot visit null"; Position pPos = parent.position(); Position nPos = n.position(); - + assert ((pPos != null) && (nPos != null)) : "Positions must never be null"; if (nPos.isCompilerGenerated()) return; if (pPos.isCompilerGenerated()) { //assert (nPos.isCompilerGenerated()) : "If your parent is COMPILER_GENERATED, then you must be COMPILER_GENERATED"; // todo: take from some ancestor return; } - assert ((pPos != null) && (nPos != null)) : "Positions must never be null"; assert (equals(pPos.file(), nPos.file())) : "Positions must have the same file"; assert (equals(pPos.path(), nPos.path())) : "Positions must have the same path"; Modified: trunk/x10.dist/samples/NQueensPar.x10 =================================================================== --- trunk/x10.dist/samples/NQueensPar.x10 2010-06-08 19:22:59 UTC (rev 14495) +++ trunk/x10.dist/samples/NQueensPar.x10 2010-06-08 21:10:56 UTC (rev 14496) @@ -64,28 +64,22 @@ /** Search for all solutions in parallel, on finding * a solution update nSolutions. */ - def search2(R: Region(1)){ + def search(R: Region(1)){at(NQueensPar.this)}{ for ((k) in R) if (safe(k)) new Board(q, k).search(); } - def search() { + def search(){at(NQueensPar.this)} { if (q.length == N) { atomic nSolutions++; return; } - if (q.length == 0) { val R = block(0..N-1, P); - foreach ((q) in 0..P-1) { - // search(R(q)); - -val R3 = block(0..N-1, P); -search2(R3(0)); - } - - } else search2(0..N-1); + foreach ((q) in 0..P-1) + search(R(q)); + } else search(0..N-1); } } Copied: trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 (from rev 14471, trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside) =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10 2010-06-08 21:10:56 UTC (rev 14496) @@ -0,0 +1,50 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * Inference for return types. + * + * @author bard 5/2010 + */ +public class TypeArgInference1 extends x10Test { + def choose[T] (a:T, b:T):T = a; + + public def run(): boolean = { + chk( HashSet[Int] <: Collection[Int], "pre-1"); + chk( ArrayList[Int] <: Collection[Int], "pre-2"); + chk( Sub <: Super, "pre-3"); + val intSet = new HashSet[Int](); + val stringList = new ArrayList[String](); + val x = choose[Collection[Any]](intSet, stringList); + val xx : Collection[Any] = x; + val intList = new ArrayList[Int](); + val y = choose[Collection[Int]](intSet, intList); + val yy : Collection[Int] = y; + return true; + } + + public static def main(var args: Rail[String]): void = { + new TypeArgInference1().execute(); + } + + private static interface Collection[+T] {} + private static class HashSet[+T] implements Collection[T] {} + private static class ArrayList[+T] implements Collection[T] {} + + private static class Super {} + private static class Sub extends Super{} + +} + + + Deleted: trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside =================================================================== --- trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside 2010-06-08 19:22:59 UTC (rev 14495) +++ trunk/x10.tests/examples/Constructs/Inference/TypeArgInference1.x10.aside 2010-06-08 21:10:56 UTC (rev 14496) @@ -1,46 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -import harness.x10Test; -import x10.util.*; - -/** - * Inference for return types. - * - * @author bard 5/2010 - */ -public class TypeArgInference1 extends x10Test { - def choose[T] (a:T, b:T):T = a; - - public def run(): boolean = { - chk( Set[Int] <: Collection[Int], "pre-1"); - chk( List[Int] <: Collection[Int], "pre-2"); - chk( Sub <: Super, "pre-3"); - val intSet = new HashSet[Int](); - val stringList = new ArrayList[String](); - val x = choose(intSet, stringList); - val xx : Collection[Any] = x; - val intList = new ArrayList[Int](); - val y = choose(intSet, intList); - val yy : Collection[Int] = y; - return true; - } - - public static def main(var args: Rail[String]): void = { - new TypeArgInference1().execute(); - } - private static class Super {} - private static class Sub extends Super{} - -} - - - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-06-09 00:46:59
|
Revision: 14500 http://x10.svn.sourceforge.net/x10/?rev=14500&view=rev Author: ipeshansky Date: 2010-06-09 00:46:52 +0000 (Wed, 09 Jun 2010) Log Message: ----------- XTENLANG-1416 WIP: None of the goals that precede TypeCheckBarrier are supposed to fail. If there were typechecking errors, the job's AST is marked as invalid. Add validity marker to X10Ext. Visitor goals that follow TypeCheckBarrier silently succeed on invalid ASTs. CodeGenerated fails on invalid ASTs. Move CheckNativeAnnotations to the semantic checks section of the schedule. Temporarily disable CheckNativeAnnotations (doesn't work before NativeClassVisitor). Add EnsureNoErrors to X10Doc's schedule to restore old behavior. Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/extension/X10Del_c.java trunk/x10.compiler/src/x10/extension/X10Ext.java trunk/x10.compiler/src/x10/extension/X10Ext_c.java trunk/x10.compiler/src/x10/visit/X10TypeChecker.java trunk/x10.compiler/src/x10cpp/ExtensionInfo.java trunk/x10.doc/src/x10doc/ExtensionInfo.java Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -31,12 +31,14 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; +import polyglot.ast.Node; import polyglot.ast.NodeFactory; import polyglot.frontend.AllBarrierGoal; import polyglot.frontend.BarrierGoal; import polyglot.frontend.Compiler; import polyglot.frontend.FileResource; import polyglot.frontend.FileSource; +import polyglot.frontend.ForgivingVisitorGoal; import polyglot.frontend.Globals; import polyglot.frontend.Goal; import polyglot.frontend.JLScheduler; @@ -59,9 +61,19 @@ import polyglot.util.ErrorQueue; import polyglot.util.InternalCompilerError; import polyglot.util.Position; +import polyglot.visit.ConformanceChecker; +import polyglot.visit.ConstructorCallChecker; import polyglot.visit.ContextVisitor; +import polyglot.visit.ExceptionChecker; +import polyglot.visit.ExitChecker; +import polyglot.visit.FwdReferenceChecker; +import polyglot.visit.InitChecker; +import polyglot.visit.NodeVisitor; import polyglot.visit.PruningVisitor; +import polyglot.visit.ReachChecker; +import polyglot.visit.Translator; import x10.ast.X10NodeFactory_c; +import x10.extension.X10Ext; import x10.optimizations.Optimizer; import x10.parser.X10Lexer; import x10.parser.X10Parser; @@ -353,7 +365,6 @@ goals.add(End(job)); } else { - goals.add(EnsureNoErrors(job)); goals.add(ReassembleAST(job)); goals.add(ConformanceChecked(job)); @@ -366,6 +377,8 @@ goals.add(ConstructorCallsChecked(job)); goals.add(ForwardReferencesChecked(job)); goals.add(PropertyAssignmentsChecked(job)); +// goals.add(CheckNativeAnnotations(job)); + goals.add(CheckASTForErrors(job)); // goals.add(TypeCheckBarrier()); goals.add(X10Casted(job)); @@ -377,7 +390,6 @@ goals.add(NativeClassVisitor(job)); goals.add(Serialized(job)); - goals.add(CheckNativeAnnotations(job)); if (x10.Configuration.WORK_STEALING) { Goal wsCodeGenGoal = WSCodeGenerator(job); @@ -476,7 +488,7 @@ return new BarrierGoal(name, commandLineJobs()) { @Override public Goal prereqForJob(Job job) { - return Serialized(job); + return CheckASTForErrors(job); } }.intern(this); } @@ -489,7 +501,7 @@ { return null; } - return Serialized(job); + return CheckASTForErrors(job); } }.intern(this); } @@ -524,6 +536,18 @@ } } + public Goal CheckASTForErrors(Job job) { + return new SourceGoal_c("CheckASTForErrors", job) { + public boolean runTask() { + if (job.reportedErrors()) { + Node ast = job.ast(); + job.ast(((X10Ext)ast.ext()).setSubtreeValid(false)); + } + return true; + } + }.intern(this); + } + public Goal Serialized(Job job) { Compiler compiler = job.extensionInfo().compiler(); X10TypeSystem ts = (X10TypeSystem) job.extensionInfo().typeSystem(); @@ -572,16 +596,29 @@ @Override public Goal InitializationsChecked(Job job) { - TypeSystem ts = job.extensionInfo().typeSystem(); - NodeFactory nf = job.extensionInfo().nodeFactory(); - return new VisitorGoal("InitializationsChecked", job, new X10InitChecker(job, ts, nf)).intern(this); + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("InitializationsChecked", job, new X10InitChecker(job, ts, nf)).intern(this); } + public static class ValidatingOutputGoal extends OutputGoal { + public ValidatingOutputGoal(Job job, Translator translator) { + super(job, translator); + } + public boolean runTask() { + Node ast = job().ast(); + if (ast != null && !((X10Ext)ast.ext()).subtreeValid()) { + return false; + } + return super.runTask(); + } + } + @Override public Goal CodeGenerated(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new OutputGoal(job, new X10Translator(job, ts, nf, extInfo.targetFactory())).intern(this); + return new ValidatingOutputGoal(job, new X10Translator(job, ts, nf, extInfo.targetFactory())).intern(this); } public Goal X10MLTypeChecked(Job job) { @@ -592,62 +629,112 @@ @Override public Goal TypeChecked(Job job) { - TypeSystem ts = job.extensionInfo().typeSystem(); - NodeFactory nf = job.extensionInfo().nodeFactory(); - return new VisitorGoal("TypeChecked", job, new X10TypeChecker(job, ts, nf, job.nodeMemo())).intern(this); + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("TypeChecked", job, new X10TypeChecker(job, ts, nf, job.nodeMemo())).intern(this); } - public Goal X10Casted(Job job) { + public Goal ConformanceChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ConformanceChecked", job, new ConformanceChecker(job, ts, nf)).intern(this); + } + + public Goal ReachabilityChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ReachChecked", job, new ReachChecker(job, ts, nf)).intern(this); + } + + public Goal ExceptionsChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ExceptionsChecked", job, new ExceptionChecker(job, ts, nf)).intern(this); + } + + public Goal ExitPathsChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ExitChecked", job, new ExitChecker(job, ts, nf)).intern(this); + } + + public Goal ConstructorCallsChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ContructorCallsChecked", job, new ConstructorCallChecker(job, ts, nf)).intern(this); + } + + public Goal ForwardReferencesChecked(Job job) { + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); + return new ForgivingVisitorGoal("ForwardRefsChecked", job, new FwdReferenceChecker(job, ts, nf)).intern(this); + } + + public Goal PropertyAssignmentsChecked(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10Casted", job, new X10Caster(job, ts, nf)).intern(this); + return new ForgivingVisitorGoal("PropertyAssignmentsChecked", job, new AssignPropertyChecker(job, ts, nf)).intern(this); } - public Goal MoveFieldInitializers(Job job) { + public Goal CheckNativeAnnotations(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("MoveFieldInitializers", job, new FieldInitializerMover(job, ts, nf)).intern(this); + return new VisitorGoal("CheckNativeAnnotations", job, new CheckNativeAnnotationsVisitor(job, ts, nf, "java")).intern(this); } - public Goal X10RewriteExtern(Job job) { + public static class ValidatingVisitorGoal extends VisitorGoal { + public ValidatingVisitorGoal(String name, Job job, NodeVisitor v) { + super(name, job, v); + } + public boolean runTask() { + Node ast = job().ast(); + if (ast != null && !((X10Ext)ast.ext()).subtreeValid()) { + return true; + } + return super.runTask(); + } + } + + public Goal X10Casted(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10RewriteExtern", job, new RewriteExternVisitor(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("X10Casted", job, new X10Caster(job, ts, nf)).intern(this); } - public Goal X10RewriteAtomicMethods(Job job) { + + public Goal MoveFieldInitializers(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10RewriteAtomicMethods", job, new RewriteAtomicMethodVisitor(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("MoveFieldInitializers", job, new FieldInitializerMover(job, ts, nf)).intern(this); } - public Goal X10ExprFlattened(Job job) { + public Goal X10RewriteExtern(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10ExprFlattened", job, new ExprFlattener(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("X10RewriteExtern", job, new RewriteExternVisitor(job, ts, nf)).intern(this); } - public Goal PropertyAssignmentsChecked(Job job) { + public Goal X10RewriteAtomicMethods(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("PropertyAssignmentsChecked", job, new AssignPropertyChecker(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("X10RewriteAtomicMethods", job, new RewriteAtomicMethodVisitor(job, ts, nf)).intern(this); } - public Goal X10Expanded(Job job) { + public Goal X10ExprFlattened(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("X10Expanded", job, new X10ImplicitDeclarationExpander(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("X10ExprFlattened", job, new ExprFlattener(job, ts, nf)).intern(this); } - public Goal CheckNativeAnnotations(Job job) { + public Goal X10Expanded(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("CheckNativeAnnotations", job, new CheckNativeAnnotationsVisitor(job, ts, nf, "java")).intern(this); + return new ValidatingVisitorGoal("X10Expanded", job, new X10ImplicitDeclarationExpander(job, ts, nf)).intern(this); } public Goal NativeClassVisitor(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "java")).intern(this); + return new ValidatingVisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "java")).intern(this); } public Goal WSCodeGenerator(Job job) { @@ -665,7 +752,7 @@ TypeSystem.class, NodeFactory.class); ContextVisitor wsvisitor = (ContextVisitor) con.newInstance(job, ts, nf); - result = new VisitorGoal("WSCodeGenerator", job, wsvisitor).intern(this); + result = new ValidatingVisitorGoal("WSCodeGenerator", job, wsvisitor).intern(this); } catch (ClassNotFoundException e) { System.err.println("[X10_WS_ERR]Cannot load Work-Stealing code gen class. Ignore Work-Stealing transform."); @@ -679,18 +766,19 @@ public Goal Desugarer(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("Desugarer", job, new Desugarer(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("Desugarer", job, new Desugarer(job, ts, nf)).intern(this); } public Goal InnerClassRemover(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("InnerClassRemover", job, new X10InnerClassRemover(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("InnerClassRemover", job, new X10InnerClassRemover(job, ts, nf)).intern(this); } + public Goal StaticNestedClassRemover(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new VisitorGoal("StaticNestedClassRemover", job, new StaticNestedClassRemover(job, ts, nf)).intern(this); + return new ValidatingVisitorGoal("StaticNestedClassRemover", job, new StaticNestedClassRemover(job, ts, nf)).intern(this); } } Modified: trunk/x10.compiler/src/x10/extension/X10Del_c.java =================================================================== --- trunk/x10.compiler/src/x10/extension/X10Del_c.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10/extension/X10Del_c.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -88,6 +88,20 @@ return ((X10Ext) node().ext()).annotations(annotations); } + /* (non-Javadoc) + * @see x10.extension.X10Ext#subtreeValid(boolean) + */ + public boolean subtreeValid() { + return ((X10Ext) node().ext()).subtreeValid(); + } + + /* (non-Javadoc) + * @see x10.extension.X10Ext#setSubtreeValid(boolean) + */ + public Node setSubtreeValid(boolean val) { + return ((X10Ext) node().ext()).setSubtreeValid(val); + } + public static Node visitAnnotations(Node n, NodeVisitor v) { if (n.del() instanceof X10Del_c) { return ((X10Del_c) n.del()).visitAnnotations(v); Modified: trunk/x10.compiler/src/x10/extension/X10Ext.java =================================================================== --- trunk/x10.compiler/src/x10/extension/X10Ext.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10/extension/X10Ext.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -60,4 +60,17 @@ * @return */ public Node annotations(List<AnnotationNode> annotations); + + /** + * Are this node and all of its children valid? + * @return + */ + public boolean subtreeValid(); + + /** + * Set the validity status for this node and all of its children. + * @param val + * @return + */ + public Node setSubtreeValid(boolean val); } Modified: trunk/x10.compiler/src/x10/extension/X10Ext_c.java =================================================================== --- trunk/x10.compiler/src/x10/extension/X10Ext_c.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10/extension/X10Ext_c.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -29,6 +29,7 @@ public class X10Ext_c extends Ext_c implements X10Ext { String comment; List<AnnotationNode> annotations; + boolean subtreeValid = true; public String comment() { return this.comment; @@ -86,4 +87,19 @@ Node n = this.node(); return n.ext(this.extAnnotations(annotations)); } + + public boolean subtreeValid() { + return subtreeValid; + } + + public X10Ext subtreeValid(boolean val) { + X10Ext_c n = (X10Ext_c) copy(); + n.subtreeValid = val; + return n; + } + + public Node setSubtreeValid(boolean val) { + Node n = this.node(); + return n.ext(this.subtreeValid(val)); + } } Modified: trunk/x10.compiler/src/x10/visit/X10TypeChecker.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10TypeChecker.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10/visit/X10TypeChecker.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -23,79 +23,70 @@ */ public class X10TypeChecker extends TypeChecker { - Map<Node,Node> memo; + Map<Node,Node> memo; + /** * @param job * @param ts * @param nf * @param memo */ - public X10TypeChecker(Job job, TypeSystem ts, NodeFactory nf, - Map<Node, Node> memo) { - super(job, ts, nf, memo); - this.extensionInfo = (x10.ExtensionInfo) job.extensionInfo(); - this.memo = memo; + public X10TypeChecker(Job job, TypeSystem ts, NodeFactory nf, Map<Node, Node> memo) { + super(job, ts, nf, memo); + this.extensionInfo = (x10.ExtensionInfo) job.extensionInfo(); + this.memo = memo; } - x10.ExtensionInfo extensionInfo; + private x10.ExtensionInfo extensionInfo; - public Node override(Node parent, Node n) { - Node n_ = memo.get(n); - n_ = null; - if (n_ != null) { - this.addDecls(n_); - return n_; - } - - try { - if (Report.should_report(Report.visit, 2)) - Report.report(2, ">> " + this + "::override " + n); - - Node m = n.del().typeCheckOverride(parent, this); - - if (m != null) { - memo.put(n, m); - memo.put(m, m); - } - - return m; + public Node override(Node parent, Node n) { + Node n_ = memo.get(n); + n_ = null; + if (n_ != null) { + this.addDecls(n_); + return n_; + } + + try { + if (Report.should_report(Report.visit, 2)) + Report.report(2, ">> " + this + "::override " + n); + + Node m = n.del().typeCheckOverride(parent, this); + + if (m != null) { + memo.put(n, m); + memo.put(m, m); } - catch (SemanticException e) { - Errors.issue(job(), e); - - // IMPORTANT: Mark the goal as failed, otherwise we may run dependent goals - // that depend on this pass completing successfully. - if (goal() != null) - goal().fail(); - - return n; - } + + return m; } - protected NodeVisitor enterCall(Node n) throws SemanticException { - try { - return super.enterCall(n); - } catch (SemanticException z) { - boolean newp = extensionInfo.errorSet().add(z); - if (newp) - throw z; - else throw new SemanticException(); - } - + catch (SemanticException e) { + Errors.issue(job(), e); + // continue, errors have been reported, maybe you will find more errors. + return n; } + } + + protected NodeVisitor enterCall(Node n) throws SemanticException { + try { + return super.enterCall(n); + } catch (SemanticException z) { + boolean newp = extensionInfo.errorSet().add(z); + if (newp) + throw z; + else throw new SemanticException(); + } + } - protected Node leaveCall(Node old, final Node n, NodeVisitor v) throws SemanticException { - try { - return super.leaveCall(old, n, v); - } catch (SemanticException z) { - boolean newp = extensionInfo.errorSet().add(z); - if (newp) - throw z; - - } - // continue, errors have been reported, maybe you will find more errors. - if (goal() != null) - goal().fail(); - return old; + protected Node leaveCall(Node old, final Node n, NodeVisitor v) throws SemanticException { + try { + return super.leaveCall(old, n, v); + } catch (SemanticException z) { + boolean newp = extensionInfo.errorSet().add(z); + if (newp) + throw z; } - + // continue, errors have been reported, maybe you will find more errors. + return old; + } } Modified: trunk/x10.compiler/src/x10cpp/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.compiler/src/x10cpp/ExtensionInfo.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -146,7 +146,7 @@ public Goal CodeGenerated(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - return new OutputGoal(job, new X10CPPTranslator(job, ts, nf, extInfo.targetFactory())).intern(this); + return new ValidatingOutputGoal(job, new X10CPPTranslator(job, ts, nf, extInfo.targetFactory())).intern(this); } @Override protected Goal PostCompiled() { Modified: trunk/x10.doc/src/x10doc/ExtensionInfo.java =================================================================== --- trunk/x10.doc/src/x10doc/ExtensionInfo.java 2010-06-08 23:34:52 UTC (rev 14499) +++ trunk/x10.doc/src/x10doc/ExtensionInfo.java 2010-06-09 00:46:52 UTC (rev 14500) @@ -54,6 +54,7 @@ goals.add(TypesInitializedForCommandLineBarrier()); goals.add(TypeChecked(job)); goals.add(ReassembleAST(job)); + goals.add(EnsureNoErrors(job)); goals.add(X10DocGenerated(job)); goals.add(End(job)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-06-11 18:38:02
|
Revision: 14557 http://x10.svn.sourceforge.net/x10/?rev=14557&view=rev Author: ipeshansky Date: 2010-06-11 18:37:55 +0000 (Fri, 11 Jun 2010) Log Message: ----------- Turn off serialization of type information in the compiler options, making -noserial the default for X10. Remove -disable CheckNativeAnnotations from the x10c and x10cpp launch configs -- that pass was disabled in the compiler. Change the x10cpp launch config to use -commandlineonly. Modified Paths: -------------- trunk/x10.compiler/src/x10/X10CompilerOptions.java trunk/x10.dist/.launchConfigs/x10c.launch trunk/x10.dist/.launchConfigs/x10cpp.launch trunk/x10.dist/bin/x10c.in Modified: trunk/x10.compiler/src/x10/X10CompilerOptions.java =================================================================== --- trunk/x10.compiler/src/x10/X10CompilerOptions.java 2010-06-11 18:33:18 UTC (rev 14556) +++ trunk/x10.compiler/src/x10/X10CompilerOptions.java 2010-06-11 18:37:55 UTC (rev 14557) @@ -23,6 +23,7 @@ public X10CompilerOptions(ExtensionInfo extension) { super(extension); + serialize_type_info = false; // turn off type info serialization for X10 } protected int parseCommand(String args[], int index, Set source) Modified: trunk/x10.dist/.launchConfigs/x10c.launch =================================================================== --- trunk/x10.dist/.launchConfigs/x10c.launch 2010-06-11 18:33:18 UTC (rev 14556) +++ trunk/x10.dist/.launchConfigs/x10c.launch 2010-06-11 18:37:55 UTC (rev 14557) @@ -12,7 +12,7 @@ <listEntry value="org.eclipse.debug.ui.launchGroup.run"/> </listAttribute> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="polyglot.main.Main"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10c.ExtensionInfo "${resource_loc}" -sourcepath "${workspace_loc:x10.runtime/src-x10}" -sourcepath "${workspace_loc:x10.dist}/lib/x10.jar" -sourcepath "${workspace_loc:x10.tests}/examples/x10lib" -noserial -assert -post "java -jar ${workspace_loc:x10.dist/lib/ecj.jar} -source 1.5 -nowarn -classpath ${workspace_loc:x10.dist/lib/x10.jar}" -d out -disable CheckNativeAnnotations -commandlineonly"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10c.ExtensionInfo "${resource_loc}" -sourcepath "${workspace_loc:x10.runtime/src-x10}" -sourcepath "${workspace_loc:x10.dist}/lib/x10.jar" -sourcepath "${workspace_loc:x10.tests}/examples/x10lib" -assert -post "java -jar ${workspace_loc:x10.dist/lib/ecj.jar} -source 1.5 -nowarn -classpath ${workspace_loc:x10.dist/lib/x10.jar}" -d out -commandlineonly"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="x10.compiler"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${container_loc}"/> Modified: trunk/x10.dist/.launchConfigs/x10cpp.launch =================================================================== --- trunk/x10.dist/.launchConfigs/x10cpp.launch 2010-06-11 18:33:18 UTC (rev 14556) +++ trunk/x10.dist/.launchConfigs/x10cpp.launch 2010-06-11 18:37:55 UTC (rev 14557) @@ -17,7 +17,7 @@ <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> </listAttribute> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="polyglot.main.Main"/> -<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10cpp.ExtensionInfo ${resource_loc} -sourcepath ${project_loc:x10.runtime}/src-x10 -noserial -assert -d out -disable CheckNativeAnnotations ${project_loc:x10.tests}/examples/x10lib/harness/x10Test.x10"/> +<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-extclass x10cpp.ExtensionInfo ${resource_loc} -sourcepath ${project_loc:x10.runtime}/src-x10 -assert -d out ${project_loc:x10.tests}/examples/x10lib/harness/x10Test.x10 -commandlineonly"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="x10.compiler"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Xmx256m"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${container_loc}"/> Modified: trunk/x10.dist/bin/x10c.in =================================================================== --- trunk/x10.dist/bin/x10c.in 2010-06-11 18:33:18 UTC (rev 14556) +++ trunk/x10.dist/bin/x10c.in 2010-06-11 18:37:55 UTC (rev 14557) @@ -73,12 +73,6 @@ extargs="" # [DC] assert should be off by default # extargs="$extargs -assert" -# FIXME: HACK (at Vijay's request) -# FIXME: [DC] this is now a no-op? -# To be removed once serialization of types is fixed in x10c -# HACK!!! HACK!!! HACK!!! vvv -extargs="$extargs -noserial" -# HACK!!! HACK!!! HACK!!! ^^^ classpath="${CP_OVERRIDE}" [ -n "$dev" ] && classpath="${classpath}${TOP}${FILE_SEP}..${FILE_SEP}x10.compiler${FILE_SEP}classes${PATH_SEP}${TOP}${FILE_SEP}..${FILE_SEP}x10.runtime${FILE_SEP}classes${PATH_SEP}${TOP}${FILE_SEP}..${FILE_SEP}polyglot3-dev${FILE_SEP}bin${PATH_SEP}${TOP}${FILE_SEP}classes${PATH_SEP}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-12 18:52:12
|
Revision: 14570 http://x10.svn.sourceforge.net/x10/?rev=14570&view=rev Author: yzibin Date: 2010-06-12 18:52:05 +0000 (Sat, 12 Jun 2010) Log Message: ----------- Fixed XTENLANG-1314 and XTENLANG-1424, added a test case that checks many errors and their positions to the test suite, RunTestSuite now searches for markers ERR to check multiple errors and their positions. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Cast_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java trunk/x10.compiler/src/x10/ast/X10Field_c.java trunk/x10.compiler/src/x10/ast/X10Instanceof_c.java trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.tests/examples/Issues/XTENLANG_1380_MustFailCompile.x10 trunk/x10.tests/examples/Issues/XTENLANG_16_MustFailCompile.x10 trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/AmbDepTypeNode_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -122,26 +122,24 @@ public Node typeCheckOverride(Node parent, ContextVisitor tc) throws SemanticException { X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); X10NodeFactory nf = (X10NodeFactory) tc.nodeFactory(); - - AmbDepTypeNode_c n = this; - - LazyRef<Type> sym = (LazyRef<Type>) n.type; + + LazyRef<Type> sym = (LazyRef<Type>) this.type; assert sym != null; - TypeChecker childtc = (TypeChecker) tc.enter(parent, n); + TypeChecker childtc = (TypeChecker) tc.enter(parent, this); - TypeNode tn = (TypeNode) visitChild(n.base, childtc); + TypeNode tn = (TypeNode) visitChild(base, childtc); Type t = tn.type(); if (t instanceof UnknownType) { // Mark the type resolved to prevent us from trying to resolve this again and again. sym.update(ts.unknownType(position())); - return postprocess(nf.CanonicalTypeNode(position(), sym), n, childtc); + return postprocess(nf.CanonicalTypeNode(position(), sym), this, childtc); } - DepParameterExpr dep = (DepParameterExpr) n.visitChild(n.dep, childtc); + DepParameterExpr constr = (DepParameterExpr) visitChild(dep, childtc); - CConstraint c = Types.get(dep.valueConstraint()); + CConstraint c = Types.get(constr.valueConstraint()); t = X10TypeMixin.xclause(t, c); if (flags != null) { t = X10TypeMixin.processFlags(flags, t); @@ -150,8 +148,8 @@ sym.update(t); - CanonicalTypeNode result = nf.X10CanonicalTypeNode(position(), sym, dep); - return postprocess(result, n, childtc); + CanonicalTypeNode result = nf.X10CanonicalTypeNode(position(), sym, constr); + return postprocess(result, this, childtc); } static TypeNode postprocess(CanonicalTypeNode result, TypeNode n, ContextVisitor childtc) throws SemanticException { Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -467,13 +467,13 @@ } } - // We have a cc and a valid call with no target. The one with + // We have a cc and a valid call with no target. The one with //todo: fill in this comment if (cc instanceof ClosureCall) { ClosureCall call = (ClosureCall) cc; if (call.target() instanceof Local) { // cc is of the form r() where r is a local variable. // This overrides any other possibility for this call, e.g. a static or an instance method call. - X10TypeMixin.checkMissingParameters(cc.type()); + X10TypeMixin.checkMissingParameters(cc); Checker.checkOfferType(position(), call.closureInstance(), tc); return cc; @@ -518,7 +518,7 @@ if (cc != null) { Node result = cc.typeCheck(tc); if (result instanceof Expr) { - X10TypeMixin.checkMissingParameters(((Expr) result).type()); + X10TypeMixin.checkMissingParameters((Expr) result); } // Checker.checkOfferType(position(), call.closureInstance(), tc); return result; @@ -551,7 +551,7 @@ } if (n instanceof Expr) { - X10TypeMixin.checkMissingParameters(((Expr) n).type()); + X10TypeMixin.checkMissingParameters((Expr) n); } return n; } @@ -596,7 +596,7 @@ if (cc != null) { Node result = cc.typeCheck(tc); if (result instanceof Expr) { - X10TypeMixin.checkMissingParameters(((Expr) result).type()); + X10TypeMixin.checkMissingParameters((Expr) result); } return result; } @@ -646,7 +646,7 @@ // result = result.adjustMI(tc); // result.checkWhereClause(tc); result.checkAnnotations(tc); - X10TypeMixin.checkMissingParameters(result.type()); + X10TypeMixin.checkMissingParameters(result); Checker.checkOfferType(position(), (X10MethodInstance) result.methodInstance(), tc); return result; @@ -725,4 +725,3 @@ return sb.toString(); } } - Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -76,7 +76,7 @@ this.expr = d; } - DepParameterExpr expr; + private DepParameterExpr expr; // todo: remove me, this hack is ugly! The constraint expression should be generated from the type's constraint public DepParameterExpr constraintExpr() { return expr; @@ -226,15 +226,23 @@ if (t instanceof X10ClassType) { X10ClassType ct = (X10ClassType) t; - X10ClassDef def = ct.x10Def(); - if (ct.typeArguments().size() != def.typeParameters().size()) - throw new SemanticException("Invalid type; parameterized class " - + def.fullName() - + " instantiated with incorrect number of arguments.", position()); + X10ClassDef def = ct.x10Def(); + final List<Type> typeArgs = ct.typeArguments(); + final int typeArgNum = typeArgs.size(); + final List<ParameterType> typeParam = def.typeParameters(); - for (int j = 0; j < ct.typeArguments().size(); j++) { - Type actualType = ct.typeArguments().get(j); - ParameterType correspondingParam = def.typeParameters().get(j); + // I want to check that all generic classes have all the required type arguments, i.e., X10TypeMixin.checkMissingParameters(t, position()) + // E.g., that you always write: Array[...] and never Array. + // But that is not true for a static method, e.g., Array.make(...) + // so instead we do this check in all other places (e.g., field access, method definitions, new calls, etc) + // But I can check it if there are typeArguments. + if (typeArgNum>0) X10TypeMixin.checkMissingParameters(t,position()); + + for (int j = 0; j < typeArgNum; j++) { + Type actualType = typeArgs.get(j); + X10TypeMixin.checkMissingParameters(actualType,position()); + + ParameterType correspondingParam = typeParam.get(j); if (actualType.isVoid()) { throw new SemanticException("Cannot instantiate invariant parameter " + correspondingParam + " of " + def + " with type " + actualType + ".", position()); @@ -244,9 +252,9 @@ // A invariant parameter may not be instantiated on a covariant or contravariant parameter. // A contravariant parameter may not be instantiated on a covariant parameter. // A covariant parameter may not be instantiated on a contravariant parameter. - for (int j = 0; j < ct.typeArguments().size(); j++) { - Type actualType = ct.typeArguments().get(j); - ParameterType correspondingParam = def.typeParameters().get(j); + for (int j = 0; j < typeArgNum; j++) { + Type actualType = typeArgs.get(j); + ParameterType correspondingParam = typeParam.get(j); ParameterType.Variance correspondingVariance = def.variances().get(j); if (actualType instanceof ParameterType) { ParameterType pt = (ParameterType) actualType; Modified: trunk/x10.compiler/src/x10/ast/X10Cast_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10Cast_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -87,7 +87,7 @@ public Node typeCheck(ContextVisitor tc) throws SemanticException { if (castType()!= null) - X10TypeMixin.checkMissingParameters(castType().type()); + X10TypeMixin.checkMissingParameters(castType()); Expr e = Converter.converterChain(this, tc); assert e.type() != null; assert ! (e instanceof X10Cast_c) || ((X10Cast_c) e).convert != Converter.ConversionType.UNKNOWN_CONVERSION; Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -43,6 +43,7 @@ import polyglot.ast.Term; import polyglot.ast.TopLevelDecl; import polyglot.ast.TypeNode; +import polyglot.ast.CanonicalTypeNode; import polyglot.frontend.Globals; import polyglot.frontend.Job; import polyglot.frontend.Scheduler; @@ -1001,9 +1002,10 @@ return succs; } - protected ConstructorDecl createDefaultConstructor(ClassDef thisType, + protected ConstructorDecl createDefaultConstructor(ClassDef _thisType, TypeSystem ts, NodeFactory nf) throws SemanticException { + X10ClassDef thisType = (X10ClassDef) _thisType; Position pos = Position.COMPILER_GENERATED; //body().position().startOf(); X10NodeFactory xnf = (X10NodeFactory) nf; Block block = null; @@ -1018,9 +1020,7 @@ List<TypeParamNode> typeFormals = Collections.EMPTY_LIST; List<Formal> formals = Collections.EMPTY_LIST; DepParameterExpr guard = null; - TypeNode returnType = null; - - + if (! properties.isEmpty()) { // build type parameters. /* typeFormals = new ArrayList<TypeParamNode>(typeParameters.size()); @@ -1044,12 +1044,17 @@ guard = classInvariant(); s2 = xnf.AssignPropertyCall(pos, Collections.EMPTY_LIST, actuals); - // TODO: Check that this works. - returnType = xnf.CanonicalTypeNode(pos, thisType.asType()); + // TODO: add constraint on the return type } block = s2 == null ? (s1 == null ? nf.Block(pos) : nf.Block(pos, s1)) : (s1 == null ? nf.Block(pos, s2) : nf.Block(pos, s1, s2)); + X10ClassType resultType = (X10ClassType) thisType.asType(); + // for Generic classes + final List<ParameterType> typeParams = thisType.typeParameters(); + resultType = (X10ClassType)resultType.typeArguments((List)typeParams); + X10CanonicalTypeNode returnType = (X10CanonicalTypeNode) xnf.CanonicalTypeNode(pos, resultType); + ConstructorDecl cd = xnf.X10ConstructorDecl(pos, nf.FlagsNode(pos, Flags.PUBLIC), nf.Id(pos, "this"), Modified: trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10FieldDecl_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -363,14 +363,15 @@ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - Type type = this.type().type(); + final TypeNode typeNode = this.type(); + Type type = typeNode.type(); Type oldType = (Type)type.copy(); X10Context xc = (X10Context) enterChildScope(type(), tc.context()); X10Flags f = X10Flags.toX10Flags(flags.flags()); if (f.isGlobal() && ! f.isFinal()) { throw new Errors.GlobalFieldIsVar(this); } - X10TypeMixin.checkMissingParameters(type); + X10TypeMixin.checkMissingParameters(typeNode); // Need to replace here by current placeTerm in type, // since the field of this type can be referenced across @@ -379,7 +380,7 @@ type = PlaceChecker.ReplaceHereByPlaceTerm(type, xc); if (type.isVoid()) - throw new SemanticException("Field cannot have type " + this.type().type() + ".", position()); + throw new SemanticException("Field cannot have type " + typeNode.type() + ".", position()); if (X10TypeMixin.isProto(type)) { throw new SemanticException("Field cannot have type " Modified: trunk/x10.compiler/src/x10/ast/X10Field_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10Field_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -89,7 +89,7 @@ n = typeCheck1(tc); // Keep this at the very end. This is caught by // handle proto. - X10TypeMixin.checkMissingParameters(type()); + X10TypeMixin.checkMissingParameters(this); if (! ((X10Context) tc.context()).inAssignment()) { if (n instanceof X10Field_c) { Field nf = (Field) n; Modified: trunk/x10.compiler/src/x10/ast/X10Instanceof_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Instanceof_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10Instanceof_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -43,7 +43,8 @@ /** Type check the expression. */ public Node typeCheck(ContextVisitor tc) throws SemanticException { X10Instanceof_c n = (X10Instanceof_c) copy(); - Type toType = n.compareType().type(); + final TypeNode toTypeNode = n.compareType(); + Type toType = toTypeNode.type(); Type fromType = n.expr().type(); X10TypeSystem xts = (X10TypeSystem) tc.typeSystem(); @@ -52,7 +53,7 @@ throw new Errors.InstanceofError(fromType, toType, position()); } - X10TypeMixin.checkMissingParameters(toType); + X10TypeMixin.checkMissingParameters(toTypeNode); return n.type(xts.Boolean()); } Modified: trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10LocalDecl_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -196,11 +196,12 @@ */ @Override public Node typeCheck(ContextVisitor tc) throws SemanticException { - Type type = type().type(); + final TypeNode typeNode = type(); + Type type = typeNode.type(); - X10TypeMixin.checkMissingParameters(type); + X10TypeMixin.checkMissingParameters(typeNode); type = PlaceChecker.ReplaceHereByPlaceTerm(type, (X10Context) tc.context()); - Ref<Type> r = (Ref<Type>) type().typeRef(); + Ref<Type> r = (Ref<Type>) typeNode.typeRef(); r.update(type); if (type.isVoid()) @@ -215,7 +216,7 @@ throw new SemanticException(e.getMessage(), position()); } - X10LocalDecl_c n = (X10LocalDecl_c) this.type(tc.nodeFactory().CanonicalTypeNode(type().position(), type)); + X10LocalDecl_c n = (X10LocalDecl_c) this.type(tc.nodeFactory().CanonicalTypeNode(typeNode.position(), type)); // Need to check that the initializer is a subtype of the (declared or inferred) type of the variable, // or can be implicitly coerced to the type. Modified: trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/ast/X10MethodDecl_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -489,7 +489,7 @@ X10TypeMixin.protoTypeCheck(formals(), returnType().type(), position(), true); - X10TypeMixin.checkMissingParameters(n.returnType().type()); + X10TypeMixin.checkMissingParameters(n.returnType()); return n; } Modified: trunk/x10.compiler/src/x10/types/X10ClassDef_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/types/X10ClassDef_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -31,6 +31,7 @@ import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; +import polyglot.types.ClassType; import polyglot.util.FilteringList; import polyglot.util.Predicate; import polyglot.util.Transformation; Modified: trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/types/X10ParsedClassType_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -32,17 +32,13 @@ import polyglot.types.Type; import polyglot.types.TypeObject; import polyglot.types.TypeSystem; -import polyglot.types.Types; import polyglot.util.InternalCompilerError; import polyglot.util.Position; import polyglot.util.Transformation; import polyglot.util.TransformingList; import polyglot.util.TypedList; -import x10.ast.SemanticError; -import x10.constraint.XConstraint; import x10.constraint.XFailure; import x10.constraint.XVar; -import x10.constraint.XVar; import x10.types.constraints.CConstraint; import x10.types.matcher.Subst; @@ -61,8 +57,8 @@ public class X10ParsedClassType_c extends ParsedClassType_c implements X10ParsedClassType { - TypeParamSubst subst; - + TypeParamSubst cacheSubst; // "subst" is just an auxiliary structure (cached to improve performance). It represents the typeArguments (thus it is nullified when assigning to typeArguments). + public int hashCode() { return def.hashCode(); } @@ -101,19 +97,19 @@ public TypeParamSubst subst() { - if (subst == null) - subst = new TypeParamSubst((X10TypeSystem) ts, typeArguments, x10Def().typeParameters()); - return subst; + if (cacheSubst == null) + cacheSubst = new TypeParamSubst((X10TypeSystem) ts, typeArguments, x10Def().typeParameters()); + return cacheSubst; } public X10ParsedClassType_c(ClassDef def) { super(def); - subst = null; + cacheSubst = null; } public X10ParsedClassType_c(TypeSystem ts, Position pos, Ref<? extends ClassDef> def) { super(ts, pos, def); - subst = null; + cacheSubst = null; } public Type setFlags(Flags f) { @@ -322,7 +318,7 @@ } catch (XFailure z) { throw new InternalCompilerError(z.toString() + " for type " + this); } - n.subst = null; + n.cacheSubst = null; return n; } @@ -421,7 +417,7 @@ return thisVar; } - CConstraint xClause; + CConstraint xClause; //todo: is it mutated? it it used? public CConstraint getXClause() { if (xClause == null) { Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -1065,7 +1065,11 @@ return true; } - public static void checkMissingParameters(Type xt) throws SemanticException { + public static void checkMissingParameters(Receiver receiver) throws SemanticException { + Type xt = receiver.type(); + checkMissingParameters(xt,receiver.position()); + } + public static void checkMissingParameters(Type xt, Position pos) throws SemanticException { if (xt == null) return; xt = baseType(xt); @@ -1074,7 +1078,7 @@ if (xt1.subst() == null || xt1.subst().isMissingParameters()){ List<ParameterType> expectedArgs = ((X10ClassDef) xt1.def()).typeParameters(); - throw new Errors.TypeIsMissingParameters(xt, expectedArgs, xt.position()); + throw new Errors.TypeIsMissingParameters(xt, expectedArgs, pos); } } } Modified: trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -305,7 +305,6 @@ } TypeConstraint c = Types.get(ct.x10Def().typeBounds()); if (c != null) { - TypeParamSubst subst = ((X10ParsedClassType_c) ct).subst(); TypeConstraint equals = new TypeConstraint(); for (int i = 0; i < ct.typeArguments().size(); i++) { Type Y = ct.typeArguments().get(i); Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-12 18:52:05 UTC (rev 14570) @@ -1,13 +1,32 @@ package x10.util; +import polyglot.frontend.Globals; +import polyglot.util.ErrorQueue; +import polyglot.util.SilentErrorQueue; +import polyglot.util.Position; +import polyglot.util.ErrorInfo; +import polyglot.main.Report; +import polyglot.main.Main; + import java.io.File; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import java.util.HashSet; public class RunTestSuite { + + // todo: some _MustFailCompile in the test suite cause compiler crashes + + //_MustFailCompile means the compilation should fail. + // Inside those files we should have "ERR" markers that we use to test the position of the errors is correct. + //_MustFailTimeout means that when running the file it will have an infinite loop private static final String[] EXCLUDE_FILES_WITH_SUFFIX = { "_DYNAMIC_CALLS.x10", - "_MustFailCompile.x10", + }; private static final String[] EXCLUDE_FILES = { }; @@ -44,36 +63,112 @@ assert args.length>0 : "The first command line argument must be an x10 filename or a comma separated list of the directories.\n"+ "E.g.,\n"+ "C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.tests,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.dist\\samples,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.runtime\\src-x10"; - String[] newArgs = args; - if (!args[0].endsWith(".x10")) { - ArrayList<String> files = new ArrayList<String>(10); - for (String dirStr : args[0].split(",")) { + List<String> remainingArgs = new ArrayList<String>(Arrays.asList(args)); + remainingArgs.remove(0); + + final String dirName = args[0]; + ArrayList<File> files = new ArrayList<File>(10); + if (dirName.endsWith(".x10")) { + final File dir = new File(dirName); + assert dir.isFile() : "File doesn't not exists: "+dirName; + files.add(dir); + } else { + for (String dirStr : dirName.split(",")) { File dir = new File(dirStr); assert dir.isDirectory() : "The first command line argument must be the directory of x10.tests, and you passed: "+dir; int before = files.size(); recurse(dir,files); assert before<files.size() : "Didn't find any .x10 files to compile in any subdirectory of "+dir; } - if (ONE_FILE_AT_A_TIME) { - for (String f : files) { - newArgs[0] = f; - // adding to -sourcepath - for (int i=1; i<newArgs.length; i++) - if (newArgs[i].contains("/x10.runtime/src-x10;")) - newArgs[i] += ";"+f.substring(0,f.lastIndexOf('/')); - System.out.println("Running: "+ Arrays.toString(newArgs)); - polyglot.main.Main.main(newArgs); + } + if (ONE_FILE_AT_A_TIME) { + for (File f : files) { + compileFiles(Arrays.asList(f),remainingArgs); + } + } else { + compileFiles(files,remainingArgs); + } + } + private static void compileFiles(List<File> files, List<String> args) throws IOException { + // replace \ with / + ArrayList<String> fileNames = new ArrayList<String>(files.size()); + for (File f : files) + fileNames.add(f.getAbsolutePath().replace('\\','/')); + // adding the directories of the files to -sourcepath (in case they refer to other files that are not compiled, e.g., if we decide to compile the files one by one) + HashSet<String> directories = new HashSet<String>(); + for (String f : fileNames) { + final int index = f.lastIndexOf('/'); + assert index>0 : f; + directories.add(f.substring(0, index)); + } + String dirs = ""; + for (String dir : directories) + dirs += ";"+dir; + int argsNum = args.size(); + for (int i=1; i<argsNum; i++) { + final String arg = args.get(i); + if (arg.contains("/x10.runtime/src-x10;")) { + args.set(i,arg+dirs); + break; + } + } + // Now running polyglot + List<String> allArgs = new ArrayList<String>(fileNames); + allArgs.addAll(args); + String[] newArgs = allArgs.toArray(new String[allArgs.size()]); + System.out.println("Running: "+ allArgs); + SilentErrorQueue errQueue = new SilentErrorQueue(10000,"TestSuiteErrQueue"); + try { + new polyglot.main.Main().start(newArgs,errQueue); + } catch (Main.TerminationException e) { + // If we had errors (and we should because we compile _MustFailCompile) then we will get a non-zero exitCode + } + ArrayList<ErrorInfo> errors = (ArrayList<ErrorInfo>)errQueue.getErrors(); + + // Now checking the errors reported are correct and match ERR markers + // 1. find all ERR markers that don't have a corresponding error + for (File file : files) { + if (!file.getName().endsWith("_MustFailCompile.x10")) continue; + if (Report.should_report("TestSuite", 3)) + Report.report(3, "Looking for ERR markers in file "+ file); + BufferedReader in = new BufferedReader(new FileReader(file)); + int lineNum = 0; + boolean foundErr = false; + String line; + while ((line=in.readLine())!=null) { + lineNum++; + if (line.contains("ERR")) { + foundErr = true; + // try to find the matching error + boolean foundMatch = false; + for (ErrorInfo err : errors) { + final Position position = err.getPosition(); + if (new File(position.file()).equals(file) && position.line()==lineNum) { + // found it! + if (Report.should_report("TestSuite", 2)) + Report.report(2, "Found error: "+ err); + errors.remove(err); + foundMatch = true; + break; + } + } + if (!foundMatch) + System.err.println("File "+file+" has an ERR marker on line "+lineNum+", but the compiler didn't report an error on that line!"); } - return; } - newArgs = new String[args.length-1+files.size()]; - files.toArray(newArgs); - System.arraycopy(args,1,newArgs,files.size(),args.length-1); - } - System.out.println("Running: "+ Arrays.toString(newArgs)); - polyglot.main.Main.main(newArgs); + if (!foundErr) { + System.err.println("File "+file+" ends in _MustFailCompile.x10 but it doesn't contain any 'ERR' markers!"); + } + } + // 2. report all the remaining errors that didn't have a matching ERR marker + if (errors.size()>0) { + System.err.println("\nThe following errors did not have a matching ERR marker:\n\n"); + for (ErrorInfo err : errors) + System.err.println("Position: "+err.getPosition()+"\nMessage: "+err+"\n"); + } + // todo: check that for each file (without errors) we generated a *.class file, and load them and run their main method (except for the ones with _MustFailTimeout) } - private static void recurse(File dir, ArrayList<String> files) { + private static void recurse(File dir, ArrayList<File> files) { if (files.size()>=MAX_FILES_NUM) return; for (File f : dir.listFiles()) { if (files.size()>=MAX_FILES_NUM) return; @@ -82,7 +177,7 @@ else { String name = f.getName(); if (name.endsWith(".x10") && !shouldIgnoreFile(name)) { - files.add(f.getAbsolutePath().replace('\\','/')); + files.add(f); } } } Added: trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 2010-06-12 18:52:05 UTC (rev 14570) @@ -0,0 +1,114 @@ +public class Generics_ERR_MustFailCompile {} + +class Bla[T] extends Throwable + {T<: + Bla} // ERR - not caught! + { + var x1: + Bla; // ERR + var x2: + Bla[Int,Int]; // ERR - reported 2 errors in this line! + var x3: + Bla[Bla]; // ERR + var x4: + Bla[Bla[Bla]]; // ERR + var x5:Bla[Bla[Bla[Int]]]; + var x6:Bla[Int]{T<:Bla[Int]}; + var x7:Bla[Int]{T<: + Bla}; // ERR - not caught! + + static def m() {} + static def m2():Bla[Int] { + Bla.m(); + Bla[Int].m(); // ERR - now it is a parsing error! + val z1 = + new Bla(); // ERR - not caught! + val z2 = + new Bla[Bla](); // ERR + val z3 = + new Bla[Int[Int]](); // ERR + + val b1 = + null instanceof Bla[Int] + || null instanceof + Bla // ERR + || null instanceof + Bla[Bla]; // ERR + + val a1 = null as Bla[Int]; + val a2 = null as + Bla; // ERR + + val c1 = (x:Bla[Int], + y: + Bla, // ERR - not caught! + z:Bla[Bla[Int]]): + Bla // ERR + => null; + + return new Bla[Int](); + } + static def m3(x: + Bla, // ERR - not caught! + y:Bla[Int]): + Bla // ERR + = null; + + static def m4() throws + Bla // ERR + {} + def m5[U]() {U<:Bla[T]} {} + static def m6[U]() {U<: + Bla} // ERR + {} + + + static type BlaInt = Bla[Int]; + static type Bla2 = + Bla[Bla]; // ERR + static type Bla3 = + Bla; // ERR + static type Bla4(x: + Bla // ERR + ) = Int; + + static class S {} + var s1:S; + var s2:Bla.S = new Bla.S(); + + + // causes a syntax error! + var s3: + Bla[Int] // ERR + .S; + + + var s4:Bla.S = new + Bla[Int] // ERR + .S(); + var s5: + S[T]; // ERR + + class Inner {} + var i1:Inner = new Inner(); + var i2:Bla[T].Inner = new Inner(); + var i3:Bla[Int].Inner = new Bla[Int]().new Inner(); + var i4: + Bla.Inner; // ERR + var i5:Bla[T].Inner = + new Bla(). new Inner(); // ERR + var i6: + Inner[T]; // ERR + + class Inner2[U] {} + var j1:Inner2[Int] = new Inner2[Int](); + var j2:Bla[T].Inner2[T] = new Inner2[T](); + var j3:Bla[Int].Inner2[T] = new Bla[Int]().new Inner2[T](); + var j4: + Inner2; // ERR + var j5:Bla[T].Inner2[T] = + this.new Inner2(); // ERR + var j6:Inner2[T]; + var j7: + Inner2; // ERR +} \ No newline at end of file Property changes on: trunk/x10.tests/examples/Constructs/Generics/Generics_ERR_MustFailCompile.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Issues/XTENLANG_1380_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1380_MustFailCompile.x10 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.tests/examples/Issues/XTENLANG_1380_MustFailCompile.x10 2010-06-12 18:52:05 UTC (rev 14570) @@ -1,8 +1,13 @@ import harness.x10Test; public class XTENLANG_1380_MustFailCompile extends x10Test { - val a:Hello{self!=null} = new Hello(); - val b:Hello{self!=null} = (true ? null : a); // Does not report an error!!! - //val b:Hello{self!=null} = null; // Correctly reports an error + val a1:XTENLANG_1380_MustFailCompile{self!=null} = new XTENLANG_1380_MustFailCompile(); + val a2:XTENLANG_1380_MustFailCompile{self!=null} = (true ? null : a1); // ERR + val a3:XTENLANG_1380_MustFailCompile{self!=null} = null; // ERR + val a4:XTENLANG_1380_MustFailCompile{self!=null}; + var a5:XTENLANG_1380_MustFailCompile{self!=null}; // ERR + def this() { + a4 = new XTENLANG_1380_MustFailCompile(); + } public static def main(Rail[String]) { new XTENLANG_1380_MustFailCompile().execute(); Modified: trunk/x10.tests/examples/Issues/XTENLANG_16_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_16_MustFailCompile.x10 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.tests/examples/Issues/XTENLANG_16_MustFailCompile.x10 2010-06-12 18:52:05 UTC (rev 14570) @@ -18,7 +18,7 @@ class XTENLANG_16_MustFailCompile extends x10Test { public interface I[T] { - property rect: boolean = true; + property rect: boolean = true; // ERR } public def run(): boolean { Modified: trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 2010-06-12 01:59:00 UTC (rev 14569) +++ trunk/x10.tests/tests/Constructs/Proto/Cast_MustFailCompile.x10 2010-06-12 18:52:05 UTC (rev 14570) @@ -23,7 +23,8 @@ /** * Casts to proto types are not permitted. */ - def m(a: A): proto A = a as proto A; + def m(a: A): proto A = + a as proto A; // ERR public def run()=true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-15 21:19:44
|
Revision: 14592 http://x10.svn.sourceforge.net/x10/?rev=14592&view=rev Author: yzibin Date: 2010-06-15 21:19:38 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Added an immutable HashMap to XRX. Fixed bugs in x10.util collections (some bugs still remain there: XTENLANG-1452) Added ERR markers to some _MustFailCompile files Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.runtime/src-x10/x10/util/HashMap.x10 trunk/x10.runtime/src-x10/x10/util/Map.x10 trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Array/ArraySubtypeCheck_MustFailCompile.x10 trunk/x10.tests/examples/Constructs/Array/ArrayTypeCheck3_MustFailCompile.x10 Added Paths: ----------- trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 trunk/x10.runtime/src-x10/x10/util/ValMap.x10 trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10.aside Removed Paths: ------------- trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-15 21:19:38 UTC (rev 14592) @@ -363,9 +363,6 @@ Goal typeCheckedGoal = TypeChecked(job); goals.add(typeCheckedGoal); - if (x10.Configuration.ONLY_TYPE_CHECKING) { - goals.add(End(job)); - } else { goals.add(ReassembleAST(job)); @@ -383,6 +380,11 @@ goals.add(CheckASTForErrors(job)); // goals.add(TypeCheckBarrier()); + + if (x10.Configuration.ONLY_TYPE_CHECKING) { + goals.add(End(job)); + } else { + goals.add(X10Casted(job)); goals.add(MoveFieldInitializers(job)); goals.add(X10Expanded(job)); Modified: trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.compiler/src/x10/ast/X10CanonicalTypeNode_c.java 2010-06-15 21:19:38 UTC (rev 14592) @@ -230,6 +230,7 @@ final List<Type> typeArgs = ct.typeArguments(); final int typeArgNum = typeArgs.size(); final List<ParameterType> typeParam = def.typeParameters(); + final int typeParamNum = typeParam.size(); // I want to check that all generic classes have all the required type arguments, i.e., X10TypeMixin.checkMissingParameters(t, position()) // E.g., that you always write: Array[...] and never Array. @@ -237,8 +238,9 @@ // so instead we do this check in all other places (e.g., field access, method definitions, new calls, etc) // But I can check it if there are typeArguments. - // but this is wrong, cause by default we get typeArgs from our def: - // if (typeArgNum>0) X10TypeMixin.checkMissingParameters(t,position()); + // typeArgNum>0 is wrong, cause by default we get typeArgs from our def, so that condition is always true + // Instead I use: typeParamNum!=typeArgNum + if (typeParamNum!=typeArgNum) X10TypeMixin.checkMissingParameters(t,position()); for (int j = 0; j < typeArgNum; j++) { Type actualType = typeArgs.get(j); Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-15 21:19:38 UTC (rev 14592) @@ -27,14 +27,15 @@ //_MustFailTimeout means that when running the file it will have an infinite loop private static final String[] EXCLUDE_FILES_WITH_SUFFIX = { "_DYNAMIC_CALLS.x10", - "_MustFailCompile.x10", - }; private static final String[] EXCLUDE_FILES = { }; private static final String[] EXCLUDE_FILES_WITH = { "TypedefOverloading","NQueens" }; + private static final String[] INCLUDE_ONLY_FILES_WITH = { + //"_MustFailCompile.x10", + }; static { Arrays.sort(EXCLUDE_FILES); @@ -47,9 +48,16 @@ for (String mid : EXCLUDE_FILES_WITH) if (name.contains(mid)) return true; + if (INCLUDE_ONLY_FILES_WITH.length>0) { + for (String mid : INCLUDE_ONLY_FILES_WITH) + if (name.contains(mid)) + return false; + return true; + } return false; } - private static final int MAX_FILES_NUM = Integer.MAX_VALUE; // Change it if you want to process only a small number of files + public static boolean ONE_FILE_AT_A_TIME = false; + private static final int MAX_FILES_NUM = Integer.MAX_VALUE; // Change it if you want to process only a small number of files /** * Finds all *.x10 files in all sub-directories, and compiles them. @@ -60,13 +68,13 @@ * C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests * @throws Throwable */ - public static boolean ONE_FILE_AT_A_TIME = false; public static void main(String[] args) throws Throwable { assert args.length>0 : "The first command line argument must be an x10 filename or a comma separated list of the directories.\n"+ "E.g.,\n"+ "C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.tests,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.dist\\samples,C:\\cygwin\\home\\Yoav\\intellij\\sourceforge\\x10.runtime\\src-x10"; List<String> remainingArgs = new ArrayList<String>(Arrays.asList(args)); remainingArgs.remove(0); + remainingArgs.add("-STATIC_CALLS"); final String dirName = args[0]; ArrayList<File> files = new ArrayList<File>(10); Modified: trunk/x10.runtime/src-x10/x10/util/HashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.runtime/src-x10/x10/util/HashMap.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -11,8 +11,8 @@ package x10.util; -public class HashMap[-K,V] implements Map[K,V] { - static class HashEntry[-Key,Value] implements Map.Entry[Key,Value] { +public class HashMap[K,V] implements Map[K,V] { + static class HashEntry[Key,Value] implements Map.Entry[Key,Value] { public def getKey() = key; public def getValue() = value; public def setValue(v: Value) { value = v; } @@ -204,7 +204,7 @@ } public def keySet(): Set[K]! = new KeySet[K,V](this); - public def entries(): Set[Map.Entry[K,V]]! = new EntrySet[K,V](this); + public def entries(): Set[Map.Entry[K,V]!]! = new EntrySet[K,V](this); protected def entriesIterator(): Iterator[HashEntry[K,V]!]! { val iterator = new EntriesIterator[K,V](this); @@ -251,7 +251,7 @@ def this(map: HashMap[Key,Value]!) { this.map = map; } public def iterator(): Iterator[Key] { - return new MapIterator[HashEntry[Key,Value],Key](map.entriesIterator(), (e: HashEntry[Key,Value]!) => e.key); + return new MapIterator[HashEntry[Key,Value]!,Key](map.entriesIterator(), (e: HashEntry[Key,Value]!) => e.key); } public def contains(k: Key) { @@ -264,19 +264,19 @@ public def size(): Int = map.size(); } - protected static class EntrySet[-Key,Value] extends AbstractCollection[Map.Entry[Key,Value]] implements Set[Map.Entry[Key,Value]] { - val map: HashMap[Key,Value]!; + protected static class EntrySet[-Key,Value] extends AbstractCollection[Map.Entry[Key,Value]{self.at(here)}] implements Set[Map.Entry[Key,Value]{self.at(here)}] { + val map: HashMap[Key,Value]{self.at(here)}; - def this(map: HashMap[Key,Value]!) { this.map = map; } + def this(map: HashMap[Key,Value]{self.at(here)}) { this.map = map; } - public def iterator(): Iterator[Map.Entry[Key,Value]] { - return new MapIterator[HashEntry[Key,Value],Map.Entry[Key,Value]](map.entriesIterator(), (e: HashEntry[Key,Value]) => e as Map.Entry[Key,Value]); + public def iterator(): Iterator[Map.Entry[Key,Value]{self.at(here)}] { + return new MapIterator[HashEntry[Key,Value]{self.at(here)},Map.Entry[Key,Value]{self.at(here)}](map.entriesIterator(), (e: HashEntry[Key,Value]{self.at(here)}):Map.Entry[Key,Value]{self.at(here)} => e); } - public def contains(k: Map.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } - public def add(k: Map.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } - public def remove(k: Map.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } - public def clone(): EntrySet[Key,Value]! { throw new UnsupportedOperationException(); } + public def contains(k: Map.Entry[Key,Value]{self.at(here)}): Boolean { throw new UnsupportedOperationException(); } + public def add(k: Map.Entry[Key,Value]{self.at(here)}): Boolean { throw new UnsupportedOperationException(); } + public def remove(k: Map.Entry[Key,Value]{self.at(here)}): Boolean { throw new UnsupportedOperationException(); } + public def clone(): EntrySet[Key,Value]{self.at(here)} { throw new UnsupportedOperationException(); } public def size(): Int = map.size(); } } Modified: trunk/x10.runtime/src-x10/x10/util/Map.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/Map.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.runtime/src-x10/x10/util/Map.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -11,7 +11,7 @@ package x10.util; -public interface Map[-K,V] { +public interface Map[K,V] { public safe def containsKey(k: K): boolean; public safe def get(k: K): Box[V]; @@ -28,9 +28,9 @@ public def clear(): void; - public def entries(): Set[Entry[K,V]]; + public def entries(): Set[Entry[K,V]!]!; - public interface Entry[Key,Val] { + public static interface Entry[Key,Val] { public def getKey(): Key; public def getValue(): Val; public def setValue(Val): void; Modified: trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.runtime/src-x10/x10/util/MapIterator.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -12,10 +12,10 @@ package x10.util; public class MapIterator[-S,+T] implements Iterator[T] { - val i: Iterator[S!]!; - val f: (S!) => T; + val i: Iterator[S]!; + val f: (S) => T; - def this(i: Iterator[S!]!, f: (S!) => T) { + def this(i: Iterator[S]!, f: (S) => T) { this.i = i; this.f = f; } Added: trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -0,0 +1,179 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.util; + +public class ValHashMap[K,V] implements ValMap[K,V] { + public static def make[Key,Value](map:Map[Key,Value]!):ValHashMap[Key,Value] { + var hashMap:HashMap[Key,Value]! = new HashMap[Key,Value](); + val entries:Iterable[Map.Entry[Key,Value]!] = map.entries(); + for (val entry:Map.Entry[Key,Value]! in entries) + hashMap.put(entry.getKey(), entry.getValue()); + return make(hashMap); + } + public static def make[Key,Value](map:HashMap[Key,Value]!):ValHashMap[Key,Value] { + return new ValHashMap[Key,Value](map); + } + + static class HashEntry[Key,Value] implements ValMap.Entry[Key,Value] { + public global safe def getKey() = key; + public global safe def getValue() = value; + + global val key: Key; + global val value: Value; + global val hash:Int; + + def this(key: Key, value: Value) { + this.key = key; + this.value = value; + this.hash = hash(key); + } + } + + global val table: ValRail[HashEntry[K,V]!]!; + + private def this(map:HashMap[K,V]!) { + val t:Rail[HashMap.HashEntry[K,V]!]! = map.table; + table = ValRail.make[HashEntry[K,V]!](t.length, (index:Int)=> new HashEntry[K,V](t(index).getKey(), t(index).getValue()) ); + } + + protected static global safe def hash[T](k:T): Int { + return k.hashCode() * 17; + } + public global safe def apply(k: K): Box[V] = get(k); + public global safe def get(k: K): Box[V] { + val e = getEntry(k); + if (e == null) return null; + return e.value as Box[V]; + } + + public global safe def getOrElse(k: K, orelse: V): V { + val e = getEntry(k); + if (e == null) return orelse; + return e.value; + } + + public global safe def getOrThrow(k: K): V throws NoSuchElementException { + val e = getEntry(k); + if (e == null) throw new NoSuchElementException("Not found"); + return e.value; + } + protected global safe def getEntry(k: K): HashEntry[K,V] { + val size = table.length; + val mask = size - 1; + + if (size == 0) + return null; + + + val h = hash(k); + + var i: int = h; + + while (true) { + val j = i & mask; + i++; + + val e = table(j); + if (e == null) { + return null; + } + if (e != null) { + if (e.hash == h && k.equals(e.key)) { + return e; + } + if (i - h > table.length) { + return null; + } + } + } + } + + public global safe def containsKey(k: K): boolean { + val e = getEntry(k); + return e != null; + } + + public global safe def keySet(): Set[K]! = new KeySet[K,V](this); + public global safe def entries(): Set[ValMap.Entry[K,V]]! = new EntrySet[K,V](this); + public global safe def size() = table.length; + + protected global safe def entriesIterator(): Iterator[HashEntry[K,V]]! { + val iterator = new EntriesIterator[K,V](this); + iterator.advance(); + return iterator; + } + + protected static class EntriesIterator[Key,Value] implements Iterator[HashEntry[Key,Value]] { + val map: ValHashMap[Key,Value]; + var i: Int; + + def this(map: ValHashMap[Key,Value]) { this.map = map; this.i = 0; } + + def advance(): void { + while (i < map.table.length) { + if (map.table(i) != null) + return; + i++; + } + } + + public def hasNext(): Boolean { + if (i < map.table.length) { + return true; + } + return false; + } + + public def next(): HashEntry[Key,Value] { + val j = i; + i++; + advance(); + return map.table(j) ; + } + } + + + protected static class KeySet[Key,Value] extends AbstractCollection[Key] implements Set[Key] { + val map: ValHashMap[Key,Value]; + + def this(map: ValHashMap[Key,Value]) { this.map = map; } + + public def iterator(): Iterator[Key] { + return new MapIterator[HashEntry[Key,Value],Key](map.entriesIterator(), (e: HashEntry[Key,Value]) => e.key); + } + + public def contains(k: Key) { + return map.containsKey(k); + } + + public def add(k: Key): Boolean { throw new UnsupportedOperationException(); } + public def remove(k: Key): Boolean { throw new UnsupportedOperationException(); } + public def clone(): KeySet[Key,Value]! { throw new UnsupportedOperationException(); } + public def size(): Int = map.size(); + } + + protected static class EntrySet[Key,Value] extends AbstractCollection[ValMap.Entry[Key,Value]] implements Set[ValMap.Entry[Key,Value]] { + val map: ValHashMap[Key,Value]; + + def this(map: ValHashMap[Key,Value]) { this.map = map; } + + public def iterator(): Iterator[ValMap.Entry[Key,Value]] { + return new MapIterator[HashEntry[Key,Value],ValMap.Entry[Key,Value]](map.entriesIterator(), (e: HashEntry[Key,Value]):ValMap.Entry[Key,Value] => e); + } + + public def contains(k: ValMap.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } + public def add(k: ValMap.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } + public def remove(k: ValMap.Entry[Key,Value]): Boolean { throw new UnsupportedOperationException(); } + public def clone(): EntrySet[Key,Value]! { throw new UnsupportedOperationException(); } + public def size(): Int = map.size(); + } +} Property changes on: trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Added: trunk/x10.runtime/src-x10/x10/util/ValMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/ValMap.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/util/ValMap.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -0,0 +1,27 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +package x10.util; + +public interface ValMap[K,V] { + // All methods are global + public global safe def containsKey(k: K): boolean; + public global safe def get(k: K): Box[V]; + public global safe def getOrElse(k: K, orelse: V): V; + public global safe def getOrThrow(k: K): V throws NoSuchElementException; + public global safe def keySet(): Set[K]!; + public global safe def entries(): Set[Entry[K,V]]!; + + public static interface Entry[Key,Val] { + public global safe def getKey(): Key; + public global safe def getValue(): Val; + } +} Property changes on: trunk/x10.runtime/src-x10/x10/util/ValMap.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Deleted: trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -1,57 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -//OPTIONS: -PLUGINS=dims.plugin.DimensionTypePlugin - -import harness.x10Test; -import dims.*; - -public class DimTest3_MustFailCompile extends harness.x10Test { - public def run(): boolean = { - // This test case simulates the failure of the Mars Climate Orbiter. - -// The Mars Climate Orbiter's reaction wheels were kept within their linear -// (unsaturated) range through thruster firings in a procedure called Angular -// Momentum Desaturation (AMD). When an AMD event occurred, relevant spacecraft -// data was telemetered to the ground, processed, and placed into a file called -// the AMD file. The JPL operations navigation team used data derived from the -// AMD file to model the forces on the spacecraft resulting from these specific -// thruster firings. Modeling of these small forces is critical for accurately -// determining the spacecraft's trajectory. Immediately after the thruster -// firing, the velocity change ("delta-V") is computed using the firing time for -// each of the thrusters, and an impulse bit, which models each thruster's -// performance. The calculation of the thruster performance is carried out both -// on-board the spacecraft and on ground support computers. The flight software -// installed on the spacecraft correctly computed the velocity change and -// transmitted it to earth. The ground software, however, was originally written -// for the Mars Global Surveyor (MGS) mission, and the MGS flight software did -// not compute nor transmit velocity change information. The ground software, -// then, discarded the transmitted velocity change and recomputed it. Since the -// Mars Climate orbiter used a differently-sized thruster than Mars Global -// Surveyor, an update to the thruster equation in the ground software was -// necessary. The conversion factor from pound-seconds to newton-seconds was -// buried in the original equation and not immediately identifiable, and so it -// was not included in the updated equation. Thus, the ground software reported -// calculated "impulse bits" which were a factor of 4.45 too large (1 pound -// force = 4.45 newtons). Subsequent processing of the calculated impulse bit -// values from the AMD file by the navigation software underestimated the effect -// of the thruster firings on the spacecraft trajectory by this factor. - - var model: double = 1.0; - var actual: double = model; - var diff: double = (actual * 4.45) - model; - return -0.001 <= diff && diff <= 0.001; - } - - public static def main(var args: Rail[String]): void = { - new DimTest3_MustFailCompile().execute(); - } -} Copied: trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10.aside (from rev 14571, trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/Annotations/DimTest3_MustFailCompile.x10.aside 2010-06-15 21:19:38 UTC (rev 14592) @@ -0,0 +1,57 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +//OPTIONS: -PLUGINS=dims.plugin.DimensionTypePlugin + +import harness.x10Test; +import dims.*; + +public class DimTest3_MustFailCompile extends harness.x10Test { + public def run(): boolean = { + // This test case simulates the failure of the Mars Climate Orbiter. + +// The Mars Climate Orbiter's reaction wheels were kept within their linear +// (unsaturated) range through thruster firings in a procedure called Angular +// Momentum Desaturation (AMD). When an AMD event occurred, relevant spacecraft +// data was telemetered to the ground, processed, and placed into a file called +// the AMD file. The JPL operations navigation team used data derived from the +// AMD file to model the forces on the spacecraft resulting from these specific +// thruster firings. Modeling of these small forces is critical for accurately +// determining the spacecraft's trajectory. Immediately after the thruster +// firing, the velocity change ("delta-V") is computed using the firing time for +// each of the thrusters, and an impulse bit, which models each thruster's +// performance. The calculation of the thruster performance is carried out both +// on-board the spacecraft and on ground support computers. The flight software +// installed on the spacecraft correctly computed the velocity change and +// transmitted it to earth. The ground software, however, was originally written +// for the Mars Global Surveyor (MGS) mission, and the MGS flight software did +// not compute nor transmit velocity change information. The ground software, +// then, discarded the transmitted velocity change and recomputed it. Since the +// Mars Climate orbiter used a differently-sized thruster than Mars Global +// Surveyor, an update to the thruster equation in the ground software was +// necessary. The conversion factor from pound-seconds to newton-seconds was +// buried in the original equation and not immediately identifiable, and so it +// was not included in the updated equation. Thus, the ground software reported +// calculated "impulse bits" which were a factor of 4.45 too large (1 pound +// force = 4.45 newtons). Subsequent processing of the calculated impulse bit +// values from the AMD file by the navigation software underestimated the effect +// of the thruster firings on the spacecraft trajectory by this factor. + + var model: double@Unit(Force.newton) = 1.0; + var actual: double@Unit(Force.lbf) = model; + var diff: double = (actual * 4.45) - model; + return -0.001 <= diff && diff <= 0.001; + } + + public static def main(var args: Rail[String]): void = { + new DimTest3_MustFailCompile().execute(); + } +} Modified: trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.tests/examples/Constructs/Array/ArrayAccessWithMismatchingPointRank_MustFailCompile.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -26,7 +26,9 @@ val ia = new Array[int](e, (Point)=>0); // will infer ia:Array[int](1) val p = [1,1] as Point; // will infer p:Point(2) - a(ia(p)); // should fail at compile time because of mismatching rank. + val p1 = [1] as Point; + a(ia(p1)); // ok + a(ia(p)); // ERR should fail at compile time because of mismatching rank. return true; } Modified: trunk/x10.tests/examples/Constructs/Array/ArraySubtypeCheck_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArraySubtypeCheck_MustFailCompile.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.tests/examples/Constructs/Array/ArraySubtypeCheck_MustFailCompile.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -22,7 +22,7 @@ public def run(): boolean = { val R:Region = 0..3; var subarr00: Array[Sub] = new Array[Sub](R, (Point)=>null); - var suparr00: Array[Sup] = subarr00; + var suparr00: Array[Sup] = subarr00; // ERR return true; } Modified: trunk/x10.tests/examples/Constructs/Array/ArrayTypeCheck3_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayTypeCheck3_MustFailCompile.x10 2010-06-15 20:46:15 UTC (rev 14591) +++ trunk/x10.tests/examples/Constructs/Array/ArrayTypeCheck3_MustFailCompile.x10 2010-06-15 21:19:38 UTC (rev 14592) @@ -18,8 +18,8 @@ public class ArrayTypeCheck3_MustFailCompile extends x10Test { public def run(): boolean = { - val a1:Array[Int](3) = // should be Array[Int](2) - new Array[Int]([0..2, 0..3] as Region(2), (p(i): Point)=>i); + // should be Array[Int](2) + val a1:Array[Int](3) = new Array[Int]([0..2, 0..3] as Region(2), (p(i): Point)=>i); // ERR return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-17 20:07:17
|
Revision: 14618 http://x10.svn.sourceforge.net/x10/?rev=14618&view=rev Author: yzibin Date: 2010-06-17 20:07:11 +0000 (Thu, 17 Jun 2010) Log Message: ----------- fixed XTENLANG-1466 Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/constraints/CConstraint.java trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG-1466.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-06-17 19:21:12 UTC (rev 14617) +++ trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java 2010-06-17 20:07:11 UTC (rev 14618) @@ -1441,16 +1441,21 @@ if (type1.isNull() || type2.isNull()) { t = type1.isNull() ? type2 : type1; if (X10TypeMixin.permitsNull(t)) return t; - if (true) // todo: remove this - throw new SemanticException("No least common ancestor found for types \"" + type1 + - "\" and \"" + type2 + "\", because one is null and the other cannot contain null."); + // Maybe there is a constraint {self!=null} that we can remove from "t", and then null will be allowed. + // e.g., true ? null : new Test() + // T1: type(null) + // T2: Test{self.home==here, self!=null} + // The lub should be: Test{self.home==here} + CConstraint ct = X10TypeMixin.realX(t); - t = X10TypeMixin.baseType(t); - if (!X10TypeMixin.permitsNull(t)) + Type baseType = X10TypeMixin.baseType(t); + if (!X10TypeMixin.permitsNull(baseType)) throw new SemanticException("No least common ancestor found for types \"" + type1 + "\" and \"" + type2 + "\", because one is null and the other cannot contain null."); - // todo we need to keep all the constraints except the one that says the type is not null - return X10TypeMixin.addConstraint(t, ct); + // we need to keep all the constraints except the one that says the type is not null + final Type res = X10TypeMixin.addConstraint(baseType, X10TypeMixin.allowNull(ct)); + assert X10TypeMixin.permitsNull(res); + return res; } else { t = leastCommonAncestorBase(X10TypeMixin.baseType(type1), X10TypeMixin.baseType(type2)); Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-06-17 19:21:12 UTC (rev 14617) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-06-17 20:07:11 UTC (rev 14618) @@ -950,7 +950,29 @@ return t; } */ - + + /** + * Returns a new constraint that allows null. + * E.g., given "{self.home==here, self!=null}" it returns "{self.home==here}" + * @param c a constraint "c" that doesn't allow null + * @return a new constraint with all the constraints in "c" except {self!=null} + */ + public static CConstraint allowNull(CConstraint c) { + final XVar self = c.self(); + CConstraint res = new CConstraint(self); + assert !res.disEntails(self,XTerms.NULL); + for (XTerm term : c.constraints()) { + CConstraint copy = res.copy(); + try { + copy.addTerm(term); + } catch (XFailure xFailure) { + assert false : xFailure; + } + if (!copy.disEntails(self,XTerms.NULL)) + res = copy; + } + return res; + } public static boolean permitsNull(Type t) { if (isX10Struct(t)) return false; Modified: trunk/x10.compiler/src/x10/types/constraints/CConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/CConstraint.java 2010-06-17 19:21:12 UTC (rev 14617) +++ trunk/x10.compiler/src/x10/types/constraints/CConstraint.java 2010-06-17 20:07:11 UTC (rev 14618) @@ -63,8 +63,11 @@ /** * */ + public CConstraint(XVar self) { + this.self = self; + } public CConstraint() { - self = XTerms.makeUQV(SELF_VAR_PREFIX); + this(XTerms.makeUQV(SELF_VAR_PREFIX)); } /** Modified: trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 2010-06-17 19:21:12 UTC (rev 14617) +++ trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 2010-06-17 20:07:11 UTC (rev 14618) @@ -42,7 +42,7 @@ private def this(map:HashMap[K,V]!) { val t:Rail[HashMap.HashEntry[K,V]!]! = map.table; - table = = ValRail.make[HashEntry[K,V]!](t.length, (index:Int)=> { + table = ValRail.make[HashEntry[K,V]!](t.length, (index:Int)=> { val entry:HashMap.HashEntry[K,V]! = t(index); var res:HashEntry[K,V]! = null; if (entry!=null) res = new HashEntry[K,V](entry.getKey(), entry.getValue()); Added: trunk/x10.tests/examples/Issues/XTENLANG-1466.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG-1466.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG-1466.x10 2010-06-17 20:07:11 UTC (rev 14618) @@ -0,0 +1,28 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author yoav + */ + +public class XTENLANG_1466 extends x10Test { + + public def run(): boolean { + val f:Test! = true ? null : new Test(); + return f == null; + } + + public static def main(Rail[String]) { + new XTENLANG_1466().execute(); + } +} Property changes on: trunk/x10.tests/examples/Issues/XTENLANG-1466.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <al...@us...> - 2010-06-17 20:08:14
|
Revision: 14619 http://x10.svn.sourceforge.net/x10/?rev=14619&view=rev Author: alpern Date: 2010-06-17 20:08:07 +0000 (Thu, 17 Jun 2010) Log Message: ----------- Support for Expression Flattening (off by default) added. The FLATTEN_EXPRESSIONS command line flag turns it on. Some expressions (primarily constructors) are not yet flattened. Modified Paths: -------------- trunk/x10.compiler/src/x10/Configuration.java trunk/x10.compiler/src/x10/ExtensionInfo.java trunk/x10.compiler/src/x10/ast/StmtExpr.java trunk/x10.compiler/src/x10/ast/StmtExpr_c.java trunk/x10.compiler/src/x10/ast/StmtSeq.java trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java trunk/x10.compiler/src/x10/visit/Inliner.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-x10/x10/lang/Activity.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java Modified: trunk/x10.compiler/src/x10/Configuration.java =================================================================== --- trunk/x10.compiler/src/x10/Configuration.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/Configuration.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -64,11 +64,14 @@ private static final String ARRAY_OPTIMIZATIONS_desc = "Generate allocation of specialized Java array classes"; public static boolean INLINE_OPTIMIZATIONS = false; - private static final String INLINE_OPTIMIZATIONS_desc = "Perform inlining optimizations"; + private static final String INLINE_OPTIMIZATIONS_desc = "Perform inlining optimizations"; public static boolean CLOSURE_INLINING = true; private static final String CLOSURE_INLINING_desc = "Perform closure literal inlining"; + public static boolean FLATTEN_EXPRESSIONS = false; + private static final String FLATTEN_EXPRESSIONS_desc = "Flatten all expressions"; + public static String PLUGINS = ""; private static final String PLUGINS_desc = "Comma-separated list of compiler plugins to run."; Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -89,6 +89,7 @@ import x10.visit.CheckNativeAnnotationsVisitor; import x10.visit.Desugarer; import x10.visit.ExprFlattener; +import x10.visit.ExpressionFlattener; import x10.visit.FieldInitializerMover; import x10.visit.NativeClassVisitor; import x10.visit.RewriteAtomicMethodVisitor; @@ -113,12 +114,12 @@ // force Topics to load Topics t = new Topics(); } - + protected Map<QName,CompilerPlugin> plugins; public static final String XML_FILE_EXTENSION = "x10ml"; public static final String XML_FILE_DOT_EXTENSION = "." + XML_FILE_EXTENSION; - + public static String clock = "clock"; static { @@ -142,13 +143,13 @@ // // Replace the Flex/Cup parser with a JikesPG parser // - // public Parser parser(Reader reader, FileSource source, ErrorQueue eq) { + // public Parser parser(Reader reader, FileSource source, ErrorQueue eq) { // Lexer lexer = new Lexer_c(reader, source.name(), eq); // Grm grm = new Grm(lexer, ts, nf, eq); // return new CupParser(grm, source, eq); // } // - + public Parser parser(Reader reader, FileSource source, ErrorQueue eq) { // ### // if (source.path().endsWith(XML_FILE_DOT_EXTENSION)) { @@ -167,7 +168,7 @@ // we depend on Polyglot to provide us with a fully qualified // name for the file. In Version 1.3.0, source.name() yielded a // fully-qualied name. In 1.3.2, source.path() yields a fully- - // qualified name. If this assumption still holds then the + // qualified name. If this assumption still holds then the // first constructor will work. // The advantage of using the Reader constructor is that it // will always work, though not as efficiently. @@ -205,7 +206,7 @@ return true; return false; } - + static class WarningComparator implements Comparator<ErrorInfo> { public int compare(ErrorInfo a, ErrorInfo b) { Position pa = a.getPosition(); @@ -226,11 +227,11 @@ } } Set<ErrorInfo> warnings = new TreeSet<ErrorInfo>(new WarningComparator()); - + public Set<ErrorInfo> warningSet() { return warnings; } - + static class ExceptionComparator implements Comparator<SemanticException> { public int compare(SemanticException a, SemanticException b) { int r = (a.getClass().toString().compareToIgnoreCase(b.getClass().toString())); @@ -242,7 +243,7 @@ if (a.getMessage() == null && b.getMessage() == null) return 0; else if (a.getMessage() != null && a.getMessage().equals(b.getMessage())) - return 0; + return 0; } if (pa == null) return -1; @@ -260,19 +261,19 @@ } } Set<SemanticException> errors = new TreeSet<SemanticException>(new ExceptionComparator()); - + public Set<SemanticException> errorSet() { return errors; } - + private static int weakCallsCount = 0; - public void incrWeakCallsCount() { + public void incrWeakCallsCount() { weakCallsCount++; } public int weakCallsCount() { return weakCallsCount; } - + protected void initTypeSystem() { try { TopLevelResolver r = new X10SourceClassResolver(compiler, this, getOptions().constructFullClasspath(), @@ -338,7 +339,7 @@ protected Scheduler createScheduler() { return new X10Scheduler(this); } - + public static class X10Scheduler extends JLScheduler { public X10Scheduler(ExtensionInfo extInfo) { super(extInfo); @@ -354,13 +355,13 @@ if (job.source() != null && job.source().path().endsWith(XML_FILE_DOT_EXTENSION)) { goals.add(X10MLTypeChecked(job)); } - - // Do not include LoadPlugins in list. It would cause prereqs to be added + + // Do not include LoadPlugins in list. It would cause prereqs to be added // goals.add(LoadPlugins()); goals.add(PropagateAnnotations(job)); goals.add(LoadJobPlugins(job)); goals.add(RegisterPlugins(job)); - + goals.add(PreTypeCheck(job)); goals.add(TypesInitializedForCommandLineBarrier()); @@ -369,7 +370,7 @@ goals.add(ReassembleAST(job)); - + goals.add(ConformanceChecked(job)); // Data-flow analyses @@ -398,27 +399,29 @@ goals.add(NativeClassVisitor(job)); goals.add(Serialized(job)); - + if (x10.Configuration.WORK_STEALING) { Goal wsCodeGenGoal = WSCodeGenerator(job); - if (wsCodeGenGoal != null) { - goals.add(wsCodeGenGoal); + if(wsCodeGenGoal != null){ + goals.add(wsCodeGenGoal); wsCodeGenGoal.addPrereq(TypeCheckBarrier()); } } goals.add(InnerClassRemover(job)); + if (x10.Configuration.FLATTEN_EXPRESSIONS) { + goals.add(ExpressionFlattener(job)); + } goals.addAll(Optimizer.goals(this, job)); goals.add(Desugarer(job)); - goals.add(CodeGenerated(job)); goals.add(End(job)); - + InnerClassRemover(job).addPrereq(Serialized(job)); InnerClassRemover(job).addPrereq(TypeCheckBarrier()); // the barrier will handle prereqs on its own CodeGenerated(job).addPrereq(CodeGenBarrier()); - + Desugarer(job).addPrereq(TypeCheckBarrier()); CodeGenerated(job).addPrereq(Desugarer(job)); @@ -447,7 +450,7 @@ return goals; } - + Goal PrintWeakCallsCount; @Override protected Goal EndAll() { @@ -489,36 +492,36 @@ } } - + public Goal TypeCheckBarrier() { String name = "TypeCheckBarrier"; - if (Globals.Options().compile_command_line_only) { + if (Globals.Options().compile_command_line_only) { return new BarrierGoal(name, commandLineJobs()) { - @Override - public Goal prereqForJob(Job job) { + @Override + public Goal prereqForJob(Job job) { return CheckASTForErrors(job); - } + } }.intern(this); - } - else { + } + else { return new AllBarrierGoal(name, this) { - @Override - public Goal prereqForJob(Job job) { - if (!scheduler.commandLineJobs().contains(job) && - ((ExtensionInfo) extInfo).manifestContains(job.source().path())) - { - return null; - } + @Override + public Goal prereqForJob(Job job) { + if (!scheduler.commandLineJobs().contains(job) && + ((ExtensionInfo) extInfo).manifestContains(job.source().path())) + { + return null; + } return CheckASTForErrors(job); - } + } }.intern(this); - } + } } - + protected Goal codegenPrereq(Job job) { return InnerClassRemover(job); } - + public Goal CodeGenBarrier() { String name = "CodeGenBarrier"; if (Globals.Options().compile_command_line_only) { @@ -568,16 +571,17 @@ }.intern(this); } + // @Override // public Goal ImportTableInitialized(Job job) { -// TypeSystem ts = job.extensionInfo().typeSystem(); -// NodeFactory nf = job.extensionInfo().nodeFactory(); -// Goal g = new VisitorGoal("ImportTableInitialized", job, new X10InitImportsVisitor(job, ts, nf)); -// Goal g2 = g.intern(this); -// if (g == g2) { -// g.addPrereq(TypesInitializedForCommandLine()); -// } -// return g2; +// TypeSystem ts = job.extensionInfo().typeSystem(); +// NodeFactory nf = job.extensionInfo().nodeFactory(); +// Goal g = new VisitorGoal("ImportTableInitialized", job, new X10InitImportsVisitor(job, ts, nf)); +// Goal g2 = g.intern(this); +// if (g == g2) { +// g.addPrereq(TypesInitializedForCommandLine()); +// } +// return g2; // } public Goal LoadPlugins() { @@ -596,7 +600,7 @@ } return g2; } - + public Goal PropagateAnnotations(Job job) { // ### return new VisitorGoal("PropagateAnnotations", job, new PruningVisitor()).intern(this); @@ -604,8 +608,8 @@ @Override public Goal InitializationsChecked(Job job) { - TypeSystem ts = job.extensionInfo().typeSystem(); - NodeFactory nf = job.extensionInfo().nodeFactory(); + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); return new ForgivingVisitorGoal("InitializationsChecked", job, new X10InitChecker(job, ts, nf)).intern(this); } @@ -634,11 +638,11 @@ NodeFactory nf = extInfo.nodeFactory(); return new VisitorGoal("X10MLTypeChecked", job, new X10MLVerifier(job, ts, nf)).intern(this); } - + @Override public Goal TypeChecked(Job job) { - TypeSystem ts = job.extensionInfo().typeSystem(); - NodeFactory nf = job.extensionInfo().nodeFactory(); + TypeSystem ts = job.extensionInfo().typeSystem(); + NodeFactory nf = job.extensionInfo().nodeFactory(); return new ForgivingVisitorGoal("TypeChecked", job, new X10TypeChecker(job, ts, nf, job.nodeMemo())).intern(this); } @@ -714,7 +718,7 @@ NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("MoveFieldInitializers", job, new FieldInitializerMover(job, ts, nf)).intern(this); } - + public Goal X10RewriteExtern(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); @@ -726,31 +730,31 @@ NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("X10RewriteAtomicMethods", job, new RewriteAtomicMethodVisitor(job, ts, nf)).intern(this); } - + public Goal X10ExprFlattened(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("X10ExprFlattened", job, new ExprFlattener(job, ts, nf)).intern(this); } - + public Goal X10Expanded(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("X10Expanded", job, new X10ImplicitDeclarationExpander(job, ts, nf)).intern(this); } - + public Goal NativeClassVisitor(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("NativeClassVisitor", job, new NativeClassVisitor(job, ts, nf, "java")).intern(this); } - + public Goal WSCodeGenerator(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - Goal result = null; - + Goal result = null; + try{ //Use reflect to load the class from ClassLoader cl = Thread.currentThread().getContextClassLoader(); @@ -770,49 +774,54 @@ } return result; } - + public Goal Desugarer(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("Desugarer", job, new Desugarer(job, ts, nf)).intern(this); } + public Goal ExpressionFlattener(Job job) { + TypeSystem ts = extInfo.typeSystem(); + NodeFactory nf = extInfo.nodeFactory(); + return new VisitorGoal("ExpressionFlattener", job, new ExpressionFlattener(job, ts, nf)).intern(this); + } + public Goal InnerClassRemover(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("InnerClassRemover", job, new X10InnerClassRemover(job, ts, nf)).intern(this); } - public Goal StaticNestedClassRemover(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); return new ValidatingVisitorGoal("StaticNestedClassRemover", job, new StaticNestedClassRemover(job, ts, nf)).intern(this); } } - + protected Options createOptions() { return new X10CompilerOptions(this); } - + public Map<QName,CompilerPlugin> plugins() { if (plugins == null) { return Collections.emptyMap(); } return plugins; } - + public void addPlugin(QName pluginName, CompilerPlugin plugin) { if (plugins == null) { plugins = new HashMap<QName,CompilerPlugin>(); } plugins.put(pluginName, plugin); } - + public CompilerPlugin getPlugin(QName pluginName) { if (plugins == null) { return null; } - + return plugins.get(pluginName); } } Modified: trunk/x10.compiler/src/x10/ast/StmtExpr.java =================================================================== --- trunk/x10.compiler/src/x10/ast/StmtExpr.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/ast/StmtExpr.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -15,6 +15,8 @@ import polyglot.ast.Block; import polyglot.ast.Expr; +import polyglot.ast.ForInit; +import polyglot.ast.ForUpdate; import polyglot.ast.Stmt; /** @@ -27,7 +29,7 @@ * * @author igor */ -public interface StmtExpr extends Expr, Block { +public interface StmtExpr extends Expr, Block, ForInit, ForUpdate { /** * Append a list of statements to the statement expression (just before the result), Modified: trunk/x10.compiler/src/x10/ast/StmtExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/StmtExpr_c.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/ast/StmtExpr_c.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -39,6 +39,12 @@ import polyglot.visit.PrettyPrinter; /** + * A StmtExpr is a sequence of statements followed by an expression, the result. + * + * The result may be null, if the type of the StmtExpr is Void. This is used to + * flatten a call to a void method. Such StmtExpr's can only be used in Eval statements. + * - Bowen + * * @author igor * */ @@ -50,7 +56,7 @@ public StmtExpr_c(Position pos, List<Stmt> statements, Expr result) { super(pos); assert(statements != null); - assert(result != null); +// assert(result != null); // result can be null, if the type is Void -- Bowen this.statements = TypedList.copyAndCheck(statements, Stmt.class, true); this.result = result; } Modified: trunk/x10.compiler/src/x10/ast/StmtSeq.java =================================================================== --- trunk/x10.compiler/src/x10/ast/StmtSeq.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/ast/StmtSeq.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -12,7 +12,10 @@ package x10.ast; import polyglot.ast.Block; +import polyglot.ast.ForInit; +import polyglot.ast.ForUpdate; import polyglot.ast.NodeList; +import polyglot.visit.NodeVisitor; /** A StmtSeq is an immutable representation of a sequence of statements. Usually * sequences of statements are represented in a block. However a block @@ -32,6 +35,6 @@ * @author vj * */ -public interface StmtSeq extends NodeList, Block { +public interface StmtSeq extends NodeList, Block, ForUpdate, ForInit { } Modified: trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java =================================================================== --- trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java 2010-06-17 20:07:11 UTC (rev 14618) +++ trunk/x10.compiler/src/x10/optimizations/ForLoopOptimizer.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -18,6 +18,8 @@ import polyglot.ast.Assign; import polyglot.ast.Binary; import polyglot.ast.Block; +import polyglot.ast.BooleanLit; +import polyglot.ast.Branch; import polyglot.ast.Expr; import polyglot.ast.Field; import polyglot.ast.For; @@ -32,6 +34,7 @@ import polyglot.ast.Stmt; import polyglot.ast.Term; import polyglot.ast.TypeNode; +import polyglot.ast.Unary; import polyglot.ast.Assign.Operator; import polyglot.frontend.Job; import polyglot.types.FieldInstance; @@ -50,6 +53,7 @@ import x10.ast.ForLoop; import x10.ast.ForLoop_c; import x10.ast.RegionMaker; +import x10.ast.StmtSeq; import x10.ast.X10Call; import x10.ast.X10Cast; import x10.ast.X10Formal; @@ -458,6 +462,9 @@ * TODO: move into Synthesizer */ public LocalDecl createLocalDecl(Position pos, Flags flags, Name name, Expr init) { + if (init.type().isVoid()) { + System.err.println("ERROR: ForLoopOptimizer.createLocalDecl: creating void local assignment for " +init+ " at " +pos); + } return createLocalDecl(pos, flags, name, init.type(), init); } @@ -551,9 +558,139 @@ return stmts; } + /** + * Create a break statement. + * + * @param pos the Position of the break statement in source code + * @return the synthesized break statement + * TODO: move to Synthesizer + */ + public Branch createBreak(Position pos) { + return xnf.Break(pos); + } + + /** + * Create a declaration for an uninitialized local variable from scratch. + * (A local variable definition is created as a side-effect and may be retrieved from the result.) + * + * @param pos the Position of the declaration + * @param flags the Flags ("static", "public", "var") for the declared local variable + * @param name the Name of the declared local variable + * @param type the Type of the declared local variable + * @return the LocalDecl representing the declaration of the local variable + * TODO: move into Synthesizer + */ + public LocalDecl createLocalDecl(Position pos, Flags flags, Name name, Type type) { + LocalDef def = xts.localDef(pos, flags, Types.ref(type), name); + return createLocalDecl(pos, def); + } + + + /** + * Create a declaration for a local variable from an uninitialized local type definition. + * + * @param pos the Position of the declaration + * @param def the definition of the declared local variable + * @return the LocalDecl representing the declaration of the local variable + * TODO: move into Synthesizer + */ + public LocalDecl createLocalDecl(Position pos, LocalDef def) { + return xnf.LocalDecl( pos, + xnf.FlagsNode(pos, def.flags()), + xnf.CanonicalTypeNode(pos, def.type().get()), + xnf.Id(pos, def.name()) ).localDef(def); + } + + /** + * Create an assignment statement. + * + * @param pos the Position of the assignment in source code + * @param target the left-hand side of the assignment + * @param op the assignment operator + * @param source the right-hand side of the assignment + * @return the synthesized assignment statement + * TODO: move to synthesizer + */ + public Stmt createAssignment(Position pos, Expr target, Operator op, Expr source) { + return createAssignment(createAssign(pos, target, op, source)); + } + + /** + * Create as assignment statement for a given Assign expression. + * + * @param expr the expression to evaluate + * @return the synthesized assignment statement + * TODO: move to Synthesizer + */ + public Stmt createAssignment(Assign expr) { + return createEval(expr); + } + + /** + * Create an evaluation statement for a given expression. + * + * @param expr the expression to be evaluated + * @return a synthesized statement that evaluates expr + * TODO: move to Synthesizer + */ + public Stmt createEval(Expr expr) { + return xnf.Eval(expr.position(), expr); + } + + + /** + * Create a conditional statements. + * + * @param pos the Position of the conditional statement in source code. + * @param cond the boolean expression to be tested + * @param thenStmt the statement to execute if cond is true + * @param elseStmt the statement to execute if cond is false + * @return the synthesized conditional statement + * TODO: move to Synthesizer + */ + public Stmt createIf(Position pos, Expr cond, Stmt thenStmt, Stmt elseStmt) { + if (null == elseStmt) return xnf.If(pos, cond, thenStmt); + return xnf.If(pos, cond, thenStmt, elseStmt); + } + + /** + * Turn a single statement into a statement sequence. + * + * @param stmt the statement to be encapsulated + * @return a synthesized statement sequence comprising stmt + */ + public StmtSeq toStmtSeq(Stmt stmt) { + return toStmtSeq(stmt.position(), Collections.singletonList(stmt)); + } + + /** + * Turn a list of statements into a statement sequence. + * + * @param pos the Position of the statement sequence in source code + * @param stmts a list of statements + * @return a synthesized statement sequence comprising stmts + * TODO: move to Synthesizer + */ + public StmtSeq toStmtSeq(Position pos, List<Stmt> stmts) { + return xnf.StmtSeq(pos, stmts); + } + // helper methods that create subclasses of Expr /** + * Create a statement expression -- a block of statements with a result value. + * + * @param pos the Position of the statement expression in source code + * @param stmts the statements to proceed evaluation of expr + * @param expr the result of the statement expression + * @return a synthesized statement expresssion comprising stmts and expr + * TODO: move to Synthesizer + */ + public Expr createStmtExpr(Position pos, List<Stmt> stmts, Expr expr) { + return xnf.StmtExpr(pos, stmts, expr).type(expr.type()); + } + + /** * Create an IntLit node representing a given integer literal. * * @param val the int value to be represented @@ -568,6 +705,80 @@ } } + /** + * Create the boolean literal "true". + * + * @param pos the Position of the literal in source code + * @return the synthesized boolean literal + * TODO: move to synthesizer + */ + public BooleanLit createTrue(Position pos) { + return (BooleanLit) xnf.BooleanLit(pos, true).type(xts.Boolean()); + } + + /** + * Create the boolean litteral "false". + * + * @param pos the Position of the literal in source code + * @return the synthesized boolean literal + * TODO: move to the synthesizer + */ + public BooleanLit createFalse(Position pos) { + return (BooleanLit) xnf.BooleanLit(pos, false).type(xts.Boolean()); + } + + /** + * Create the boolean negation of a given (boolean) expression. + * + * @param expr the boolean expressin to be negated + * @return a synthesized expression which is the boolean negation of expr + * TODO: move to synthesizer + */ + public Unary createNot(Expr expr) { + return createNot(expr.position(), expr); + } + + + /** + * Create the boolean negation of a given (boolean) expression. + * + * @param pos the Position of the negated expression in the source code + * @param expr the boolean expression to be negated + * @return a synthesized expression that negates expr + * TODO: move to Synthesizer + */ + public Unary createNot(Position pos, Expr expr) { + assert (expr.type().isBoolean()); + return createUnary(pos, Unary.NOT, expr); + } + + + /** + * Create a unary expression. + * + * @param pos the Position of the unary expression in the source code + * @param op the unary operation of the expression + * @param expr the argument to the unary operator + * @return a synthesized unary expression equivalent to applying op to expr + * TODO: move to Synthesizer + */ + public Unary createUnary(Position pos, polyglot.ast.Unary.Operator op, Expr expr) { + return (Unary) xnf.Unary(pos, op, expr).type(expr.type()); + } + + /** + * Create a local variable reference copied from another + * + * @param pos the Position of the new local variable reference in source code. + * @param local the local variable reference to copy + * @return a synthesized local variable reference + * TODO: move to Synthesizer + */ + + public Local createLocal(Position pos, Local local) { + return syn.createLocal(pos, local.localInstance()); + } + /** * Create a local variable reference. * @@ -890,6 +1101,16 @@ return createMethodInstance(receiver.type(), name, args); } + /** + * Create a new Name for a temporary variable. + * + * @return the newly created name + * TODO: move to Synthesizer + */ + public Name createTemporaryName() { + return Name.makeFresh("t"); + } + /** * Find the Types for a sequence of expressions. * Added: trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java =================================================================== --- trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java (rev 0) +++ trunk/x10.compiler/src/x10/visit/ExpressionFlattener.java 2010-06-17 20:08:07 UTC (rev 14619) @@ -0,0 +1,1183 @@ +/** + * + */ +package x10.visit; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import polyglot.ast.ArrayAccess; +import polyglot.ast.Assert; +import polyglot.ast.Assign; +import polyglot.ast.Binary; +import polyglot.ast.Block; +import polyglot.ast.BooleanLit; +import polyglot.ast.Branch; +import polyglot.ast.Call; +import polyglot.ast.Case; +import polyglot.ast.Cast; +import polyglot.ast.Catch; +import polyglot.ast.Conditional; +import polyglot.ast.ConstructorCall; +import polyglot.ast.ConstructorDecl; +import polyglot.ast.Do; +import polyglot.ast.Empty; +import polyglot.ast.Eval; +import polyglot.ast.Expr; +import polyglot.ast.Field; +import polyglot.ast.FieldAssign; +import polyglot.ast.FieldDecl; +import polyglot.ast.For; +import polyglot.ast.ForInit; +import polyglot.ast.ForUpdate; +import polyglot.ast.If; +import polyglot.ast.Instanceof; +import polyglot.ast.Lit; +import polyglot.ast.Local; +import polyglot.ast.LocalAssign; +import polyglot.ast.LocalDecl; +import polyglot.ast.New; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.ast.Return; +import polyglot.ast.Special; +import polyglot.ast.Stmt; +import polyglot.ast.Switch; +import polyglot.ast.Throw; +import polyglot.ast.Try; +import polyglot.ast.TypeNode; +import polyglot.ast.Unary; +import polyglot.ast.While; +import polyglot.ast.Assign.Operator; +import polyglot.frontend.Job; +import polyglot.types.Flags; +import polyglot.types.LocalDef; +import polyglot.types.Name; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.types.Types; +import polyglot.util.Position; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.AssignPropertyCall; +import x10.ast.Async; +import x10.ast.AtEach; +import x10.ast.AtExpr; +import x10.ast.AtStmt; +import x10.ast.Atomic; +import x10.ast.Await; +import x10.ast.Closure; +import x10.ast.ClosureCall; +import x10.ast.Finish; +import x10.ast.ForEach; +import x10.ast.ForLoop; +import x10.ast.Future; +import x10.ast.Here; +import x10.ast.Next; +import x10.ast.ParExpr; +import x10.ast.RemoteActivityInvocation; +import x10.ast.SettableAssign; +import x10.ast.StmtExpr; +import x10.ast.StmtSeq; +import x10.ast.SubtypeTest; +import x10.ast.Tuple; +import x10.ast.When; +import x10.ast.X10NodeFactory; +import x10.optimizations.ForLoopOptimizer; +import x10.types.X10TypeSystem; + +/** + * @author Bowen Alpern + * + */ +public final class ExpressionFlattener extends ContextVisitor { + + private static final boolean DEBUG = false; + + X10TypeSystem xts; + X10NodeFactory xnf; +// Synthesizer syn; + ForLoopOptimizer syn; // move functionality to Synthesizer + + /** + * @param job the job to run + * @param ts the type system object + * @param nf the factory to produce AST nodes + */ + public ExpressionFlattener(Job job, TypeSystem ts, NodeFactory nf) { + super(job, ts, nf); + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; +// syn = new Synthesizer(xnf, xts); + syn = new ForLoopOptimizer(job, ts, nf); + } + + /* (non-Javadoc) + * @see polyglot.visit.NodeVisitor#override(polyglot.ast.Node) + * + * AST Nodes that aren't flattened. + * Assert, Await, and When require the Java back-end handle StmtExpr's to achieve the right semantics. + * Constructors and class initializers cannot be flattened because of Java's initialization rules (X10 proto would fix + * this but the Java back-end must be able to handle the new code). + * Case Expr's are constant expressions that will eventually get evaluated at compile time. + */ + public Node override(Node n) { + if (n instanceof ConstructorDecl) { // can't flatten constructors until local assignments can precede super() and this() + return n; + } + if (n instanceof AssignPropertyCall) { // can't flatten constructors until local assignments can precede property assignments + return n; + } + if (n instanceof FieldDecl) { // can't flatten class initializes until assignments can precede field declarations + return n; + } + if (n instanceof Assert) { // can't flatten assert's until Java can handle StmtExpr's + return n; + } + if (n instanceof Await) { // can't flatten await's until Java can handle StmtExpr's + return n; + } + if (n instanceof When) { // can't flatten when's until Java can handle StmtExpr's + return n; + } + if (n instanceof Case) { // case Expr's will become constants, don't screw with them. + return n; + } + return null; + } + + /* (non-Javadoc) + * @see polyglot.visit.ErrorHandlingVisitor#leaveCall(polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) + * + * Flatten statements (Stmt) and expressions (Expr). + */ + public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { + if (n instanceof Expr) return flattenExpr((Expr) n); + if (n instanceof Stmt) return flattenStmt((Stmt) n); + return n; + } + + /** + * Flatten Expr's. (Flat expressions do not contain sub-expressions that arn't literal constants or final variables.) + * The result may be a StmtExpr. (Statement flattening will eliminating these.) + * + * @param expr the Expr to be flattened + * @return a flat Expr equivalent to expr (often a StmtExpr) + */ + private Expr flattenExpr(Expr expr) { + if (expr instanceof Lit) return flattenPrimary(expr); + else if (expr instanceof Local) return flattenPrimary(expr); + else if (expr instanceof Special) return flattenPrimary(expr); + else if (expr instanceof Here) return flattenPrimary(expr); + else if (expr instanceof ParExpr) return flattenParExpr((ParExpr) expr); + else if (expr instanceof Field) return flattenField((Field) expr); + else if (expr instanceof ArrayAccess) return flattenArrayAccess((ArrayAccess) expr); + else if (expr instanceof SettableAssign) return flattenSettableAssign((SettableAssign) expr); + else if (expr instanceof FieldAssign) return flattenFieldAssign((FieldAssign) expr); + else if (expr instanceof LocalAssign) return flattenLocalAssign((LocalAssign) expr); + else if (expr instanceof Call) return flattenMethodCall((Call) expr); + else if (expr instanceof New) return flattenNew((New) expr); + else if (expr instanceof Tuple) return flattenTuple((Tuple) expr); + else if (expr instanceof Binary) return flattenBinary((Binary) expr); + else if (expr instanceof Unary) return flattenUnary((Unary) expr); + else if (expr instanceof Cast) return flattenCast((Cast) expr); + else if (expr instanceof Instanceof) return flattenInstanceof((Instanceof) expr); + else if (expr instanceof AtExpr) return flattenAtExpr((AtExpr) expr); + else if (expr instanceof Future) return flattenFuture((Future) expr); + else if (expr instanceof SubtypeTest) return flattenSubtypeTest((SubtypeTest) expr); + else if (expr instanceof ClosureCall) return flattenClosureCall((ClosureCall) expr); + else if (expr instanceof Conditional) return flattenConditional((Conditional) expr); + else if (expr instanceof StmtExpr) return flattenStmtExpr((StmtExpr) expr); + else if (expr instanceof Closure) return expr; + else { + if (DEBUG) System.err.println("INFO: ExpressionFlattener.flattenExpr: default class: " +expr.getClass()+ " (" +expr+ ") at" +expr.position()); + return expr; + } + } + + /** + * Flatten a primary expression. + * (no-op: Primary expressions are already flat!) + * + * @param expr the primary expression to be flattened + * @return (the already flat) expr + */ + private Expr flattenPrimary(Expr expr) { + return expr; + } + + /** + * Flatten a statement expression (which almost certainly will already be flat). + * <pre> + * ({S; ({s1; t1}) }) -> ({S; s1; t1}) + * </pre> + * + * @param expr a statement expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenStmtExpr(StmtExpr expr) { + assert (! (expr.result() instanceof StmtExpr)); // if this ever happens, uncomment the code to flatten expr.result() + /* + if (expr.result() instanceof StmtExpr) { // this (probably) never happens + expr = expr.append(getStatements(expr.result())); + expr = expr.result(getResult(expr.result())); + } + */ + return expr; + } + + /** + * Flatten a parenthesized expression. + * (This should never happen, but it does.) + * <pre> + * (({s1; e1})) -> ({s1; val t1=e1; (t1)}) + * </pre> + * + * @param expr the parenthesized expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenParExpr(ParExpr expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr primary = getPrimaryAndStatements(expr.expr(), stmts); + return toFlatExpr(expr.position(), stmts, expr.expr(primary)); + } + + /** + * Flatten an array access. + * (Note: the StmtExpr must end in an array access in case it gets bumped: a(i)++.) + * {s1; e1}({s2; e2}) -> {s1; val t1=e1; s2; val t2=e2; t1(t2)} + * + * @param expr + * @return + */ + private Expr flattenArrayAccess(ArrayAccess expr) { + assert false; + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr array = getPrimaryAndStatements(expr.array(), stmts); + Expr index = getPrimaryAndStatements(expr.index(), stmts); + return toFlatExpr(expr.position(), stmts, expr.array(array).index(index)); + } + + /** + * Flatten an object (or struct) allocation. + * <pre> + * new T(({s1; e1}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; val t = new T(t1, ..., tk); t}) + * ({s1; e1}).new T(({s2; e2}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; val t = t1.new T(t2, ..., tk); t}) + * </pre> + * + * @param expr the New expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenNew(New expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + List<Expr> args = new ArrayList<Expr>(); + for (Expr e : expr.arguments()) { + Expr primary = getPrimaryAndStatements(e, stmts); + args.add(primary); + } + return toFlatExpr(expr.position(), stmts, (Expr) expr.arguments(args)); + } + + /** + * Flatten a field access. + * <pre> + * T.f -> T.f + * ({s1; e1}).f -> ({s1; val t1 = e1; t1.f}) + * </pre> + * + * @param expr the field access to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenField(Field expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + if (expr.target() instanceof TypeNode) { + return expr; + } + Expr target = getPrimaryAndStatements((Expr) expr.target(), stmts); + return toFlatExpr(expr.position(), stmts, expr.target(target)); + } + + + /** + * Flatten a unary expression. + * If the unary operator (++ or --) updates its argument: + * <pre> + * op ({s1; e1}) -> ({s1; op e1}) + * ({s1; e1}) op -> ({s1; e1 op}) + * </pre>, + * otherwise + * <pre> + * op ({s1; e1}) -> ({s1; val t1 = e1; op t1}) + * </pre> + * + * @param expr the unary expression to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenUnary(Unary expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr result; + if (isUpdateOp(expr.operator())) { + stmts.addAll(getStatements(expr.expr())); + result = getResult(expr.expr()); + } else { + result = getPrimaryAndStatements(expr.expr(), stmts); + } + return toFlatExpr(expr.position(), stmts, expr.expr(result)); + } + + + /** + * Does the given unary operator update it arguement? (Is it "++" or "--"?) + * + * @param op the unary operator in question + * @return true, if op updates its argument; false, otherwise + */ + private boolean isUpdateOp(polyglot.ast.Unary.Operator op) { + return op.equals(Unary.PRE_DEC) || op.equals(Unary.PRE_INC) || op.equals(Unary.POST_DEC) || op.equals(Unary.POST_INC); + } + + /** + * Flatten a cast expression. + * <pre> + * ({s1; e1}) as T -> ({s1; val t1 = e1; t1 as T}) + * </pre> + * + * @param expr the cast to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenCast(Cast expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr primary = getPrimaryAndStatements(expr.expr(), stmts); + return toFlatExpr(expr.position(), stmts, expr.expr(primary)); + } + + + /** + * Flatten an instanceof expression. + * <pre> + * ({s1; e1}) instanceof T -> ({s1; val t1 = e1; t1 instanceof T}) + * </pre> + * + * @param expr the instanceof expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenInstanceof(Instanceof expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr primary = getPrimaryAndStatements(expr.expr(), stmts); + return toFlatExpr(expr.position(), stmts, expr.expr(primary)); + } + + /** + * Flatten an At expression. + * (Only the Place needs to be flattened; the body is already flat.) + * <pre> + * at (({s1; e1})) {S; ({s2; e2})} -> ({s1; val t1 = e1; at (t1) {S; s2; e2} }) + * </pre> + * + * @param expr the at expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenAtExpr(AtExpr expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + return toFlatExpr(expr.position(), stmts, (Expr) flattenRemoteActivityInvocation(expr, stmts)); + } + + /** + * Flatten a Future expression. + * (Only the Place needs to be flattened; the body is already flat.) + * <pre> + * future (({s1; e1})) {S; ({s2; e2})} -> ({s1; val t1 = e1; future (t1) {S; s2; e2} }) + * </pre> + * + * @param expr the future expression to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenFuture(Future expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + return toFlatExpr(expr.position(), stmts, (Expr) flattenRemoteActivityInvocation(expr, stmts)); + } + + + /** + * Flatten a sub-type test. This is a no-op. + * <pre> + * T1 <: T2 -> T1 <: T2 + * </pre> + * + * @param expr the sub-type text to be flattened + * @return a flat expression equivalent to expr + * TODO: need source code to test this + */ + private Expr flattenSubtypeTest(SubtypeTest expr) { + return expr; + } + + /** + * Flatten a method call expression. + * <pre> + * ({s1; e1}).m(({s2; e2}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; t1.m(t2, ..., tk) }) + * ({s1; e1}).m(({s2; e2}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; Eval(t1.m(t2, ..., tk)) }) // (void call) + * T.m(({s1; e1}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; T.m(t1, ..., tk) }) + * T.m(({s1; e1}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; Eval( T.m(t1, ..., tk)) }) // (void call) + *</pre> + * + * @param expr the method call to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenMethodCall(Call expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + if (expr.target() instanceof Expr) { + Expr target = getPrimaryAndStatements((Expr) expr.target(), stmts); + expr = expr.target(target); + } + List<Expr> args = new ArrayList<Expr>(); + for (Expr e : expr.arguments()) { + Expr primary = getPrimaryAndStatements(e, stmts); + args.add(primary); + }; + return toFlatExpr(expr.position(), stmts, (Expr) expr.arguments(args)); + } + + + /** + * Flatten a closure call expression. + * <pre> + * ({s1; e1})(({s2; e2}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; t1(t2, ..., tk) }) + * ({s1; e1})(({s2; e2}), ..., ({sk; ek})) -> ({s1; val t1 = e1; ... sk; val tk = ek; Eval(t1(t2, ..., tk)) }) // (void call) + *</pre> + * + * @param expr the closure call to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenClosureCall(ClosureCall expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr primary = getPrimaryAndStatements(expr.target(), stmts); + expr = expr.target(primary); + List<Expr> args = new ArrayList<Expr>(); + for (Expr e : expr.arguments()) { + Expr primary2 = getPrimaryAndStatements(e, stmts); + args.add(primary2); + } + return toFlatExpr(expr.position(), stmts, (Expr) expr.arguments(args)); + } + + + /** + * Flatten a tuple expression. + * <pre> + * [({s1; e1}), ..., ({sk; ek})] -> {s1; val t1 = e1; ... sk; val tk = ek; [t1, ..., tk] }) + * </pre> + * + * @param expr the tuple to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenTuple(Tuple expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + List<Expr> args = new ArrayList<Expr>(); + for (Expr e : expr.arguments()) { + Expr primary = getPrimaryAndStatements(e, stmts); + args.add(primary); + } + return toFlatExpr(expr.position(), stmts, expr.arguments(args)); + } + + /** + * Flatten a binary expression. + * (Short-circuit AND (&&) and OR (||) are special.) + * <pre> + * ({s1; e1}) && ({s2; e2})) -> ({s1; var t = e1; if ( t){s2; t = e2;}; t}) + * ({s1; e1}) \xA6\xA6 ({s2; e2})) -> ({s1; var t = e1; if (!t){s2; t =be2;}; t}) + * ({s1; e1}) op ({s2; e2})) -> ({s1; val t1 = e1; s2; val t2 = e2; t1 op t2}) + * </pre> + * + * @param expr the binary expression to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenBinary(Binary expr) { + Position pos = expr.position(); + List<Stmt> stmts = new ArrayList<Stmt>(); + if (expr.operator().equals(Binary.COND_AND)) { + stmts.addAll(getStatements(expr.left())); + Expr left = getResult(expr.left()); + LocalDecl tmpLDecl = syn.createLocalDecl( pos, + Flags.NONE, + syn.createTemporaryName(), + xts.Boolean(), + left ); + stmts.add(tmpLDecl); + List<Stmt> andStmts = new ArrayList<Stmt>(); + stmts.addAll(getStatements(expr.right())); + Expr right = getResult(expr.right()); + andStmts.add(syn.createAssignment( pos, + syn.createLocal(pos, tmpLDecl), + Assign.ASSIGN, + right )); + stmts.add(syn.createIf( pos, + syn.createLocal(pos, tmpLDecl), + syn.createBlock(pos, andStmts), + null )); + return toFlatExpr(pos, stmts, syn.createLocal(pos, tmpLDecl)); + } else if (expr.operator().equals(Binary.COND_OR)) { + stmts.addAll(getStatements(expr.left())); + Expr left = getResult(expr.left()); + LocalDecl tmpLDecl = syn.createLocalDecl( pos, + Flags.NONE, + syn.createTemporaryName(), + xts.Boolean(), + left ); + stmts.add(tmpLDecl); + List<Stmt> orStmts = new ArrayList<Stmt>(); + stmts.addAll(getStatements(expr.right())); + Expr right = getResult(expr.right()); + orStmts.add(syn.createAssignment( pos, + syn.createLocal(pos, tmpLDecl), + Assign.ASSIGN, + right )); + stmts.add(syn.createIf( pos, + syn.createNot(syn.createLocal(pos, tmpLDecl)), + syn.createBlock(pos, orStmts), + null )); + return toFlatExpr(pos, stmts, syn.createLocal(pos, tmpLDecl)); + } + Expr left = getPrimaryAndStatements(expr.left(), stmts); + Expr right = getPrimaryAndStatements(expr.right(), stmts); + return toFlatExpr(pos, stmts, expr.left(left).right(right)); + } + + /** + * Flatten an assignment to a field. + * <pre> + * T.f op= ({s1; e1}) -> ({s1; val t1 = e1; T.f op= t1}) + * ({s1; e1}).f op= ({s2; e2}) -> ({s1; val t1 = e1; s2; val t2 = e2; t1.f op= t2}) + * </pre> + * + * @param expr the field assignment to be flattened + * @return a flat expression equivalent to expr + */ + private Expr flattenFieldAssign(FieldAssign expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + if (expr.target() instanceof Expr) { + Expr target = getPrimaryAndStatements((Expr) expr.target(), stmts); + expr = expr.target(target); + } + Expr right = getPrimaryAndStatements(expr.right(), stmts); + return toFlatExpr(expr.position(), stmts, expr.right(right)); + } + + + /** + * Flatten an assignment to a local variable. + * <pre> + * x op= ({s1; e1}) -> ({s1; val t1 = e1; x op= t1}) + * </pre> + * + * @param expr the local assignment to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenLocalAssign(LocalAssign expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr right = getPrimaryAndStatements(expr.right(), stmts); + return toFlatExpr(expr.position(), stmts, expr.right(right)); + } + + + /** + * Flatten an array element assignment. + * <pre> + * ({s1; e1})(({s2; e2}), ... ({se; tk})) op= ({sk+1; ek+1}) -> + * ({s1; val t1 = e1; ... sk+1; val tk+1 = ek+1; t1(t2, ..., tk) op= tk+1 }) + * </pre> + * + * @param expr the array element assignment to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenSettableAssign(SettableAssign expr) { + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr array = getPrimaryAndStatements(expr.array(), stmts); + List<Expr> exprs = new ArrayList<Expr>(); + for (Expr e : expr.index()) { + Expr index = getPrimaryAndStatements(e, stmts); + exprs.add(index); + } + Expr right = getPrimaryAndStatements(expr.right(), stmts); + return toFlatExpr(expr.position(), stmts, expr.array(array).index(exprs).right(right)); + } + + /** + * Flatten a conditional expression. + * <pre> + * ({s1; e1}) ? ({s2; e2}) : ({s3; e3} -> ({s1; val t1 = e1; var t; if (t1){s2; t = e2} else {s3; t = e3}; t}) + * </pre> + * + * @param expr the conditional expression to flatten + * @return a flat expression equivalent to expr + */ + private Expr flattenConditional(Conditional expr) { + assert (null != expr.alternative()); + List<Stmt> stmts = new ArrayList<Stmt>(); + Expr primary = getPrimaryAndStatements(expr.cond(), stmts); + LocalDecl tmpLDecl = syn.createLocalDecl(expr.position(), Flags.NONE, syn.createTemporaryName(), expr.type()); + stmts.add(tmpLDecl); + List<Stmt> thenStmts = new ArrayList<Stmt>(); + thenStmts.addAll(getStatements(expr.consequent())); + thenStmts.add(syn.createAssignment( expr.position(), + syn.createLocal(expr.position(), tmpLDecl), + Assign.ASSIGN, + getResult(expr.consequent()) )); + List<Stmt> elseStmts = new ArrayList<Stmt>(); + elseStmts.addAll(getStatements(expr.alternative())); + elseStmts.add(syn.createAssignment( expr.position(), + syn.createLocal(expr.position(), tmpLDecl), + Assign.ASSIGN, + getResult(expr.alternative()) )); + stmts.add(syn.createIf( expr.position(), + primary, + syn.createBlock(expr.consequent().position(), thenStmts), + syn.createBlock(expr.alternative().position(), elseStmts) )); + return toFlatExpr(expr.position(), stmts, syn.createLocal(expr.position(), tmpLDecl)); + } + + /** + * Produce a statement in which all sub-expressions have been flattened. + * Transform any embedded statement expressions into statements and expressions. + * (All children of this statement have already been flattened.) + * + * @param stmt the statement to be flattened + * @return a flat statement (possibly a Block) semantically equivalent to stmt + */ + private Stmt flattenStmt(Stmt stmt) { + if (stmt instanceof Eval) return flattenEval((Eval) stmt); + else if (stmt instanceof LocalDecl) return flattenLocalDecl((LocalDecl) stmt); + else if (stmt instanceof Block) return flattenBlock((Block) stmt); + else if (stmt instanceof If) return flattenIf((If) stmt); + else if (stmt instanceof Do) return flattenDo((Do) stmt); + else if (stmt instanceof For) return flattenFor((For) stmt); + else if (stmt instanceof ForLoop) return flattenForLoop((ForLoop) stmt); + else if (stmt instanceof While) return flattenWhile((While) stmt); + else if (stmt instanceof Return) return flattenReturn((Return) stmt); + else if (stmt instanceof Throw) return flattenThrow((Throw) stmt); + else if (stmt instanceof Switch) return flattenSwitch((Switch) stmt); + else if (stmt instanceof Assert) return flattenAssert((Assert) stmt); + else if (stmt instanceof Async) return flattenAsync((Async) stmt); + else if (stmt instanceof AtStmt) return flattenAtStmt((AtStmt) stmt); + else if (stmt instanceof Await) return flattenAwait((Await) stmt); + else if (stmt instanceof When) return flattenWhen((When) stmt); + else if (stmt instanceof ForEach) return flattenForEach((ForEach) stmt); + else if (stmt instanceof AtEach) return flattenAtEach((AtEach) stmt); + else if (stmt instanceof AssignPropertyCall) return flattenAssignPropertyCall((AssignPropertyCall) stmt); + else if (stmt instanceof ConstructorCall) return flattenConstructorCall((ConstructorCall) stmt); + else if (stmt instanceof Branch) return syn.toStmtSeq(stmt); + else if (stmt instanceof Finish) return syn.toStmtSeq(stmt); + else if (stmt instanceof Next) return syn.toStmtSeq(stmt); + else if (stmt instanceof Try) { + if (((Try) stmt).tryBlock() instanceof StmtSeq) { + List<Stmt> stmts = ((StmtSeq)((Try) stmt).tryBlock()).statements(); + assert (1 == stmts.size()); + return ((Try) stmt).tryBlock((Block) stmts.get(0)); + } + return stmt; + } + else { + if (DEBUG && !(stmt instanceof Try || stmt instanceof Catch || stmt instanceof Atomic || stmt instanceof Empty)) + System.err.println("INFO: ExpressionFlattener.flattenStmt: default class: " +stmt.getClass()+ " (" +stmt+ ") at " +stmt.position() ); + return stmt; + } + } + + /** + * Flatten a block. + * (Actually, this is a no-op, the only block with a value, StmtExpr, has already been handled.) + * <pre> + * { S; ({s1; e1}) } -> { S; s1; e1 } + * </pre> + * + * @param stmt the block to be flattened + * @return a block with all of its constituent statements flattened. + */ + private StmtSeq flattenBlock(Block stmt) { + assert (!(stmt instanceof StmtExpr)); + return syn.toStmtSeq(stmt); + } + + /** + * Flatten an assertion. + * The semantics of a flat assertion require the backend to be able to handle a StmtExpr. The java back-end cannot. + * For the time being, assertions are not flattened. + * <pre> + * assert ({s1; e1}); -> assert ({s1; e1}); // no-op + * </pre> + * + * @param stmt the assertion to be flattened + * @return a flat stmt with the same semantics as stmt + * TODO: handle StmtExpr's in the Java back end. + */ + private StmtSeq flattenAssert(Assert stmt) { + assert false; + return syn.toStmtSeq(stmt); + } + + /** + * Flatten an await statement. + * The semantics of a flat assertion require the backend to be able to handle a StmtExpr. The java back-end cannot. + * For the time being await statements are not flattened. + * <pre> + * await (({s1; e1})); -> await (({s1; e1})); // no-op + * </pre> + * + * @param stmt the await statement to flatten + * @return a flat statement with the same semantics as stmt + * TODO: handle StmtExpr's in the Java back end. + */ + private StmtSeq flattenAwait(Await stmt) { + assert false; + return syn.toStmtSeq(stmt); + } + + /** + * Flatten an when statement. + * The semantics of a flat assertion require the backend to be able to handle a StmtExpr. The java back-end cannot. + * For the time being when statements are not flattened. + * <pre> + * when (({s1; e1})) { S1 } ... or (({sk; ek})) { Sk }; -> when (({s1; e1})) { S1 } ... or (({sk; ek})) { Sk }; // no-op + * </pre> + * + * @param stmt the when statement to flatten + * @return a flat statement with the same semantics as stmt + * TODO: handle StmtExpr's in the Java back end. + */ + private StmtSeq flattenWhen(When stmt) { + assert false; + return syn.toStmtSeq(stmt); + } + + /** + * Flatten a ForEach statement. + * <pre> + * foreach (x in ({s1; e1})) S -> s1; val t1 = e1; foreach (x in t1) S; + * </pre> + * + * @param stmt the ForEach statement to flatten + * @return a flat statement with the same semantics as stmt + */ + ... [truncated message content] |
From: <yz...@us...> - 2010-06-21 20:12:03
|
Revision: 14645 http://x10.svn.sourceforge.net/x10/?rev=14645&view=rev Author: yzibin Date: 2010-06-21 20:11:56 +0000 (Mon, 21 Jun 2010) Log Message: ----------- Removed dead code from XConstraint that "supported multiple solvers". Fixed position info in "Bla.super.i" (see XTENLANG-1473) Modified Paths: -------------- trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/constraints/CConstraint.java trunk/x10.constraints/src/x10/constraint/XConstraint.java trunk/x10.constraints/src/x10/constraint/XPromise_c.java trunk/x10.constraints/src/x10/constraint/XTerm.java Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG_1473.x10 Removed Paths: ------------- trunk/x10.constraints/src/x10/constraint/Solver.java Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -7012,7 +7012,7 @@ //#line 4035 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(5); //#line 4037 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(nf.Field(pos(), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), Identifier)); + setResult(nf.Field(pos(), nf.Super(pos(getLeftSpan(),getRhsFirstTokenIndex(3)), ClassName.toType()), Identifier)); break; } @@ -7054,7 +7054,7 @@ //#line 4050 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" IToken c = (IToken) getRhsIToken(5); //#line 4052 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(nf.Field(pos(), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRhsFirstTokenIndex(5)), "class"))); + setResult(nf.Field(pos(), nf.Super(pos(getLeftSpan(),getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRhsFirstTokenIndex(5)), "class"))); break; } Modified: trunk/x10.compiler/src/x10/parser/x10.g =================================================================== --- trunk/x10.compiler/src/x10/parser/x10.g 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.compiler/src/x10/parser/x10.g 2010-06-21 20:11:56 UTC (rev 14645) @@ -4034,7 +4034,7 @@ ./ | ClassName . super$sup . Identifier /.$BeginJava - setResult(nf.Field(pos(), nf.Super(pos(getRhsFirstTokenIndex($sup)), ClassName.toType()), Identifier)); + setResult(nf.Field(pos(), nf.Super(pos(getLeftSpan(),getRhsFirstTokenIndex($sup)), ClassName.toType()), Identifier)); $EndJava ./ | Primary . class$c @@ -4049,7 +4049,7 @@ ./ | ClassName . super$sup . class$c /.$BeginJava - setResult(nf.Field(pos(), nf.Super(pos(getRhsFirstTokenIndex($sup)), ClassName.toType()), nf.Id(pos(getRhsFirstTokenIndex($c)), "class"))); + setResult(nf.Field(pos(), nf.Super(pos(getLeftSpan(),getRhsFirstTokenIndex($sup)), ClassName.toType()), nf.Id(pos(getRhsFirstTokenIndex($c)), "class"))); $EndJava ./ Modified: trunk/x10.compiler/src/x10/types/constraints/CConstraint.java =================================================================== --- trunk/x10.compiler/src/x10/types/constraints/CConstraint.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.compiler/src/x10/types/constraints/CConstraint.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -298,9 +298,9 @@ return entails(otherConstraints, otherSelf, sigma); } - protected boolean entails(XTerm term, XVar self, final CConstraint sigma) throws XFailure { + protected boolean entails(XTerm term, XVar self) throws XFailure { XTerm subst = term.subst(self(), self); - return entails(subst, (CConstraint) null); + return entails(subst); } @@ -316,7 +316,7 @@ } for (XTerm term : conjuncts) { - if (! me.entails(term, self, (CConstraint) null)) + if (! me.entails(term, self)) return false; } @@ -399,10 +399,9 @@ CConstraint result = new CConstraint(); XVar resultSelf = result.self(); - CConstraint sigma = new CConstraint(); for (XTerm term : other.constraints()) { try { - if (entails(term, otherSelf, sigma)) { + if (entails(term, otherSelf)) { term = term.subst(resultSelf, otherSelf); result.addTerm(term); } Deleted: trunk/x10.constraints/src/x10/constraint/Solver.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/Solver.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.constraints/src/x10/constraint/Solver.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -1,26 +0,0 @@ -/* - * This file is part of the X10 project (http://x10-lang.org). - * - * This file is licensed to You under the Eclipse Public License (EPL); - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.opensource.org/licenses/eclipse-1.0.php - * - * (C) Copyright IBM Corporation 2006-2010. - */ - -package x10.constraint; - -import java.util.List; - -public interface Solver { - - boolean isConsistent(List<XTerm> atoms); - - boolean isValid(List<XTerm> atoms); - - boolean entails(XConstraint env, XTerm t, XConstraint sigma); - - void addDerivedEqualitiesInvolving(XConstraint c, XTerm t) throws XFailure; - -} Modified: trunk/x10.constraints/src/x10/constraint/XConstraint.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.constraints/src/x10/constraint/XConstraint.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -223,22 +223,6 @@ * @return true iff the constraint is consistent. */ public boolean consistent() { - if (consistent) { - List<XTerm> atoms = constraints(); - if (atoms.size() == 0) { - consistent = true; - } - else { - for (XTerm t : atoms) { - if (! consistent) - break; - Solver solver = t.solver(); - if (solver != null) { - consistent &= solver.isConsistent(atoms); - } - } - } - } return consistent; } @@ -400,9 +384,6 @@ return null; } - private XTerm simplify(XTerm t) { - return t; - } /** * Add t1=t2 to the constraint, unless it is inconsistent. @@ -411,14 +392,7 @@ * @param val -- t2 */ public void addBinding(XTerm left, XTerm right) throws XFailure { - if (right instanceof XEquals) { - right = simplify(right); - } - if (left instanceof XEquals) { - left = simplify(left); - } - - assert left != null; + assert left != null; assert right != null; if (!consistent) @@ -478,17 +452,8 @@ return; p = intern(t); - - addDerivedEqualities(t); } - public void addDerivedEqualities(XTerm t) throws XFailure { - Solver solver = t.solver(); - if (solver != null) { - solver.addDerivedEqualitiesInvolving(this, t); - } - } - public XConstraint addBindingPromise(XTerm t1, XPromise p) { try { assert t1 != null; @@ -519,16 +484,6 @@ * @return */ public boolean entails(XConstraint other) { - return entails(other, (XConstraint) null); - } - - /** - * Does this entail constraint other in environment sigma? - * - * @param t - * @return - */ - public boolean entails(XConstraint other, XConstraint sigma) { if (!consistent()) return true; if (other == null || other.valid()) @@ -537,7 +492,7 @@ // return true; List<XTerm> otherConstraints = other.extConstraints(); for (XTerm t : otherConstraints) - if (! entails(t, sigma)) + if (! entails(t)) return false; return true; } @@ -702,31 +657,18 @@ * @return */ public boolean equiv(XConstraint other) throws XFailure { - return equiv(other, null); - } - - /** - * Does this entail c, and c entail this, given sigma - * - * @param t - * @return sigma, c |- this and sigma, this |- c - */ - public boolean equiv(XConstraint other, XConstraint sigma){ - boolean result = entails(other, sigma); + boolean result = entails(other); if (result) { if (other == null) result = valid; else - result = other.entails(this, sigma); + result = other.entails(this); } return result; } /** Return true if this constraint entails t. */ public boolean entails(XTerm t) { - return entails(t, (XConstraint) null); - } - protected boolean entails(XTerm t, XConstraint sigma) { if (t instanceof XEquals) { XEquals f = (XEquals) t; XTerm left = f.left(); @@ -780,20 +722,7 @@ } return false; } - - if (t.solver() != null) { - if (t.solver().entails(this, t, sigma)) - return true; - } - List<XTerm> atoms = constraints(); - for (XTerm ta : atoms) { - if (ta.solver() != null && ta.solver() != t.solver()) { - if (ta.solver().entails(this, t, sigma)) - return true; - } - } - return false; } Modified: trunk/x10.constraints/src/x10/constraint/XPromise_c.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.constraints/src/x10/constraint/XPromise_c.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -125,17 +125,11 @@ if (visited.contains(p)) continue; visited.add(p); - if (p.term() instanceof XField) { - XField f = (XField) p.term(); - XName field = f.field(); - if (field.equals(key)) - p.setTerm(XConstraint.makeField(term, field), visited); - else - System.out.println(term + "." + key + " = " + p + " (different field)"); - } - else { - System.out.println(term + "." + key + " = " + p + " (not a field)"); - } + assert p.term() instanceof XField : term + "." + key + " = " + p + " (not a field)"; + XField f = (XField) p.term(); + XName field = f.field(); + assert field.equals(key) : term + "." + key + " = " + p + " (different field)"; + p.setTerm(XConstraint.makeField(term, field), visited); } } } Modified: trunk/x10.constraints/src/x10/constraint/XTerm.java =================================================================== --- trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-06-21 18:43:31 UTC (rev 14644) +++ trunk/x10.constraints/src/x10/constraint/XTerm.java 2010-06-21 20:11:56 UTC (rev 14645) @@ -32,10 +32,6 @@ // The default is OBJECT. May be overridden by subclasses. public XTermKind kind() { return XTermKind.OBJECT;} - public Solver solver() { - return null; - } - public final XTerm subst(XTerm y, XVar x) { return subst(y, x, true); } Added: trunk/x10.tests/examples/Issues/XTENLANG_1473.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1473.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_1473.x10 2010-06-21 20:11:56 UTC (rev 14645) @@ -0,0 +1,52 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author yoav + */ + +public class XTENLANG_1473 extends x10Test { + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_1473().execute(); + } + + static class Super { + val x = 4; + } + static class Sub extends Super { + val y = x; + val z = super.x; + val w = this.x; + } + + static class BarSuper { + val i = 4; + } + static class Bar extends BarSuper { + class Super { + val x = 4; + } + class Sub extends Super { + val y = x; + val z = super.x; + val w = this.x; + val i1 = at (Bar.this) Bar.super.i; + val i2 = at (Bar.this) Bar.this.i; + } + } +} \ No newline at end of file Property changes on: trunk/x10.tests/examples/Issues/XTENLANG_1473.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-24 00:16:11
|
Revision: 14657 http://x10.svn.sourceforge.net/x10/?rev=14657&view=rev Author: yzibin Date: 2010-06-24 00:16:01 +0000 (Thu, 24 Jun 2010) Log Message: ----------- Some refactoring, and fixed XTENLANG-1476 and XTENLANG-1462 Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java trunk/x10.compiler/src/x10/ast/X10Call_c.java trunk/x10.compiler/src/x10/ast/X10Disamb_c.java trunk/x10.compiler/src/x10/ast/X10NodeFactory.java trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/parser/X10ParsedName.java trunk/x10.compiler/src/x10/parser/X10Parser.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/util/RunTestSuite.java Added Paths: ----------- trunk/x10.tests/examples/Issues/XTENLANG_1462.x10 Modified: trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/TypeParamNode_c.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -104,8 +104,8 @@ } public void addDecls(Context c) { - X10Context xc = (X10Context) c; - c.addNamed((Named) type()); + if (type!=null) + c.addNamed(type); } public Node visitChildren(NodeVisitor v) { Modified: trunk/x10.compiler/src/x10/ast/X10Call_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/X10Call_c.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -268,7 +268,7 @@ otn = nf.AmbMacroTypeNode(position(), r, name(), typeArguments(), Collections.EMPTY_LIST); } else { - otn = nf.X10AmbTypeNode(position(), r, name()); + otn = nf.AmbTypeNode(position(), r, name()); } otn = otn.typeRef(Types.lazyRef(ts.unknownType(position()))); Modified: trunk/x10.compiler/src/x10/ast/X10Disamb_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Disamb_c.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/X10Disamb_c.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -38,6 +38,7 @@ import polyglot.types.Type; import polyglot.types.Types; import polyglot.types.VarInstance; +import polyglot.types.CodeDef; import polyglot.util.Position; import polyglot.visit.ContextVisitor; import x10.extension.X10Del; @@ -89,7 +90,7 @@ catch (SemanticException ex) { } - if (fi != null && vi instanceof FieldInstance) { + if (fi != null && vi instanceof FieldInstance && !c.inStaticContext()) { Receiver e = makeMissingFieldTarget((FieldInstance) vi); throw new SemanticException("Ambiguous reference to field " + this.name + "; both self." + name + " and " + e + "." + name + " match.", pos); } Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -64,8 +64,6 @@ AtStmt AtStmt(Position pos, Expr place, Stmt body); AtExpr AtExpr(Position pos, Expr place, TypeNode returnType, Block body); - X10AmbQualifierNode X10AmbQualifierNode(Position pos, Prefix prefix, Id name); - X10AmbTypeNode X10AmbTypeNode(Position pos, Prefix prefix, Id name); ConstructorCall X10ConstructorCall(Position pos, ConstructorCall.Kind kind, Expr outer, List<TypeNode> typeArgs, List<Expr> args); ConstructorCall X10ThisCall(Position pos, Expr outer, List<TypeNode> typeArgs, List<Expr> args); Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -167,32 +167,20 @@ return n; } - public AmbTypeNode AmbTypeNode(Position pos, Prefix qualifier, Id name) { - X10AmbTypeNode_c n = new X10AmbTypeNode_c(pos, qualifier, name); - n = (X10AmbTypeNode_c)n.ext(extFactory().extAmbTypeNode()); - n = (X10AmbTypeNode_c)n.del(delFactory().delAmbTypeNode()); + public X10AmbTypeNode AmbTypeNode(Position pos, Prefix p, Id name) { + X10AmbTypeNode_c n = new X10AmbTypeNode_c(pos, p, name); + n = (X10AmbTypeNode_c) n.ext(extFactory().extAmbTypeNode()); + n = (X10AmbTypeNode_c) n.del(delFactory().delAmbTypeNode()); return n; } - public X10AmbTypeNode X10AmbTypeNode(Position pos, Prefix prefix, Id name) { - X10AmbTypeNode_c n = new X10AmbTypeNode_c(pos, prefix, name); - n = (X10AmbTypeNode_c) n.ext(extFactory().extAmbTypeNode()); - n = (X10AmbTypeNode_c) n.del(delFactory().delAmbTypeNode()); - return n; - } - public AmbQualifierNode AmbQualifierNode(Position pos, Prefix prefix, Id name) { + public X10AmbQualifierNode AmbQualifierNode(Position pos, Prefix prefix, Id name) { X10AmbQualifierNode_c n = new X10AmbQualifierNode_c(pos, prefix, name); n = (X10AmbQualifierNode_c) n.ext(extFactory().extAmbQualifierNode()); n = (X10AmbQualifierNode_c) n.del(delFactory().delAmbQualifierNode()); return n; } - public X10AmbQualifierNode X10AmbQualifierNode(Position pos, Prefix prefix, Id name) { - X10AmbQualifierNode_c n = new X10AmbQualifierNode_c(pos, prefix, name); - n = (X10AmbQualifierNode_c) n.ext(extFactory().extAmbQualifierNode()); - n = (X10AmbQualifierNode_c) n.del(delFactory().delAmbQualifierNode()); - return n; - } public UnknownTypeNode UnknownTypeNode(Position pos) { UnknownTypeNode_c n = new UnknownTypeNode_c(pos); Modified: trunk/x10.compiler/src/x10/ast/X10Special_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/ast/X10Special_c.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -138,9 +138,7 @@ if (t == null || (c.inStaticContext() && ts.typeEquals(t, c.currentClass(), c))) { // trying to access "this" or "super" from a static context. - throw new SemanticException("Cannot access a non-static " + - "field or method, or refer to \"this\" or \"super\" " + - "from a static context.", this.position()); + throw new SemanticException("Cannot access a non-static field or method, or refer to \"this\" or \"super\" from a static context.", this.position()); } X10Special result = this; Modified: trunk/x10.compiler/src/x10/parser/X10ParsedName.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10ParsedName.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/parser/X10ParsedName.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -36,7 +36,7 @@ return nf.AmbQualifierNode(pos, name); } - return nf.X10AmbQualifierNode(pos, prefix.toPrefix(), name); + return nf.AmbQualifierNode(pos, prefix.toPrefix(), name); } @@ -47,6 +47,6 @@ return nf.AmbTypeNode(pos, name); } - return nf.X10AmbTypeNode(pos, prefix.toPrefix(), name); + return nf.AmbTypeNode(pos, prefix.toPrefix(), name); } } Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -66,6 +66,7 @@ import polyglot.ast.TypeNode; import polyglot.ast.Unary; import polyglot.ast.FlagsNode; +import polyglot.ast.ProcedureDecl; import polyglot.parse.ParsedName; import x10.ast.AddFlags; import x10.ast.AnnotationNode; @@ -94,6 +95,7 @@ import x10.extension.X10Ext; import polyglot.frontend.FileSource; import polyglot.frontend.Parser; +import polyglot.frontend.Globals; import polyglot.lex.BooleanLiteral; import polyglot.lex.CharacterLiteral; import polyglot.lex.DoubleLiteral; @@ -1144,7 +1146,7 @@ FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { - if (!v.flags().flags().isFinal()) throw new InternalCompilerError("Type definition parameters must be final.", v.position()); + if (!v.flags().flags().isFinal()) syntaxError("Type definition parameters must be final.", v.position()); } TypeDecl cd = nf.TypeDecl(pos(), f, Identifier, TypeParametersopt, FormalParametersopt, WhereClauseopt, Type); cd = (TypeDecl) ((X10Ext) cd.ext()).annotations(annotations); @@ -1156,27 +1158,7 @@ // Rule 17: TypeDefDeclaration ::= TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt ; // case 17: { - //#line 937 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 935 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - List TypeDefModifiersopt = (List) getRhsSym(1); - //#line 935 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - Id Identifier = (Id) getRhsSym(3); - //#line 935 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - List TypeParametersopt = (List) getRhsSym(4); - //#line 935 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - List FormalParametersopt = (List) getRhsSym(5); - //#line 935 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 937 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - FlagsNode f = extractFlags(TypeDefModifiersopt); - List annotations = extractAnnotations(TypeDefModifiersopt); - for (Formal v : (List<Formal>) FormalParametersopt) { - if (!v.flags().flags().isFinal()) throw new InternalCompilerError("Type definition parameters must be final.", v.position()); - } - TypeDecl cd = nf.TypeDecl(pos(), f, Identifier, TypeParametersopt, FormalParametersopt, WhereClauseopt, null); - cd = (TypeDecl) ((X10Ext) cd.ext()).annotations(annotations); - setResult(cd); - break; + syntaxError("Type definition is missing '= Type'",pos()); } // @@ -1261,10 +1243,11 @@ //#line 976 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(10); //#line 978 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" + ProcedureDecl pd; if (Identifier.id().toString().equals("this")) { - ConstructorDecl cd = nf.X10ConstructorDecl(pos(), + pd = nf.X10ConstructorDecl(pos(), extractFlags(MethodModifiersopt), - nf.Id(pos(getRhsFirstTokenIndex(3)), "this"), + Identifier, HasResultTypeopt, TypeParametersopt, FormalParameters, @@ -1272,11 +1255,9 @@ Throwsopt, Offersopt, MethodBody); - cd = (ConstructorDecl) ((X10Ext) cd.ext()).annotations(extractAnnotations(MethodModifiersopt)); - setResult(cd); } else { - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(10)), + pd = nf.X10MethodDecl(pos(), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, Identifier, @@ -1286,9 +1267,9 @@ Throwsopt, Offersopt, MethodBody); - md = (MethodDecl) ((X10Ext) md.ext()).annotations(extractAnnotations(MethodModifiersopt)); - setResult(md); } + pd = (ProcedureDecl) ((X10Ext) pd.ext()).annotations(extractAnnotations(MethodModifiersopt)); + setResult(pd); break; } @@ -1318,7 +1299,7 @@ //#line 1008 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(15); //#line 1010 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex(1), getRhsLastTokenIndex(15)), + MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex(7)), X10Binary_c.binaryMethodName(BinOp)), @@ -1954,7 +1935,7 @@ //#line 1302 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" AddFlags tn = (AddFlags) ConstrainedType; tn.addFlags(X10Flags.PROTO); - setResult(tn); + setResult(ConstrainedType.position(pos())); break; } @@ -2024,7 +2005,7 @@ //#line 1341 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" DepParameterExpr DepParametersopt = (DepParameterExpr) getRhsSym(6); //#line 1343 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - TypeNode type = nf.X10AmbTypeNode(pos(), Primary, Identifier); + TypeNode type = nf.AmbTypeNode(pos(), Primary, Identifier); // TODO: place constraint if (DepParametersopt != null || (TypeArgumentsopt != null && ! TypeArgumentsopt.isEmpty()) || (Argumentsopt != null && ! Argumentsopt.isEmpty())) { type = nf.AmbDepTypeNode(pos(), Primary, Identifier, TypeArgumentsopt, Argumentsopt, DepParametersopt); @@ -2301,7 +2282,7 @@ X10Formal FormalParameter = (X10Formal) getRhsSym(1); //#line 1481 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" List l = new TypedList(new LinkedList(), Formal.class, false); - l.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); + l.add(FormalParameter.flags(nf.FlagsNode(Position.COMPILER_GENERATED, Flags.FINAL))); setResult(l); break; } @@ -2316,7 +2297,7 @@ //#line 1486 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(3); //#line 1488 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - ExistentialList.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); + ExistentialList.add(FormalParameter.flags(nf.FlagsNode(Position.COMPILER_GENERATED, Flags.FINAL))); break; } @@ -2651,24 +2632,7 @@ //#line 1712 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" //#line 1710 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" Expr StatementExpression = (Expr) getRhsSym(1); - //#line 1712 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - boolean eval = true; - if (StatementExpression instanceof X10Call) { - X10Call c = (X10Call) StatementExpression; - if (c.name().id().toString().equals("property") && c.target() == null) { - setResult(nf.AssignPropertyCall(c.position(),c.typeArguments(), c.arguments())); - eval = false; - } - if (c.name().id().toString().equals("super") && c.target() instanceof Expr) { - setResult(nf.X10SuperCall(c.position(), (Expr) c.target(), c.typeArguments(), c.arguments())); - eval = false; - } - if (c.name().id().toString().equals("this") && c.target() instanceof Expr) { - setResult(nf.X10ThisCall(c.position(), (Expr) c.target(), c.typeArguments(), c.arguments())); - eval = false; - } - } - + //#line 1712 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Eval(pos(), StatementExpression)); break; } @@ -6430,16 +6394,7 @@ // Rule 437: Primary ::= TypeName . class // case 437: { - //#line 3716 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 3714 "C:/eclipsews/head5/x10.compiler/src/x10/parser/x10.g" - ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 3716 "C:/eclipsews/head5/lpg.generator/templates/java/btParserTemplateF.gi" - if (TypeName instanceof ParsedName) - { - ParsedName a = (ParsedName) TypeName; - setResult(nf.ClassLit(pos(), a.toType())); - } - else assert(false); + assert(false); break; } Modified: trunk/x10.compiler/src/x10/parser/x10.g =================================================================== --- trunk/x10.compiler/src/x10/parser/x10.g 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/parser/x10.g 2010-06-24 00:16:01 UTC (rev 14657) @@ -925,25 +925,13 @@ FlagsNode f = extractFlags(TypeDefModifiersopt); List annotations = extractAnnotations(TypeDefModifiersopt); for (Formal v : (List<Formal>) FormalParametersopt) { - if (!v.flags().flags().isFinal()) throw new InternalCompilerError("Type definition parameters must be final.", v.position()); + if (!v.flags().flags().isFinal()) syntaxError("Type definition parameters must be final.", v.position()); } TypeDecl cd = nf.TypeDecl(pos(), f, Identifier, TypeParametersopt, FormalParametersopt, WhereClauseopt, Type); cd = (TypeDecl) ((X10Ext) cd.ext()).annotations(annotations); setResult(cd); $EndJava ./ - | TypeDefModifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt ; - /.$BeginJava - FlagsNode f = extractFlags(TypeDefModifiersopt); - List annotations = extractAnnotations(TypeDefModifiersopt); - for (Formal v : (List<Formal>) FormalParametersopt) { - if (!v.flags().flags().isFinal()) throw new InternalCompilerError("Type definition parameters must be final.", v.position()); - } - TypeDecl cd = nf.TypeDecl(pos(), f, Identifier, TypeParametersopt, FormalParametersopt, WhereClauseopt, null); - cd = (TypeDecl) ((X10Ext) cd.ext()).annotations(annotations); - setResult(cd); - $EndJava - ./ Properties ::= ( PropertyList ) /.$BeginJava @@ -975,10 +963,11 @@ MethodDeclaration ::= MethodModifiersopt def Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava + ProcedureDecl pd; if (Identifier.id().toString().equals("this")) { - ConstructorDecl cd = nf.X10ConstructorDecl(pos(), + pd = nf.X10ConstructorDecl(pos(), extractFlags(MethodModifiersopt), - nf.Id(pos(getRhsFirstTokenIndex(3)), "this"), + Identifier, HasResultTypeopt, TypeParametersopt, FormalParameters, @@ -986,11 +975,10 @@ Throwsopt, Offersopt, MethodBody); - cd = (ConstructorDecl) ((X10Ext) cd.ext()).annotations(extractAnnotations(MethodModifiersopt)); - setResult(cd); + } else { - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + pd = nf.X10MethodDecl(pos(), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, Identifier, @@ -1000,14 +988,14 @@ Throwsopt, Offersopt, MethodBody); - md = (MethodDecl) ((X10Ext) md.ext()).annotations(extractAnnotations(MethodModifiersopt)); - setResult(md); } + pd = (ProcedureDecl) ((X10Ext) pd.ext()).annotations(extractAnnotations(MethodModifiersopt)); + setResult(pd); $EndJava ./ | MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex($BinOp)), X10Binary_c.binaryMethodName(BinOp)), @@ -1025,7 +1013,7 @@ ./ | MethodModifiersopt operator TypeParametersopt PrefixOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex($PrefixOp)), X10Unary_c.unaryMethodName(PrefixOp)), @@ -1043,7 +1031,7 @@ ./ | MethodModifiersopt operator TypeParametersopt this BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex($BinOp)), X10Binary_c.binaryMethodName(BinOp)), @@ -1063,7 +1051,7 @@ | MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp this WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava Name op = X10Binary_c.invBinaryMethodName(BinOp); - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex($BinOp)), X10Binary_c.invBinaryMethodName(BinOp)), @@ -1082,7 +1070,7 @@ ./ | MethodModifiersopt operator TypeParametersopt PrefixOp this WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(getRhsFirstTokenIndex($PrefixOp)), X10Unary_c.unaryMethodName(PrefixOp)), @@ -1100,7 +1088,7 @@ ./ | MethodModifiersopt operator this TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(), Name.make("apply")), @@ -1118,7 +1106,7 @@ ./ | MethodModifiersopt operator this TypeParametersopt FormalParameters = ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(), Name.make("set")), @@ -1136,7 +1124,7 @@ ./ | MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as Type WhereClauseopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), Type, nf.Id(pos(), Converter.operator_as), @@ -1154,7 +1142,7 @@ ./ | MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as ? WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(), Converter.operator_as), @@ -1172,7 +1160,7 @@ ./ | MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) WhereClauseopt HasResultTypeopt Throwsopt Offersopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, nf.Id(pos(), Converter.implicit_operator_as), @@ -1189,16 +1177,16 @@ $EndJava ./ - PropertyMethodDeclaration ::= MethodModifiersopt property Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Throwsopt MethodBody + PropertyMethodDeclaration ::= MethodModifiersopt property Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt, X10Flags.PROPERTY), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, Identifier, TypeParametersopt, FormalParameters, WhereClauseopt, - Throwsopt, + Collections.EMPTY_LIST, null, // offersOpt MethodBody); md = (MethodDecl) ((X10Ext) md.ext()).annotations(extractAnnotations(MethodModifiersopt)); @@ -1207,7 +1195,7 @@ ./ | MethodModifiersopt property Identifier WhereClauseopt HasResultTypeopt MethodBody /.$BeginJava - MethodDecl md = nf.X10MethodDecl(pos(getRhsFirstTokenIndex($MethodModifiersopt), getRhsLastTokenIndex($MethodBody)), + MethodDecl md = nf.X10MethodDecl(pos(pos()), extractFlags(MethodModifiersopt, X10Flags.PROPERTY), HasResultTypeopt == null ? nf.UnknownTypeNode(pos()) : HasResultTypeopt, Identifier, @@ -1301,7 +1289,7 @@ /.$BeginJava AddFlags tn = (AddFlags) ConstrainedType; tn.addFlags(X10Flags.PROTO); - setResult(tn); + setResult(ConstrainedType.position(pos())); $EndJava ./ @@ -1340,7 +1328,7 @@ NamedType ::= Primary . Identifier TypeArgumentsopt Argumentsopt DepParametersopt /.$BeginJava - TypeNode type = nf.X10AmbTypeNode(pos(), Primary, Identifier); + TypeNode type = nf.AmbTypeNode(pos(), Primary, Identifier); // TODO: place constraint if (DepParametersopt != null || (TypeArgumentsopt != null && ! TypeArgumentsopt.isEmpty()) || (Argumentsopt != null && ! Argumentsopt.isEmpty())) { type = nf.AmbDepTypeNode(pos(), Primary, Identifier, TypeArgumentsopt, Argumentsopt, DepParametersopt); @@ -1479,13 +1467,13 @@ ExistentialList ::= FormalParameter /.$BeginJava List l = new TypedList(new LinkedList(), Formal.class, false); - l.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); + l.add(FormalParameter.flags(nf.FlagsNode(Position.COMPILER_GENERATED, Flags.FINAL))); setResult(l); $EndJava ./ | ExistentialList ; FormalParameter /.$BeginJava - ExistentialList.add(FormalParameter.flags(nf.FlagsNode(pos(), Flags.FINAL))); + ExistentialList.add(FormalParameter.flags(nf.FlagsNode(Position.COMPILER_GENERATED, Flags.FINAL))); $EndJava ./ @@ -1709,23 +1697,6 @@ ExpressionStatement ::= StatementExpression ; /.$BeginJava - boolean eval = true; - if (StatementExpression instanceof X10Call) { - X10Call c = (X10Call) StatementExpression; - if (c.name().id().toString().equals("property") && c.target() == null) { - setResult(nf.AssignPropertyCall(c.position(),c.typeArguments(), c.arguments())); - eval = false; - } - if (c.name().id().toString().equals("super") && c.target() instanceof Expr) { - setResult(nf.X10SuperCall(c.position(), (Expr) c.target(), c.typeArguments(), c.arguments())); - eval = false; - } - if (c.name().id().toString().equals("this") && c.target() instanceof Expr) { - setResult(nf.X10ThisCall(c.position(), (Expr) c.target(), c.typeArguments(), c.arguments())); - eval = false; - } - } - setResult(nf.Eval(pos(), StatementExpression)); $EndJava ./ @@ -3711,16 +3682,6 @@ -- Chapter 15 Primary ::= Literal - | TypeName . class - /.$BeginJava - if (TypeName instanceof ParsedName) - { - ParsedName a = (ParsedName) TypeName; - setResult(nf.ClassLit(pos(), a.toType())); - } - else assert(false); - $EndJava - ./ | self /.$BeginJava setResult(nf.Self(pos())); Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-23 20:11:44 UTC (rev 14656) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-06-24 00:16:01 UTC (rev 14657) @@ -26,12 +26,14 @@ // Inside those files we should have "ERR" markers that we use to test the position of the errors is correct. //_MustFailTimeout means that when running the file it will have an infinite loop private static final String[] EXCLUDE_FILES_WITH_SUFFIX = { - "_DYNAMIC_CALLS.x10", + "_DYNAMIC_CALLS.x10","_MustFailCompile.x10", }; private static final String[] EXCLUDE_FILES = { }; private static final String[] EXCLUDE_FILES_WITH = { - "TypedefOverloading","NQueens" + "TypedefOverloading","NQueens", + "PlaceCheckArray.x10", + "XTENLANG_106.x10","XTENLANG_111.x10","XTENLANG_217.x10","XTENLANG_62.x10" }; private static final String[] INCLUDE_ONLY_FILES_WITH = { //"_MustFailCompile.x10", Added: trunk/x10.tests/examples/Issues/XTENLANG_1462.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1462.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_1462.x10 2010-06-24 00:16:01 UTC (rev 14657) @@ -0,0 +1,41 @@ +/* + * This file is part of the X10 project (http://x10-lang.org). + * + * This file is licensed to You under the Eclipse Public License (EPL); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.opensource.org/licenses/eclipse-1.0.php + * + * (C) Copyright IBM Corporation 2006-2010. + */ + +import harness.x10Test; + +/** + * @author yoav + */ + +public class XTENLANG_1462 extends x10Test { + + public def run(): boolean { + return true; + } + + public static def main(Rail[String]) { + new XTENLANG_1462().execute(); + } + + + static class Bar(p:Int) { + def this(q:Int):Bar{self.p==q} { + property(q); + } + static def test(z:Bar{p==3}) { + val b:Bar{p==3} = new Bar(3); + } + def membertest(z:Bar{self.p==3}) {p==2} { + val b:Bar{self.p==3} = new Bar(3); + } + } + +} \ No newline at end of file Property changes on: trunk/x10.tests/examples/Issues/XTENLANG_1462.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-06-24 18:53:15
|
Revision: 14667 http://x10.svn.sourceforge.net/x10/?rev=14667&view=rev Author: yzibin Date: 2010-06-24 18:53:09 +0000 (Thu, 24 Jun 2010) Log Message: ----------- small refactoring, added a check in ValHashMap.x10 Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/X10Disamb_c.java trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 Modified: trunk/x10.compiler/src/x10/ast/X10Disamb_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10Disamb_c.java 2010-06-24 18:02:05 UTC (rev 14666) +++ trunk/x10.compiler/src/x10/ast/X10Disamb_c.java 2010-06-24 18:53:09 UTC (rev 14667) @@ -94,8 +94,6 @@ Receiver e = makeMissingFieldTarget((FieldInstance) vi); throw new SemanticException("Ambiguous reference to field " + this.name + "; both self." + name + " and " + e + "." + name + " match.", pos); } - - Expr prop = null; if (fi instanceof X10FieldInstance) { X10FieldInstance xfi = (X10FieldInstance) fi; @@ -104,7 +102,6 @@ f = f.fieldInstance(xfi); Type ftype = X10Field_c.rightType(xfi.rightType(), xfi.x10Def(), f.target(), c); f = (Field) f.type(ftype); - prop = f; return f; } else { @@ -120,15 +117,11 @@ if (vi != null) { Node n = disambiguateVarInstance(vi); - if (n != null && prop != null) - throw new SemanticException("Reference to field or property " + name + " is ambiguous; both " + prop + " and " + n + " match.", pos); if (n != null) return n; } - - if (prop != null) - return prop; + // Now try 0-ary property methods. try { X10MethodInstance mi = ts.findMethod(t, ts.MethodMatcher(t, this.name.id(), Collections.EMPTY_LIST, c)); @@ -233,7 +226,6 @@ Type t = e.type(); X10Context xc = (X10Context) this.c; - X10TypeSystem xts = (X10TypeSystem) ts; // If in a class header, don't search the supertypes of this class. if (xc.inSuperTypeDeclaration()) { @@ -373,7 +365,6 @@ } else { // The field is non-static, so we must prepend with self. - X10Context xc = (X10Context) c; Expr e = ((X10NodeFactory) nf).Self(pos); e = e.type(currentDepType); Modified: trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 2010-06-24 18:02:05 UTC (rev 14666) +++ trunk/x10.runtime/src-x10/x10/util/ValHashMap.x10 2010-06-24 18:53:09 UTC (rev 14667) @@ -16,7 +16,8 @@ var hashMap:HashMap[Key,Value]! = new HashMap[Key,Value](); val entries:Iterable[Map.Entry[Key,Value]!] = map.entries(); for (val entry:Map.Entry[Key,Value]! in entries) - hashMap.put(entry.getKey(), entry.getValue()); + if (entry!=null) + hashMap.put(entry.getKey(), entry.getValue()); return make(hashMap); } public static def make[Key,Value](map:HashMap[Key,Value]!):ValHashMap[Key,Value] { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-06-27 19:02:15
|
Revision: 14695 http://x10.svn.sourceforge.net/x10/?rev=14695&view=rev Author: ipeshansky Date: 2010-06-27 19:02:09 +0000 (Sun, 27 Jun 2010) Log Message: ----------- Move the X10 bytecode backend work from the trunk to the x10-bytecode-backend branch. Modified Paths: -------------- trunk/x10.compiler/META-INF/MANIFEST.MF trunk/x10.compiler/build.xml Removed Paths: ------------- trunk/x10.compiler/src/x10bc/ trunk/x10.dist/bin/x10bc Modified: trunk/x10.compiler/META-INF/MANIFEST.MF =================================================================== --- trunk/x10.compiler/META-INF/MANIFEST.MF 2010-06-27 18:30:58 UTC (rev 14694) +++ trunk/x10.compiler/META-INF/MANIFEST.MF 2010-06-27 19:02:09 UTC (rev 14695) @@ -23,7 +23,6 @@ x10.util, x10.util.synthesizer, x10.visit, - x10bc, x10cpp, x10cpp.ast, x10cpp.debug, Modified: trunk/x10.compiler/build.xml =================================================================== --- trunk/x10.compiler/build.xml 2010-06-27 18:30:58 UTC (rev 14694) +++ trunk/x10.compiler/build.xml 2010-06-27 19:02:09 UTC (rev 14695) @@ -15,13 +15,11 @@ <property name="config" value="*.cfg"/> <property name="lpg.jar" value="lpg.jar"/> <property name="polyglot.jar" value="polyglot3.jar"/> - <property name="polyglot.bytecode.jar" value="polyglot-bytecode.jar"/> <property name="asm.jar" value="asm.jar"/> <path id="project.classpath"> <path refid="mainproject.classpath"/> <path refid="lpg.classpath"/> <path refid="polyglot.classpath"/> - <path refid="polyglot.bytecode.classpath"/> <path refid="asm.classpath"/> <path refid="x10.constraints.classpath"/> <path refid="x10.common.classpath"/> @@ -35,9 +33,6 @@ <path id="polyglot.classpath"> <pathelement location="${lib}/${polyglot.jar}"/> </path> - <path id="polyglot.bytecode.classpath"> - <pathelement location="${lib}/${polyglot.bytecode.jar}"/> - </path> <path id="asm.classpath"> <pathelement location="${lib}/${asm.jar}"/> </path> @@ -67,7 +62,7 @@ </copy> </target> <target name="check-jar" depends="init"> - <fileset id="compiler.classes" dir="${build}" includes="org/**,x10/**,x10bc/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/> + <fileset id="compiler.classes" dir="${build}" includes="org/**,x10/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/> <fileset id="constraints.classes" dir="${x10.constraints.location}/classes" includes="x10/constraint/**" excludes="x10/constraint/test/**"/> <fileset id="common.classes" dir="${x10.common.location}/classes" includes="x10/**"/> <uptodate property="compiler.uptodate" targetfile="${build}/${jar}"> @@ -82,7 +77,7 @@ <fileset refid="compiler.classes"/> <fileset refid="constraints.classes"/> <fileset refid="common.classes"/> - <!--<fileset dir="${build}" includes="org/**,x10/**,x10bc/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/>--> + <!--<fileset dir="${build}" includes="org/**,x10/**,x10cpp/**,x10c/**,x10cuda/**,data/**" excludes="${jar}"/>--> <!--<fileset dir="${x10.constraints.location}/classes" includes="x10/constraint/**" excludes="x10/constraint/test/**"/>--> <!--<fileset dir="${x10.common.location}/classes" includes="x10/**"/>--> </jar> @@ -99,7 +94,7 @@ </target> <target name="build" depends="init,prereq-jars"> <echo message="${ant.project.name}: ${ant.file}"/> - <javac destdir="${build}" source="1.5" target="1.5" debug="on" includes="x10/**,x10bc/**,x10c/**,x10cpp/**,x10cuda/**" excludes="polyglot/ext/x10/dom/**,polyglot/ext/x10/plugin/**,polyglot/ext/x10/visit/Propagate*AnnotationsVisitor.java"> + <javac destdir="${build}" source="1.5" target="1.5" debug="on" includes="x10/**,x10c/**,x10cpp/**,x10cuda/**" excludes="polyglot/ext/x10/dom/**,polyglot/ext/x10/plugin/**,polyglot/ext/x10/visit/Propagate*AnnotationsVisitor.java"> <src path="${src}"/> <classpath refid="project.classpath"/> </javac> Deleted: trunk/x10.dist/bin/x10bc =================================================================== --- trunk/x10.dist/bin/x10bc 2010-06-27 18:30:58 UTC (rev 14694) +++ trunk/x10.dist/bin/x10bc 2010-06-27 19:02:09 UTC (rev 14695) @@ -1,24 +0,0 @@ -#!/bin/bash - -# If X10_FROM_SRC is set in your environment, then -# this script will default to using paths that assume -# the standard X10 developer setup and a desire to build from source. -# If it is not set, then the script will use paths that are -# appropriate for a pre-built distribution of x10. - -UNAME=`uname -s` -FILE_SEP='/'; if [[ "$UNAME" = CYGWIN* ]]; then FILE_SEP='\\'; fi -PATH_SEP=':'; if [[ "$UNAME" = CYGWIN* ]]; then PATH_SEP=';'; fi - -prog=$(readlink $0 2>&1) -[ $? -eq 127 -o "$prog" = "" ] && prog="$0" -export X10_DIST="$(cd "$(dirname "$prog")/.." && pwd)" -if [[ "$UNAME" = CYGWIN* ]]; then X10_DIST="$(cygpath -aw "$X10_DIST")"; fi - -[ -z "$X10SOURCES" ] && export X10SOURCES="${X10_DIST}/lib/x10.jar" - -export CP_OVERRIDE="${X10_DIST}${FILE_SEP}lib${FILE_SEP}x10c.jar${PATH_SEP}${X10_DIST}${FILE_SEP}classes${PATH_SEP}" -export DEXT="x10bc.ExtensionInfo" - -exec "${X10_DIST}/bin/x10c" "$@" - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |