From: <yz...@us...> - 2010-08-17 16:23:24
|
Revision: 15560 http://x10.svn.sourceforge.net/x10/?rev=15560&view=rev Author: yzibin Date: 2010-08-17 16:23:16 +0000 (Tue, 17 Aug 2010) Log Message: ----------- Fixed XTENLANG-1666 Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/ParExpr_c.java trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java trunk/x10.compiler/src/x10/util/RunTestSuite.java trunk/x10.compiler/src/x10/visit/X10InitChecker.java trunk/x10.dist/samples/tutorial/HeatTransfer_v0.x10 trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField.x10 trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 trunk/x10.tests/examples/Misc/FinalInitializationTest.x10 Added Paths: ----------- trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10.aside trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField1.x10 trunk/x10.tests/examples/Issues/XTENLANG_1666.x10 Removed Paths: ------------- trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10 trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CF1.x10 Modified: trunk/x10.compiler/src/x10/ast/ParExpr_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ParExpr_c.java 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.compiler/src/x10/ast/ParExpr_c.java 2010-08-17 16:23:16 UTC (rev 15560) @@ -17,6 +17,7 @@ import polyglot.ast.Node; import polyglot.ast.Term; import polyglot.ast.Expr_c; +import polyglot.ast.Unary; import polyglot.types.SemanticException; import polyglot.util.CodeWriter; import polyglot.util.Position; @@ -24,6 +25,7 @@ import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; import polyglot.visit.PrettyPrinter; +import polyglot.visit.FlowGraph; /** * @author vj Feb 4, 2005 @@ -92,11 +94,18 @@ /* (non-Javadoc) * @see polyglot.ast.Term#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) + * todo Yoav: I just copied it from Unary_c. I think that ParExpr_c should inherit from Unary_c, and we should define Unary.Operator.IDEMPOTENT. */ - public List acceptCFG(CFGBuilder v, List succs) { - v.visitCFG( expr, this, EXIT); - return succs; - } + public List<Term> acceptCFG(CFGBuilder v, List<Term> succs) { + if (expr.type().isBoolean()) { + v.visitCFG(expr, FlowGraph.EDGE_KEY_TRUE, this, + EXIT, FlowGraph.EDGE_KEY_FALSE, this, EXIT); + } else { + v.visitCFG(expr, this, EXIT); + } + + return succs; + } public String toString() { return "(" + expr.toString() + ")"; } Modified: trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.compiler/src/x10/ast/X10ClassDecl_c.java 2010-08-17 16:23:16 UTC (rev 15560) @@ -88,6 +88,7 @@ import x10.types.constraints.TypeConstraint; import x10.util.Synthesizer; import x10.visit.ChangePositionVisitor; +import x10.visit.CheckEscapingThis; /** * The same as a Java class, except that it needs to handle properties. @@ -705,7 +706,9 @@ } n.checkStructMethods(parent, tc); } - + + if (false) + new CheckEscapingThis(this,tc.job(),tc.typeSystem()).typeCheck(); return n; } Modified: trunk/x10.compiler/src/x10/util/RunTestSuite.java =================================================================== --- trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.compiler/src/x10/util/RunTestSuite.java 2010-08-17 16:23:16 UTC (rev 15560) @@ -32,9 +32,9 @@ "NOT_WORKING","SSCA2","FT-alltoall","FT-global" }; private static final String[] EXCLUDE_FILES_WITH = { - "TypedefOverloading","NQueens", + "HeatTransfer_v0.x10", + "TypedefOverloading", "PlaceCheckArray.x10", - "XTENLANG_106.x10","XTENLANG_111.x10","XTENLANG_217.x10","XTENLANG_62.x10" }; private static final String[] INCLUDE_ONLY_FILES_WITH = { //"_MustFailCompile.x10", @@ -69,7 +69,7 @@ * E.g., * C:\cygwin\home\Yoav\intellij\sourceforge\x10.runtime\src-x10 * C:\cygwin\home\Yoav\intellij\sourceforge\x10.tests - * @throws Throwable + * @throws Throwable Can be a failed assertion or missing file. */ 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"+ @@ -178,14 +178,14 @@ int warningCount = 0; for (ErrorInfo err : errors) if (err.getErrorKind()==ErrorInfo.WARNING) { - System.err.println(err); + System.err.println("Got a warning in position: "+err.getPosition()+"\nMessage: "+err+"\n"); warningCount++; } if (errors.size()>warningCount) { System.err.println("\nThe following errors did not have a matching ERR marker:\n\n"); for (ErrorInfo err : errors) if (err.getErrorKind()!=ErrorInfo.WARNING) - System.err.println("Position: "+err.getPosition()+"\nMessage: "+err+"\n"); + System.err.println("Position:\n"+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) } Modified: trunk/x10.compiler/src/x10/visit/X10InitChecker.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10InitChecker.java 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.compiler/src/x10/visit/X10InitChecker.java 2010-08-17 16:23:16 UTC (rev 15560) @@ -13,6 +13,8 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Set; import polyglot.ast.ClassBody; import polyglot.ast.ClassDecl; @@ -20,6 +22,8 @@ import polyglot.ast.New; import polyglot.ast.Node; import polyglot.ast.NodeFactory; +import polyglot.ast.Term; +import polyglot.ast.Expr; import polyglot.frontend.Job; import polyglot.types.ClassDef; import polyglot.types.SemanticException; @@ -27,7 +31,9 @@ import polyglot.util.InternalCompilerError; import polyglot.visit.InitChecker; import polyglot.visit.NodeVisitor; +import polyglot.visit.FlowGraph; import x10.ast.X10ClassDecl; +import x10.ast.ParExpr; public class X10InitChecker extends InitChecker { @@ -35,6 +41,26 @@ super(job, ts, nf); } + public Map flow(Item trueItem, Item falseItem, Item otherItem, + FlowGraph graph, Term n, boolean entry, Set succEdgeKeys) { + Item inItem = safeConfluence(trueItem, FlowGraph.EDGE_KEY_TRUE, + falseItem, FlowGraph.EDGE_KEY_FALSE, + otherItem, FlowGraph.EDGE_KEY_OTHER, + n, entry, graph); + if (entry) { + return itemToMap(inItem, succEdgeKeys); + } + if (inItem == BOTTOM) { + return itemToMap(BOTTOM, succEdgeKeys); + } + DataFlowItem inDFItem = ((DataFlowItem)inItem); + if (n instanceof ParExpr && ((ParExpr)n).type().isBoolean()) { + if (trueItem == null) trueItem = inDFItem; + if (falseItem == null) falseItem = inDFItem; + return itemsToMap(trueItem, falseItem, inDFItem, succEdgeKeys); + } + return super.flow(trueItem, falseItem, otherItem, graph,n, entry, succEdgeKeys); + } /** * Overridden superclass method. * Modified: trunk/x10.dist/samples/tutorial/HeatTransfer_v0.x10 =================================================================== --- trunk/x10.dist/samples/tutorial/HeatTransfer_v0.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.dist/samples/tutorial/HeatTransfer_v0.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -42,7 +42,7 @@ do { for (p in D) Temp(p) = stencil_1(p); - delta = A.map(Temp, (x:Real,y:Real)=>Math.abs(x-y)).reduce(Math.max.(Double,Double), 0.0); + delta = A.map[Real,Real](Temp, (x:Real,y:Real)=>Math.abs(x-y)).reduce(Math.max.(Double,Double), 0.0); for (p in D) A(p) = Temp(p); } while (delta > epsilon); Deleted: trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -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; - -/** - * - * - * @author igor - */ -public class RailAlias extends x10Test { - public def this(): RailAlias = { } - public def run(): boolean = { - val r: Region{rail} = [0..10]; - val a <: Array[double]{rail} = new Array[double](r, (x:Point)=>0.0); - val d: double = a(1); - for (val (p) in a.region) a(p) = 1.0; - return true; - } - public static def main(var a: Rail[String]): void = { - new RailAlias().execute(); - } -} Copied: trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10.aside (from rev 15385, trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10.aside (rev 0) +++ trunk/x10.tests/examples/Constructs/DepType/RailAlias.x10.aside 2010-08-17 16:23:16 UTC (rev 15560) @@ -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; + +/** + * + * + * @author igor + */ +public class RailAlias extends x10Test { + public def this(): RailAlias = { } + public def run(): boolean = { + val r: Region{rail} = [0..10]; + val a <: Array[double]{rail} = new Array[double](r, (x:Point)=>0.0); + val d: double = a(1); + for (val (p) in a.region) a(p) = 1.0; + return true; + } + public static def main(var a: Rail[String]): void = { + new RailAlias().execute(); + } +} Deleted: trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CF1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CF1.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CF1.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -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. - */ - - /** - Check that circular dependencies between classes are handled correctly - during TypeElaboration. - See CircularField.x10 - - *@author vj - * - */ - - public class CF1(i:int, j:int) { - public def this(i:int, j:int):CF1{self.i==i,self.j==j} { - property(i,j); - } - var f:CircularField{k==3} = null; - } Modified: trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -22,7 +22,7 @@ public class CircularField(k:int) extends x10Test { public def this(k:int):CircularField = { property(k);} - val h = new CF1(4,4) as CF1{i==j} ; + val h = new CircularField1(4,4) as CircularField1{i==j} ; public def run():boolean = true; public static def main(Rail[String]) = { Copied: trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField1.x10 (from rev 15385, trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CF1.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField1.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/DepType/TypeElaboration/CircularField1.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -0,0 +1,26 @@ +/* + * 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. + */ + + /** + Check that circular dependencies between classes are handled correctly + during TypeElaboration. + See CircularField.x10 + + *@author vj + * + */ + + public class CircularField1(i:int, j:int) { + public def this(i:int, j:int):CircularField1{self.i==i,self.j==j} { + property(i,j); + } + var f:CircularField{k==3} = null; + } Modified: trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.tests/examples/Constructs/Place/B_CheckThisTypeInCallMacro.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -18,13 +18,21 @@ * * @author vj */ -class R(rank:Int) { + +public class B_CheckThisTypeInCallMacro extends x10Test { + public def run() = true; + public static def main(Rail[String]) { + new + B_CheckThisTypeInCallMacro().execute(); + } + +static class R(rank:Int) { static type R(r:int)=R{self.rank==r}; static type Test(r:int)=Test{self.rank==r}; def check( tt:Test(this.rank)) {} def this(r:Int){property(r);} } -class Test(rank:Int) { +static class Test(rank:Int) { static type Test(r:int)=Test{self.rank==r}; static type R(r:int)=R{self.rank==r}; def this(r:Int){property(r);} @@ -33,11 +41,5 @@ r.check(t); } } -public class B_CheckThisTypeInCallMacro extends x10Test { - public def run() = true; - public static def main(Rail[String]) { - new - B_CheckThisTypeInCallMacro().execute(); - } } Added: trunk/x10.tests/examples/Issues/XTENLANG_1666.x10 =================================================================== --- trunk/x10.tests/examples/Issues/XTENLANG_1666.x10 (rev 0) +++ trunk/x10.tests/examples/Issues/XTENLANG_1666.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -0,0 +1,44 @@ +/* + * 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 + * Testing a bug in definite-assignment rules + */ +public class XTENLANG_1666 extends x10Test { + public static def main(Rail[String]) { + new XTENLANG_1666().execute(); + } + var flag:Boolean; + public def run(): boolean { + var z:Int; + z = flag || (z=3)>0 ? 3 : z++; + + var y:Int; + y = (flag || (y=3)>0) ? 3 : y++; // the bug was in ParExpr (parenthesis expressions) + + + var k:Int; + k = !(!(flag || (k=3)>0)) ? 3 : k++; + + z++; + y++; + k++; + + // I also had a bug with ParExpr in await: + await !false; + await (true); + + return true; + } +} \ No newline at end of file Property changes on: trunk/x10.tests/examples/Issues/XTENLANG_1666.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.tests/examples/Misc/FinalInitializationTest.x10 =================================================================== --- trunk/x10.tests/examples/Misc/FinalInitializationTest.x10 2010-08-17 15:25:22 UTC (rev 15559) +++ trunk/x10.tests/examples/Misc/FinalInitializationTest.x10 2010-08-17 16:23:16 UTC (rev 15560) @@ -22,12 +22,12 @@ val intval: int; val cval: complex!; val refval: foo!; - def this(var intval: int, var cval: complex!, var refval: foo!): myval = { + def this(intval: int, cval: complex!, refval: foo!): myval = { this.intval = intval; this.cval = cval; this.refval = refval; } - def eq(var other: myval!): boolean = { + def eq(other: myval!): boolean = { return this.intval == other.intval && this.cval.eq(other.cval) && @@ -42,7 +42,7 @@ static class complex { val re: int; val im: int; - def this(var re: int, var im: int): complex = { + def this(re: int, im: int): complex = { this.re = re; this.im = im; } @@ -57,7 +57,7 @@ return (x.eq(y)); } - public static def main(var args: Rail[String]): void = { + public static def main(args: Rail[String]): void = { new FinalInitializationTest().execute(); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |