From: <vj...@us...> - 2010-09-26 14:24:30
|
Revision: 16714 http://x10.svn.sourceforge.net/x10/?rev=16714&view=rev Author: vj0 Date: 2010-09-26 14:24:21 +0000 (Sun, 26 Sep 2010) Log Message: ----------- Removed foreach from the grammar. Updated X10 code in head to not use foreach. foreach (p in R) S ==> for (p in R) async S foreach (p in R) clocked (c1,...,cn) S ==> for (p in R) async clocked (c1,..., cn) S Have not removed the AST node for ForEach etc since we may use this later in the context of implicit chunking. Modified Paths: -------------- 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.dist/samples/ArraySum.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessEqualRank3a.x10 trunk/x10.tests/examples/Constructs/Array/BoxArrayAssign.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D_Dep.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest4.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest7.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest9.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF7.x10 trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 trunk/x10.tests/examples/Constructs/Distribution/ArrayToDist.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach1.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach2.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 trunk/x10.tests/examples/Misc/IfElseFinishBug.x10 trunk/x10.tests/examples/Misc/Stencil1D.x10 trunk/x10.tests/examples/Samples/HeatTransferTest_v4.x10 Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-26 11:40:43 UTC (rev 16713) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-26 14:24:21 UTC (rev 16714) @@ -13,7 +13,7 @@ import lpg.runtime.*; -//#line 32 "x10/parser/x10.g" +//#line 32 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; @@ -281,7 +281,7 @@ // - //#line 315 "x10/parser/x10.g" + //#line 315 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" private ErrorQueue eq; private X10TypeSystem ts; private X10NodeFactory nf; @@ -1162,10 +1162,10 @@ // Rule 1: TypeName ::= TypeName . ErrorId // case 1: { - //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 6 "x10/parser/MissingId.gi" + //#line 8 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 6 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1178,10 +1178,10 @@ // Rule 2: PackageName ::= PackageName . ErrorId // case 2: { - //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 16 "x10/parser/MissingId.gi" + //#line 18 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 16 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageName = (ParsedName) getRhsSym(1); - //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1194,10 +1194,10 @@ // Rule 3: ExpressionName ::= AmbiguousName . ErrorId // case 3: { - //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 26 "x10/parser/MissingId.gi" + //#line 28 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 26 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1210,10 +1210,10 @@ // Rule 4: MethodName ::= AmbiguousName . ErrorId // case 4: { - //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 36 "x10/parser/MissingId.gi" + //#line 38 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 36 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1226,10 +1226,10 @@ // Rule 5: PackageOrTypeName ::= PackageOrTypeName . ErrorId // case 5: { - //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 46 "x10/parser/MissingId.gi" + //#line 48 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 46 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); - //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1242,10 +1242,10 @@ // Rule 6: AmbiguousName ::= AmbiguousName . ErrorId // case 6: { - //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 56 "x10/parser/MissingId.gi" + //#line 58 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 56 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1258,10 +1258,10 @@ // Rule 7: FieldAccess ::= Primary . ErrorId // case 7: { - //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 66 "x10/parser/MissingId.gi" + //#line 68 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 66 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(), Primary, nf.Id(pos(getRightSpan()), "*"))); break; @@ -1271,9 +1271,9 @@ // Rule 8: FieldAccess ::= super . ErrorId // case 8: { - //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getLeftSpan())), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1283,12 +1283,12 @@ // Rule 9: FieldAccess ::= ClassName . super$sup . ErrorId // case 9: { - //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 78 "x10/parser/MissingId.gi" + //#line 80 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 78 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 78 "x10/parser/MissingId.gi" + //#line 78 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1298,12 +1298,12 @@ // Rule 10: MethodInvocation ::= MethodPrimaryPrefix ( ArgumentListopt ) // case 10: { - //#line 87 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 85 "x10/parser/MissingId.gi" + //#line 87 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 85 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" Object MethodPrimaryPrefix = (Object) getRhsSym(1); - //#line 85 "x10/parser/MissingId.gi" + //#line 85 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 87 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "C:/eclipsews/head1/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)); @@ -1314,12 +1314,12 @@ // Rule 11: MethodInvocation ::= MethodSuperPrefix ( ArgumentListopt ) // case 11: { - //#line 94 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 92 "x10/parser/MissingId.gi" + //#line 94 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 92 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" polyglot.lex.Identifier MethodSuperPrefix = (polyglot.lex.Identifier) getRhsSym(1); - //#line 92 "x10/parser/MissingId.gi" + //#line 92 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 94 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "C:/eclipsews/head1/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; @@ -1329,12 +1329,12 @@ // Rule 12: MethodInvocation ::= MethodClassNameSuperPrefix ( ArgumentListopt ) // case 12: { - //#line 100 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 98 "x10/parser/MissingId.gi" + //#line 100 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 98 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" Object MethodClassNameSuperPrefix = (Object) getRhsSym(1); - //#line 98 "x10/parser/MissingId.gi" + //#line 98 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 100 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "C:/eclipsews/head1/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]; @@ -1346,12 +1346,12 @@ // Rule 13: MethodPrimaryPrefix ::= Primary . ErrorId$ErrorId // case 13: { - //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 107 "x10/parser/MissingId.gi" + //#line 109 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 107 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 107 "x10/parser/MissingId.gi" + //#line 107 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[2]; a[0] = Primary; a[1] = id(getRhsFirstTokenIndex(3)); @@ -1363,10 +1363,10 @@ // Rule 14: MethodSuperPrefix ::= super . ErrorId$ErrorId // case 14: { - //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 115 "x10/parser/MissingId.gi" + //#line 117 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 115 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(id(getRhsFirstTokenIndex(3))); break; } @@ -1375,14 +1375,14 @@ // Rule 15: MethodClassNameSuperPrefix ::= ClassName . super$sup . ErrorId$ErrorId // case 15: { - //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 120 "x10/parser/MissingId.gi" + //#line 122 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 120 "x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 120 "x10/parser/MissingId.gi" + //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(5); - //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[3]; a[0] = ClassName; a[1] = pos(getRhsFirstTokenIndex(3)); @@ -1395,9 +1395,9 @@ // Rule 16: Modifiersopt ::= $Empty // case 16: { - //#line 1190 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1190 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1190 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1190 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new LinkedList<Modifier>()); break; } @@ -1406,12 +1406,12 @@ // Rule 17: Modifiersopt ::= Modifiersopt Modifier // case 17: { - //#line 1195 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1193 "x10/parser/x10.g" + //#line 1195 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1193 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1193 "x10/parser/x10.g" + //#line 1193 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1195 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1195 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" Modifiersopt.add(Modifier); break; } @@ -1420,9 +1420,9 @@ // Rule 18: Modifier ::= abstract // case 18: { - //#line 1201 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1201 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1201 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1201 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ABSTRACT)); break; } @@ -1431,10 +1431,10 @@ // Rule 19: Modifier ::= Annotation // case 19: { - //#line 1206 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1204 "x10/parser/x10.g" + //#line 1206 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1204 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); - //#line 1206 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1206 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new AnnotationModifier(Annotation)); break; } @@ -1443,9 +1443,9 @@ // Rule 20: Modifier ::= atomic // case 20: { - //#line 1211 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1211 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1211 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1211 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ATOMIC)); break; } @@ -1454,9 +1454,9 @@ // Rule 21: Modifier ::= extern // case 21: { - //#line 1216 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1216 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1216 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1216 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.EXTERN)); break; } @@ -1465,9 +1465,9 @@ // Rule 22: Modifier ::= final // case 22: { - //#line 1221 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1221 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1221 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1221 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.FINAL)); break; } @@ -1476,9 +1476,9 @@ // Rule 23: Modifier ::= global // case 23: { - //#line 1226 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1226 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1226 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1226 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.GLOBAL)); break; } @@ -1487,9 +1487,9 @@ // Rule 24: Modifier ::= native // case 24: { - //#line 1231 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1231 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1231 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1231 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.NATIVE)); break; } @@ -1498,9 +1498,9 @@ // Rule 25: Modifier ::= private // case 25: { - //#line 1236 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1236 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1236 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1236 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PRIVATE)); break; } @@ -1509,9 +1509,9 @@ // Rule 26: Modifier ::= protected // case 26: { - //#line 1241 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1241 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1241 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1241 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PROTECTED)); break; } @@ -1520,9 +1520,9 @@ // Rule 27: Modifier ::= public // case 27: { - //#line 1246 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1246 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1246 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1246 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.PUBLIC)); break; } @@ -1531,9 +1531,9 @@ // Rule 28: Modifier ::= static // case 28: { - //#line 1251 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1251 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1251 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1251 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.STATIC)); break; } @@ -1542,9 +1542,9 @@ // Rule 29: Modifier ::= transient // case 29: { - //#line 1256 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1256 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1256 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1256 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.TRANSIENT)); break; } @@ -1553,9 +1553,9 @@ // Rule 30: Modifier ::= clocked // case 30: { - //#line 1261 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1261 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1261 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1261 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.CLOCKED)); break; } @@ -1564,12 +1564,12 @@ // Rule 32: MethodModifiersopt ::= MethodModifiersopt property$property // case 32: { - //#line 1268 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1266 "x10/parser/x10.g" + //#line 1268 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1266 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1266 "x10/parser/x10.g" + //#line 1266 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" IToken property = (IToken) getRhsIToken(2); - //#line 1268 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1268 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(new FlagModifier(pos(getRhsFirstTokenIndex(2)), FlagModifier.PROPERTY)); break; } @@ -1578,12 +1578,12 @@ // Rule 33: MethodModifiersopt ::= MethodModifiersopt Modifier // case 33: { - //#line 1273 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1271 "x10/parser/x10.g" + //#line 1273 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1271 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1271 "x10/parser/x10.g" + //#line 1271 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1273 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1273 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(Modifier); break; } @@ -1592,20 +1592,20 @@ // Rule 34: TypeDefDeclaration ::= Modifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; // case 34: { - //#line 1279 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1277 "x10/parser/x10.g" + //#line 1279 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1277 "x10/parser/x10.g" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1277 "x10/parser/x10.g" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1277 "x10/parser/x10.g" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Formal> FormalParametersopt = (List<Formal>) getRhsSym(5); - //#line 1277 "x10/parser/x10.g" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1277 "x10/parser/x10.g" + //#line 1277 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1279 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1279 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkTypeDefModifiers(Modifiersopt); FlagsNode f = extractFlags(modifiers); List<AnnotationNode> annotations = extractAnnotations(modifiers); @@ -1628,10 +1628,10 @@ // Rule 35: Properties ::= ( PropertyList ) // case 35: { - //#line 1299 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1297 "x10/parser/x10.g" + //#line 1299 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1297 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<PropertyDecl> PropertyList = (List<PropertyDecl>) getRhsSym(2); - //#line 1299 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1299 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" setResult(PropertyList); break; } @@ -1639,10 +1639,10 @@ // Rule 36: PropertyList ::= Property // case 36: { - //#line 1304 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1302 "x10/parser/x10.g" + //#line 1304 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1302 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(1); - //#line 1304 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1304 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<PropertyDecl> l = new TypedList<PropertyDecl>(new LinkedList<PropertyDecl>(), PropertyDecl.class, false); l.add(Property); setResult(l); @@ -1653,12 +1653,12 @@ // Rule 37: PropertyList ::= PropertyList , Property // case 37: { - //#line 1311 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1309 "x10/parser/x10.g" + //#line 1311 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1309 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<PropertyDecl> PropertyList = (List<PropertyDecl>) getRhsSym(1); - //#line 1309 "x10/parser/x10.g" + //#line 1309 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" PropertyDecl Property = (PropertyDecl) getRhsSym(3); - //#line 1311 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1311 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" PropertyList.add(Property); break; } @@ -1667,14 +1667,14 @@ // Rule 38: Property ::= Annotationsopt Identifier ResultType // case 38: { - //#line 1318 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1316 "x10/parser/x10.g" + //#line 1318 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1316 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<AnnotationNode> Annotationsopt = (List<AnnotationNode>) getRhsSym(1); - //#line 1316 "x10/parser/x10.g" + //#line 1316 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); - //#line 1316 "x10/parser/x10.g" + //#line 1316 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode ResultType = (TypeNode) getRhsSym(3); - //#line 1318 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1318 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<AnnotationNode> annotations = extractAnnotations(Annotationsopt); PropertyDecl cd = nf.PropertyDecl(pos(), nf.FlagsNode(pos(), Flags.PUBLIC.Final()), ResultType, Identifier); cd = (PropertyDecl) ((X10Ext) cd.ext()).annotations(annotations); @@ -1686,24 +1686,24 @@ // Rule 39: MethodDeclaration ::= MethodModifiersopt def Identifier TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 39: { - //#line 1327 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1325 "x10/parser/x10.g" + //#line 1327 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Formal> FormalParameters = (List<Formal>) getRhsSym(5); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(8); - //#line 1325 "x10/parser/x10.g" + //#line 1325 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1327 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1327 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); ProcedureDecl pd; if (Identifier.id().toString().equals("this")) { @@ -1740,26 +1740,26 @@ // Rule 40: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 40: { - //#line 1360 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1358 "x10/parser/x10.g" + //#line 1360 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(7); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(9); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(11); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(12); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(13); - //#line 1358 "x10/parser/x10.g" + //#line 1358 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(14); - //#line 1360 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1360 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.binaryMethodName(BinOp); if (opName == null) { @@ -1790,24 +1790,24 @@ // Rule 41: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 41: { - //#line 1387 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1385 "x10/parser/x10.g" + //#line 1387 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Unary.Operator PrefixOp = (Unary.Operator) getRhsSym(4); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(6); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(8); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(9); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(10); - //#line 1385 "x10/parser/x10.g" + //#line 1385 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 1387 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1387 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Unary_c.unaryMethodName(PrefixOp); if (opName == null) { @@ -1838,24 +1838,24 @@ // Rule 42: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt this BinOp ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 42: { - //#line 1414 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1412 "x10/parser/x10.g" + //#line 1414 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(5); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(7); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(11); - //#line 1412 "x10/parser/x10.g" + //#line 1412 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1414 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1414 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.binaryMethodName(BinOp); if (opName == null) { @@ -1886,24 +1886,24 @@ // Rule 43: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) BinOp this WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 43: { - //#line 1441 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1439 "x10/parser/x10.g" + //#line 1441 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Binary.Operator BinOp = (Binary.Operator) getRhsSym(7); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(11); - //#line 1439 "x10/parser/x10.g" + //#line 1439 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1441 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1441 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Binary_c.invBinaryMethodName(BinOp); if (opName == null) { @@ -1934,22 +1934,22 @@ // Rule 44: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt PrefixOp this WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 44: { - //#line 1468 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1466 "x10/parser/x10.g" + //#line 1468 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Unary.Operator PrefixOp = (Unary.Operator) getRhsSym(4); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(8); - //#line 1466 "x10/parser/x10.g" + //#line 1466 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1468 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1468 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); Name opName = X10Unary_c.unaryMethodName(PrefixOp); if (opName == null) { @@ -1980,22 +1980,22 @@ // Rule 45: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 45: { - //#line 1495 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1493 "x10/parser/x10.g" + //#line 1495 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Formal> FormalParameters = (List<Formal>) getRhsSym(5); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(8); - //#line 1493 "x10/parser/x10.g" + //#line 1493 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(9); - //#line 1495 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1495 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2021,24 +2021,24 @@ // Rule 46: MethodDeclaration ::= MethodModifiersopt operator this TypeParametersopt FormalParameters = ( FormalParameter$fp2 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 46: { - //#line 1517 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1515 "x10/parser/x10.g" + //#line 1517 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Formal> FormalParameters = (List<Formal>) getRhsSym(5); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp2 = (X10Formal) getRhsSym(8); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(10); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(11); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(12); - //#line 1515 "x10/parser/x10.g" + //#line 1515 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(13); - //#line 1517 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1517 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2064,22 +2064,22 @@ // Rule 47: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as Type WhereClauseopt Offersopt MethodBody // case 47: { - //#line 1539 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1537 "x10/parser/x10.g" + //#line 1539 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(10); - //#line 1537 "x10/parser/x10.g" + //#line 1537 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(11); - //#line 1539 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1539 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2105,22 +2105,22 @@ // Rule 48: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) as ? WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 48: { - //#line 1561 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1559 "x10/parser/x10.g" + //#line 1561 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(9); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(10); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(11); - //#line 1559 "x10/parser/x10.g" + //#line 1559 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" Block MethodBody = (Block) getRhsSym(12); - //#line 1561 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1561 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkMethodModifiers(MethodModifiersopt); MethodDecl md = nf.X10MethodDecl(pos(), extractFlags(modifiers), @@ -2146,22 +2146,22 @@ // Rule 49: MethodDeclaration ::= MethodModifiersopt operator TypeParametersopt ( FormalParameter$fp1 ) WhereClauseopt HasResultTypeopt Offersopt MethodBody // case 49: { - //#line 1583 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1581 "x10/parser/x10.g" + //#line 1583 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1581 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1581 "x10/parser/x10.g" + //#line 1581 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(3); - //#line 1581 "x10/parser/x10.g" + //#line 1581 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" X10Formal fp1 = (X10Formal) getRhsSym(5); - //#line 1581 "x10/parser/x10.g" + //#line 1581 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" DepParameterExpr WhereClaus... [truncated message content] |
From: <ipe...@us...> - 2010-09-27 02:17:56
|
Revision: 16718 http://x10.svn.sourceforge.net/x10/?rev=16718&view=rev Author: ipeshansky Date: 2010-09-27 02:17:47 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Back out r16714 and r16716, as they used a stale version of the parser generator. These will be redone with the latest version of the generator and the parser templates. Modified Paths: -------------- 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.dist/samples/ArraySum.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessEqualRank3a.x10 trunk/x10.tests/examples/Constructs/Array/BoxArrayAssign.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D_Dep.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest4.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest7.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest9.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF7.x10 trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 trunk/x10.tests/examples/Constructs/Distribution/ArrayToDist.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach1.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach2.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 trunk/x10.tests/examples/Misc/IfElseFinishBug.x10 trunk/x10.tests/examples/Misc/Stencil1D.x10 trunk/x10.tests/examples/Samples/HeatTransferTest_v4.x10 Modified: trunk/x10.compiler/src/x10/parser/X10KWLexer.gi =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexer.gi 2010-09-27 00:59:07 UTC (rev 16717) +++ trunk/x10.compiler/src/x10/parser/X10KWLexer.gi 2010-09-27 02:17:47 UTC (rev 16718) @@ -93,11 +93,14 @@ do else extends + extern false final finally finish for + foreach + global goto here if @@ -234,6 +237,11 @@ $setResult($_extends); $EndAction ./ + | e x t e r n + /.$BeginAction + $setResult($_extern); + $EndAction + ./ | f a l s e /.$BeginAction $setResult($_false); @@ -259,6 +267,16 @@ $setResult($_for); $EndAction ./ + | f o r e a c h + /.$BeginAction + $setResult($_foreach); + $EndAction + ./ + | g l o b a l + /.$BeginAction + $setResult($_global); + $EndAction + ./ | g o t o /.$BeginAction $setResult($_goto); Modified: trunk/x10.compiler/src/x10/parser/X10KWLexer.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10KWLexer.java 2010-09-27 00:59:07 UTC (rev 16717) +++ trunk/x10.compiler/src/x10/parser/X10KWLexer.java 2010-09-27 02:17:47 UTC (rev 16718) @@ -17,7 +17,7 @@ public class X10KWLexer extends X10KWLexerprs { private char[] inputChars; - private final int keywordKind[] = new int[61 + 1]; + private final int keywordKind[] = new int[64 + 1]; public int[] getKeywordKinds() { return keywordKind; } @@ -224,299 +224,320 @@ // - // Rule 20: KeyWord ::= f a l s e + // Rule 20: KeyWord ::= e x t e r n // - keywordKind[20] = (X10Parsersym.TK_false); + keywordKind[20] = (X10Parsersym.TK_extern); // - // Rule 21: KeyWord ::= f i n a l + // Rule 21: KeyWord ::= f a l s e // - keywordKind[21] = (X10Parsersym.TK_final); + keywordKind[21] = (X10Parsersym.TK_false); // - // Rule 22: KeyWord ::= f i n a l l y + // Rule 22: KeyWord ::= f i n a l // - keywordKind[22] = (X10Parsersym.TK_finally); + keywordKind[22] = (X10Parsersym.TK_final); // - // Rule 23: KeyWord ::= f i n i s h + // Rule 23: KeyWord ::= f i n a l l y // - keywordKind[23] = (X10Parsersym.TK_finish); + keywordKind[23] = (X10Parsersym.TK_finally); // - // Rule 24: KeyWord ::= f o r + // Rule 24: KeyWord ::= f i n i s h // - keywordKind[24] = (X10Parsersym.TK_for); + keywordKind[24] = (X10Parsersym.TK_finish); // - // Rule 25: KeyWord ::= g o t o + // Rule 25: KeyWord ::= f o r // - keywordKind[25] = (X10Parsersym.TK_goto); + keywordKind[25] = (X10Parsersym.TK_for); // - // Rule 26: KeyWord ::= h e r e + // Rule 26: KeyWord ::= f o r e a c h // - keywordKind[26] = (X10Parsersym.TK_here); + keywordKind[26] = (X10Parsersym.TK_foreach); // - // Rule 27: KeyWord ::= i f + // Rule 27: KeyWord ::= g l o b a l // - keywordKind[27] = (X10Parsersym.TK_if); + keywordKind[27] = (X10Parsersym.TK_global); // - // Rule 28: KeyWord ::= i m p l e m e n t s + // Rule 28: KeyWord ::= g o t o // - keywordKind[28] = (X10Parsersym.TK_implements); + keywordKind[28] = (X10Parsersym.TK_goto); // - // Rule 29: KeyWord ::= i m p o r t + // Rule 29: KeyWord ::= h e r e // - keywordKind[29] = (X10Parsersym.TK_import); + keywordKind[29] = (X10Parsersym.TK_here); // - // Rule 30: KeyWord ::= i n + // Rule 30: KeyWord ::= i f // - keywordKind[30] = (X10Parsersym.TK_in); + keywordKind[30] = (X10Parsersym.TK_if); // - // Rule 31: KeyWord ::= i n s t a n c e o f + // Rule 31: KeyWord ::= i m p l e m e n t s // - keywordKind[31] = (X10Parsersym.TK_instanceof); + keywordKind[31] = (X10Parsersym.TK_implements); // - // Rule 32: KeyWord ::= i n t e r f a c e + // Rule 32: KeyWord ::= i m p o r t // - keywordKind[32] = (X10Parsersym.TK_interface); + keywordKind[32] = (X10Parsersym.TK_import); // - // Rule 33: KeyWord ::= n a t i v e + // Rule 33: KeyWord ::= i n // - keywordKind[33] = (X10Parsersym.TK_native); + keywordKind[33] = (X10Parsersym.TK_in); // - // Rule 34: KeyWord ::= n e w + // Rule 34: KeyWord ::= i n s t a n c e o f // - keywordKind[34] = (X10Parsersym.TK_new); + keywordKind[34] = (X10Parsersym.TK_instanceof); // - // Rule 35: KeyWord ::= n e x t + // Rule 35: KeyWord ::= i n t e r f a c e // - keywordKind[35] = (X10Parsersym.TK_next); + keywordKind[35] = (X10Parsersym.TK_interface); // - // Rule 36: KeyWord ::= n u l l + // Rule 36: KeyWord ::= n a t i v e // - keywordKind[36] = (X10Parsersym.TK_null); + keywordKind[36] = (X10Parsersym.TK_native); // - // Rule 37: KeyWord ::= o f f e r + // Rule 37: KeyWord ::= n e w // - keywordKind[37] = (X10Parsersym.TK_offer); + keywordKind[37] = (X10Parsersym.TK_new); // - // Rule 38: KeyWord ::= o f f e r s + // Rule 38: KeyWord ::= n e x t // - keywordKind[38] = (X10Parsersym.TK_offers); + keywordKind[38] = (X10Parsersym.TK_next); // - // Rule 39: KeyWord ::= o p e r a t o r + // Rule 39: KeyWord ::= n u l l // - keywordKind[39] = (X10Parsersym.TK_operator); + keywordKind[39] = (X10Parsersym.TK_null); // - // Rule 40: KeyWord ::= p a c k a g e + // Rule 40: KeyWord ::= o f f e r // - keywordKind[40] = (X10Parsersym.TK_package); + keywordKind[40] = (X10Parsersym.TK_offer); // - // Rule 41: KeyWord ::= p r i v a t e + // Rule 41: KeyWord ::= o f f e r s // - keywordKind[41] = (X10Parsersym.TK_private); + keywordKind[41] = (X10Parsersym.TK_offers); // - // Rule 42: KeyWord ::= p r o p e r t y + // Rule 42: KeyWord ::= o p e r a t o r // - keywordKind[42] = (X10Parsersym.TK_property); + keywordKind[42] = (X10Parsersym.TK_operator); // - // Rule 43: KeyWord ::= p r o t e c t e d + // Rule 43: KeyWord ::= p a c k a g e // - keywordKind[43] = (X10Parsersym.TK_protected); + keywordKind[43] = (X10Parsersym.TK_package); // - // Rule 44: KeyWord ::= p u b l i c + // Rule 44: KeyWord ::= p r i v a t e // - keywordKind[44] = (X10Parsersym.TK_public); + keywordKind[44] = (X10Parsersym.TK_private); // - // Rule 45: KeyWord ::= r e s u m e + // Rule 45: KeyWord ::= p r o p e r t y // - keywordKind[45] = (X10Parsersym.TK_resume); + keywordKind[45] = (X10Parsersym.TK_property); // - // Rule 46: KeyWord ::= r e t u r n + // Rule 46: KeyWord ::= p r o t e c t e d // - keywordKind[46] = (X10Parsersym.TK_return); + keywordKind[46] = (X10Parsersym.TK_protected); // - // Rule 47: KeyWord ::= s e l f + // Rule 47: KeyWord ::= p u b l i c // - keywordKind[47] = (X10Parsersym.TK_self); + keywordKind[47] = (X10Parsersym.TK_public); // - // Rule 48: KeyWord ::= s t a t i c + // Rule 48: KeyWord ::= r e s u m e // - keywordKind[48] = (X10Parsersym.TK_static); + keywordKind[48] = (X10Parsersym.TK_resume); // - // Rule 49: KeyWord ::= s t r u c t + // Rule 49: KeyWord ::= r e t u r n // - keywordKind[49] = (X10Parsersym.TK_struct); + keywordKind[49] = (X10Parsersym.TK_return); // - // Rule 50: KeyWord ::= s u p e r + // Rule 50: KeyWord ::= s e l f // - keywordKind[50] = (X10Parsersym.TK_super); + keywordKind[50] = (X10Parsersym.TK_self); // - // Rule 51: KeyWord ::= s w i t c h + // Rule 51: KeyWord ::= s t a t i c // - keywordKind[51] = (X10Parsersym.TK_switch); + keywordKind[51] = (X10Parsersym.TK_static); // - // Rule 52: KeyWord ::= t h i s + // Rule 52: KeyWord ::= s t r u c t // - keywordKind[52] = (X10Parsersym.TK_this); + keywordKind[52] = (X10Parsersym.TK_struct); // - // Rule 53: KeyWord ::= t h r o w + // Rule 53: KeyWord ::= s u p e r // - keywordKind[53] = (X10Parsersym.TK_throw); + keywordKind[53] = (X10Parsersym.TK_super); // - // Rule 54: KeyWord ::= t r a n s i e n t + // Rule 54: KeyWord ::= s w i t c h // - keywordKind[54] = (X10Parsersym.TK_transient); + keywordKind[54] = (X10Parsersym.TK_switch); // - // Rule 55: KeyWord ::= t r u e + // Rule 55: KeyWord ::= t h i s // - keywordKind[55] = (X10Parsersym.TK_true); + keywordKind[55] = (X10Parsersym.TK_this); // - // Rule 56: KeyWord ::= t r y + // Rule 56: KeyWord ::= t h r o w // - keywordKind[56] = (X10Parsersym.TK_try); + keywordKind[56] = (X10Parsersym.TK_throw); // - // Rule 57: KeyWord ::= t y p e + // Rule 57: KeyWord ::= t r a n s i e n t // - keywordKind[57] = (X10Parsersym.TK_type); + keywordKind[57] = (X10Parsersym.TK_transient); // - // Rule 58: KeyWord ::= v a l + // Rule 58: KeyWord ::= t r u e // - keywordKind[58] = (X10Parsersym.TK_val); + keywordKind[58] = (X10Parsersym.TK_true); // - // Rule 59: KeyWord ::= v a r + // Rule 59: KeyWord ::= t r y // - keywordKind[59] = (X10Parsersym.TK_var); + keywordKind[59] = (X10Parsersym.TK_try); // - // Rule 60: KeyWord ::= w h e n + // Rule 60: KeyWord ::= t y p e // - keywordKind[60] = (X10Parsersym.TK_when); + keywordKind[60] = (X10Parsersym.TK_type); // - // Rule 61: KeyWord ::= w h i l e + // Rule 61: KeyWord ::= v a l // - keywordKind[61] = (X10Parsersym.TK_while); + keywordKind[61] = (X10Parsersym.TK_val); + // + // Rule 62: KeyWord ::= v a r + // + + keywordKind[62] = (X10Parsersym.TK_var); + + + // + // Rule 63: KeyWord ::= w h e n + // + + keywordKind[63] = (X10Parsersym.TK_when); + + + // + // Rule 64: KeyWord ::= w h i l e + // + + keywordKind[64] = (X10Parsersym.TK_while); + + 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-09-27 00:59:07 UTC (rev 16717) +++ trunk/x10.compiler/src/x10/parser/X10KWLexerprs.java 2010-09-27 02:17:47 UTC (rev 16718) @@ -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 = 196; + public final static int NUM_STATES = 205; 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 = 322; + public final static int LA_STATE_OFFSET = 337; 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 = 61; + public final static int NUM_RULES = 64; 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 = 62; + public final static int START_STATE = 65; 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 = 260; + public final static int ACCEPT_ACTION = 272; public final int getAcceptAction() { return ACCEPT_ACTION; } - public final static int ERROR_ACTION = 261; + public final static int ERROR_ACTION = 273; public final int getErrorAction() { return ERROR_ACTION; } public final static boolean BACKTRACK = false; @@ -104,12 +104,12 @@ public interface BaseCheck { public final static byte baseCheck[] = {0, 8,2,6,5,2,6,6,5,5,4, - 5,5,7,8,3,7,2,4,7,5, - 5,7,6,3,4,4,2,10,6,2, - 10,9,6,3,4,4,5,6,8,7, - 7,8,9,6,6,6,4,6,6,5, - 6,4,5,9,4,3,4,3,3,4, - 5 + 5,5,7,8,3,7,2,4,7,6, + 5,5,7,6,3,7,6,4,4,2, + 10,6,2,10,9,6,3,4,4,5, + 6,8,7,7,8,9,6,6,6,4, + 6,6,5,6,4,5,9,4,3,4, + 3,3,4,5 }; }; public final static byte baseCheck[] = BaseCheck.baseCheck; @@ -125,27 +125,28 @@ 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,1,1,64,99,36,28,17,24,68, - 34,59,40,44,118,120,47,52,66,55, - 70,27,78,80,121,61,82,127,128,87, - 131,92,132,93,137,140,133,136,81,146, - 105,138,149,154,155,157,150,160,163,161, - 165,9,106,169,164,112,109,171,172,175, - 177,181,179,183,185,187,191,186,194,195, - 198,199,200,115,201,203,202,204,211,212, - 213,215,224,116,217,221,95,225,227,232, - 234,236,229,239,240,241,245,243,83,249, - 247,253,255,258,260,251,261,264,263,270, - 271,262,272,273,281,283,284,285,289,276, - 290,292,296,298,301,302,303,305,307,308, - 291,312,309,313,319,316,320,324,325,327, - 328,332,334,337,338,339,342,344,349,352, - 341,355,346,358,356,360,362,361,365,366, - 367,372,373,370,375,376,383,387,391,386, - 393,396,398,394,400,401,405,402,408,409, - 410,412,414,415,416,419,422,425,427,423, - 433,436,437,430,440,442,443,444,446,261, - 261 + 1,1,1,1,1,1,67,108,118,28, + 17,24,133,34,36,40,46,135,66,49, + 47,68,53,8,27,74,79,114,61,80, + 137,138,87,139,92,140,85,141,142,144, + 148,81,149,98,150,67,158,153,161,159, + 162,170,166,167,173,99,105,174,177,111, + 101,176,178,183,186,188,184,190,191,195, + 198,194,201,202,204,206,209,113,207,210, + 208,218,213,221,224,225,227,116,233,231, + 222,235,122,237,243,245,247,238,248,251, + 249,252,257,258,259,261,262,267,263,269, + 272,273,274,275,276,281,283,284,285,290, + 294,296,297,298,302,286,304,309,310,315, + 317,318,319,322,325,120,323,305,311,327, + 328,330,333,336,337,339,338,347,340,346, + 352,349,353,356,358,360,361,367,363,368, + 371,372,374,375,377,378,380,382,381,383, + 389,391,392,393,395,400,401,403,404,410, + 413,416,419,421,417,423,424,428,412,431, + 432,433,434,436,438,439,440,442,446,443, + 451,453,455,457,461,460,464,466,467,468, + 470,273,273 }; }; public final static char baseAction[] = BaseAction.baseAction; @@ -155,54 +156,56 @@ public interface TermCheck { public final static byte termCheck[] = {0, - 0,1,2,3,4,5,6,7,0,9, - 10,3,12,13,14,15,0,17,10,19, + 0,1,2,3,4,5,6,0,8,9, + 10,4,12,13,14,15,0,17,18,0, 4,21,22,0,1,2,0,0,2,13, 3,5,16,0,11,0,3,4,15,0, - 1,15,3,0,11,19,0,0,13,3, - 11,0,9,7,0,12,10,3,0,8, - 0,18,8,3,10,0,1,0,1,0, - 12,11,14,4,23,10,16,0,1,0, - 0,0,0,4,7,4,0,8,7,3, - 4,0,0,2,0,15,5,3,0,7, - 18,7,10,23,0,0,2,2,0,5, - 5,0,1,5,0,0,2,0,1,0, - 0,10,24,8,16,10,0,0,14,10, - 0,0,0,7,14,0,0,0,8,0, - 1,14,6,8,12,0,0,2,0,0, - 19,14,4,0,0,2,0,8,4,0, - 0,2,0,0,0,9,3,5,0,1, - 0,0,12,9,0,5,0,1,0,8, - 0,1,0,9,0,0,0,9,2,5, - 0,1,10,0,0,2,11,0,0,0, - 0,0,0,0,1,4,12,8,11,11, - 0,0,0,2,0,1,0,1,8,7, - 0,21,20,0,0,2,0,1,0,5, - 10,0,1,0,6,0,3,2,0,0, - 0,1,0,5,0,6,0,3,0,7, - 0,3,0,1,0,9,2,0,1,0, - 0,0,0,0,5,15,6,4,6,0, - 0,0,0,1,4,0,7,0,7,18, - 0,1,0,0,0,3,3,3,0,0, - 0,0,4,4,3,0,21,0,1,4, - 0,0,0,1,0,5,0,0,0,8, - 20,0,0,9,7,0,5,11,0,0, - 2,13,7,0,0,6,0,0,4,6, - 4,0,20,0,7,2,0,0,0,1, - 0,0,6,0,13,0,9,6,0,6, - 5,0,4,2,0,0,2,0,1,0, - 0,0,22,2,0,0,0,12,9,0, - 1,0,0,8,0,0,0,13,18,8, - 6,9,0,17,2,0,0,2,13,3, - 0,1,0,0,2,0,1,0,1,0, - 0,0,3,10,0,1,6,0,0,0, - 2,0,5,0,0,0,1,16,0,6, - 11,0,0,9,0,4,0,1,17,0, - 6,9,0,1,16,0,0,2,2,0, - 1,0,0,0,2,0,17,0,0,0, - 5,10,0,0,0,12,0,0,0,0, + 1,15,3,17,11,0,0,12,0,14, + 11,3,0,7,9,3,8,12,10,7, + 0,0,10,3,19,0,0,0,1,23, + 4,11,7,0,1,10,16,10,0,0, + 0,8,4,4,0,7,0,8,0,3, + 4,0,8,2,10,15,5,0,0,2, + 0,3,5,23,0,5,2,0,10,5, + 0,1,0,0,2,0,16,0,0,0, + 10,0,7,4,3,10,14,14,9,8, + 13,24,0,1,0,1,0,0,0,0, + 0,0,1,0,8,7,6,0,0,0, + 2,14,0,0,7,12,17,0,0,2, + 0,0,10,14,4,0,0,9,7,0, + 5,2,0,0,1,0,0,0,12,3, + 5,9,0,0,7,0,1,0,1,0, + 0,9,9,0,0,5,2,0,1,10, + 0,0,2,0,11,0,0,0,0,0, + 0,4,0,12,11,7,11,0,1,7, + 0,0,2,0,0,1,0,21,2,20, + 0,8,0,1,0,1,0,0,17,2, + 10,5,0,1,0,1,0,0,0,3, + 0,0,1,6,6,5,0,0,0,3, + 0,0,0,3,2,8,0,1,0,1, + 9,0,0,0,0,0,5,19,4,6, + 0,6,0,0,0,0,4,15,8,0, + 1,0,8,0,1,0,0,0,3,3, + 3,0,19,0,0,4,21,4,0,0, + 0,3,8,4,0,1,0,0,0,3, + 3,0,0,5,0,1,0,0,7,0, + 20,5,0,11,2,0,0,0,0,0, + 13,4,6,8,6,0,0,8,0,20, + 4,0,0,2,6,0,1,0,13,0, + 0,9,0,6,4,6,0,0,2,2, + 0,0,1,0,0,5,0,0,2,0, + 0,0,0,9,22,12,7,6,0,7, + 0,0,0,13,0,1,19,9,7,0, + 0,9,0,0,2,6,3,0,18,0, + 1,0,0,13,2,0,0,2,0,1, + 0,1,0,0,13,3,10,0,1,6, + 0,0,0,0,2,0,5,0,0,0, + 1,0,0,6,11,0,16,9,6,4, + 0,1,0,18,0,1,0,16,2,0, + 0,9,2,0,1,0,0,0,2,0, + 0,0,0,0,5,10,0,18,0,12, 0,0,0,0,0,0,0,0,0,0, - 0,0,0 + 0,0,0,0,0,0,0 }; }; public final static byte termCheck[] = TermCheck.termCheck; @@ -210,52 +213,54 @@ public interface TermAction { public final static char termAction[] = {0, - 261,77,67,81,69,68,79,73,261,72, - 71,153,76,74,70,65,261,78,152,80, - 85,66,75,261,90,89,261,261,115,86, - 83,116,84,261,88,261,94,93,87,261, - 98,114,99,261,92,117,261,261,82,106, - 97,261,100,105,261,288,104,112,261,108, - 261,101,111,122,110,261,109,261,91,261, - 96,121,95,113,107,278,317,261,119,261, - 261,261,261,320,118,123,261,319,124,128, - 127,261,261,130,261,295,131,185,261,134, - 195,184,133,139,30,261,141,154,2,142, - 155,5,159,161,261,261,173,261,102,261, - 261,158,260,183,160,182,261,261,174,103, - 261,261,261,125,120,261,261,261,129,261, - 136,126,135,138,137,261,261,140,261,261, - 132,143,144,261,261,145,261,147,285,261, - 261,148,261,261,261,146,157,149,261,156, - 261,261,150,151,261,162,261,318,261,163, - 261,316,261,321,261,261,261,164,166,313, - 261,167,165,261,261,169,168,261,261,261, - 261,261,261,261,178,177,308,172,170,171, - 261,261,261,296,261,180,261,287,297,179, - 261,175,176,261,261,181,261,187,261,186, - 286,261,279,15,190,261,188,189,261,261, - 261,271,261,191,261,192,261,193,261,194, - 261,196,261,198,261,197,199,261,322,261, - 261,261,261,261,200,314,201,311,202,261, - 261,261,261,207,204,261,203,261,206,205, - 261,208,261,261,261,209,210,211,261,261, - 261,261,212,214,215,261,213,261,217,216, - 261,261,261,281,261,218,261,261,261,219, - 223,261,261,220,222,261,273,221,261,261, - 269,272,224,261,261,225,261,261,226,265, - 227,261,270,261,228,310,261,261,261,306, - 261,261,309,261,312,37,307,305,261,229, - 299,261,230,231,261,261,233,261,294,261, - 261,261,232,290,261,21,261,234,235,261, - 241,261,261,237,261,261,261,284,236,239, - 268,240,261,238,264,261,261,244,267,242, - 261,243,261,261,245,261,302,261,301,261, - 261,261,247,246,261,249,248,261,261,261, - 277,261,280,261,261,261,253,283,261,251, - 250,261,261,252,261,300,261,255,274,261, - 254,256,261,275,303,261,261,262,315,261, - 293,261,261,261,258,261,304,261,261,261, - 289,257,261,261,261,292 + 273,80,70,84,72,71,82,273,76,75, + 74,117,79,77,73,68,273,83,81,273, + 88,69,78,273,93,92,273,273,119,89, + 86,120,87,273,91,273,97,96,90,273, + 101,118,102,121,95,273,273,99,273,98, + 100,110,273,112,103,116,109,303,108,115, + 273,273,114,126,104,273,273,273,113,111, + 148,125,107,273,123,106,332,290,273,273, + 273,122,335,127,273,334,273,128,273,132, + 131,273,138,134,137,310,135,33,273,145, + 2,159,146,143,273,167,160,273,158,161, + 5,165,273,273,179,273,166,273,273,273, + 164,273,189,230,193,188,180,124,231,192, + 85,272,273,94,273,105,273,273,273,273, + 273,273,140,273,129,133,139,273,273,273, + 144,130,273,273,142,141,136,273,273,149, + 273,273,150,147,151,273,273,152,153,273, + 155,154,273,273,162,273,273,273,156,163, + 168,157,273,273,169,273,333,273,331,273, + 273,336,170,273,273,328,172,273,173,171, + 273,273,175,273,174,273,273,273,273,273, + 273,183,273,323,176,178,177,273,184,312, + 273,273,311,273,273,186,273,181,187,182, + 273,185,273,302,25,191,273,273,190,197, + 301,194,273,195,273,291,15,273,273,196, + 273,273,283,198,200,199,273,273,273,201, + 273,273,273,204,207,202,273,206,273,337, + 205,273,273,273,273,273,208,203,326,209, + 273,210,273,273,273,273,212,329,211,273, + 215,273,214,273,216,273,273,273,217,218, + 219,273,213,273,273,220,221,222,273,273, + 273,223,233,224,273,225,273,273,273,226, + 227,273,273,228,273,294,273,273,229,273, + 234,285,273,232,281,273,273,273,273,273, + 284,237,236,235,277,273,273,239,273,282, + 238,273,273,325,324,273,321,273,327,273, + 273,322,273,320,241,240,273,273,242,244, + 40,273,309,273,273,314,273,273,305,273, + 273,273,22,246,243,245,300,248,273,249, + 273,273,273,297,273,253,247,293,251,273, + 273,252,273,273,276,280,254,273,250,273, + 255,273,273,279,256,273,273,257,273,317, + 273,316,273,273,299,259,258,273,261,260, + 273,273,273,273,289,273,292,273,273,273, + 265,273,273,263,262,273,296,264,266,315, + 273,267,273,286,273,287,273,318,274,273, + 273,268,330,273,308,273,273,273,270,273, + 273,273,273,273,304,269,273,319,273,307 }; }; 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-09-27 00:59:07 UTC (rev 16717) +++ trunk/x10.compiler/src/x10/parser/X10KWLexersym.java 2010-09-27 02:17:47 UTC (rev 16718) @@ -14,18 +14,18 @@ public interface X10KWLexersym { public final static int Char_a = 3, - Char_b = 19, + Char_b = 17, Char_c = 6, - Char_d = 17, + Char_d = 18, Char_e = 1, Char_f = 12, Char_g = 22, Char_h = 13, - Char_i = 7, + Char_i = 8, Char_j = 25, Char_k = 20, - Char_l = 8, - Char_m = 18, + Char_l = 7, + Char_m = 19, Char_n = 9, Char_o = 10, Char_p = 14, @@ -49,8 +49,8 @@ "r", "s", "c", + "l", "i", - "l", "n", "o", "u", @@ -59,9 +59,9 @@ "p", "w", "y", + "b", "d", "m", - "b", "k", "v", "g", Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-27 00:59:07 UTC (rev 16717) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-27 02:17:47 UTC (rev 16718) @@ -13,7 +13,7 @@ import lpg.runtime.*; -//#line 32 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" +//#line 32 "x10/parser/x10.g" import java.util.Arrays; import java.util.ArrayList; import java.util.Collections; @@ -281,7 +281,7 @@ // - //#line 315 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 315 "x10/parser/x10.g" private ErrorQueue eq; private X10TypeSystem ts; private X10NodeFactory nf; @@ -418,9 +418,9 @@ private static class FlagModifier extends Modifier { public static int ABSTRACT = 0; public static int ATOMIC = 1; - // public static int EXTERN = 2; + public static int EXTERN = 2; public static int FINAL = 3; - //public static int GLOBAL = 4; + public static int GLOBAL = 4; //public static int INCOMPLETE = 5; public static int NATIVE = 6; //public static int NON_BLOCKING = 7; @@ -443,9 +443,9 @@ public Flags flags() { if (flag == ABSTRACT) return Flags.ABSTRACT; if (flag == ATOMIC) return X10Flags.ATOMIC; - // if (flag == EXTERN) return X10Flags.EXTERN; + if (flag == EXTERN) return X10Flags.EXTERN; if (flag == FINAL) return Flags.FINAL; - // if (flag == GLOBAL) return X10Flags.GLOBAL; + if (flag == GLOBAL) return X10Flags.GLOBAL; //if (flag == INCOMPLETE) return X10Flags.INCOMPLETE; if (flag == NATIVE) return Flags.NATIVE; //if (flag == NON_BLOCKING) return X10Flags.NON_BLOCKING; @@ -465,9 +465,9 @@ public String name() { if (flag == ABSTRACT) return "abstract"; if (flag == ATOMIC) return "atomic"; - //if (flag == EXTERN) return "extern"; + if (flag == EXTERN) return "extern"; if (flag == FINAL) return "final"; - //if (flag == GLOBAL) return "global"; + if (flag == GLOBAL) return "global"; //if (flag == INCOMPLETE) return "incomplete"; if (flag == NATIVE) return "native"; //if (flag == NON_BLOCKING) return "nonblocking"; @@ -541,7 +541,7 @@ static { methodModifiers[ABSTRACT] = true; methodModifiers[ATOMIC] = true; - // methodModifiers[EXTERN] = true; + methodModifiers[EXTERN] = true; methodModifiers[FINAL] = true; // methodModifiers[GLOBAL] = true; //methodModifiers[INCOMPLETE] = true; @@ -1162,10 +1162,10 @@ // Rule 1: TypeName ::= TypeName . ErrorId // case 1: { - //#line 8 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 6 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 6 "x10/parser/MissingId.gi" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 8 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 8 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1178,10 +1178,10 @@ // Rule 2: PackageName ::= PackageName . ErrorId // case 2: { - //#line 18 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 16 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 16 "x10/parser/MissingId.gi" ParsedName PackageName = (ParsedName) getRhsSym(1); - //#line 18 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 18 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1194,10 +1194,10 @@ // Rule 3: ExpressionName ::= AmbiguousName . ErrorId // case 3: { - //#line 28 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 26 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 26 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 28 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 28 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1210,10 +1210,10 @@ // Rule 4: MethodName ::= AmbiguousName . ErrorId // case 4: { - //#line 38 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 36 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 36 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 38 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 38 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1226,10 +1226,10 @@ // Rule 5: PackageOrTypeName ::= PackageOrTypeName . ErrorId // case 5: { - //#line 48 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 46 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 46 "x10/parser/MissingId.gi" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); - //#line 48 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 48 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1242,10 +1242,10 @@ // Rule 6: AmbiguousName ::= AmbiguousName . ErrorId // case 6: { - //#line 58 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 56 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 56 "x10/parser/MissingId.gi" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 58 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 58 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ParsedName(nf, ts, pos(getLeftSpan(), getRightSpan()), @@ -1258,10 +1258,10 @@ // Rule 7: FieldAccess ::= Primary . ErrorId // case 7: { - //#line 68 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 66 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 66 "x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 68 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 68 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(), Primary, nf.Id(pos(getRightSpan()), "*"))); break; @@ -1271,9 +1271,9 @@ // Rule 8: FieldAccess ::= super . ErrorId // case 8: { - //#line 74 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 74 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 74 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getLeftSpan())), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1283,12 +1283,12 @@ // Rule 9: FieldAccess ::= ClassName . super$sup . ErrorId // case 9: { - //#line 80 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 78 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 78 "x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 78 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 78 "x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 80 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 80 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.Field(pos(getRightSpan()), nf.Super(pos(getRhsFirstTokenIndex(3)), ClassName.toType()), nf.Id(pos(getRightSpan()), "*"))); break; @@ -1298,12 +1298,12 @@ // Rule 10: MethodInvocation ::= MethodPrimaryPrefix ( ArgumentListopt ) // case 10: { - //#line 87 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 85 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 87 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 85 "x10/parser/MissingId.gi" Object MethodPrimaryPrefix = (Object) getRhsSym(1); - //#line 85 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 85 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 87 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 87 "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)); @@ -1314,12 +1314,12 @@ // Rule 11: MethodInvocation ::= MethodSuperPrefix ( ArgumentListopt ) // case 11: { - //#line 94 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 92 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 94 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 92 "x10/parser/MissingId.gi" polyglot.lex.Identifier MethodSuperPrefix = (polyglot.lex.Identifier) getRhsSym(1); - //#line 92 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 92 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 94 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 94 "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; @@ -1329,12 +1329,12 @@ // Rule 12: MethodInvocation ::= MethodClassNameSuperPrefix ( ArgumentListopt ) // case 12: { - //#line 100 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 98 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 100 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 98 "x10/parser/MissingId.gi" Object MethodClassNameSuperPrefix = (Object) getRhsSym(1); - //#line 98 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 98 "x10/parser/MissingId.gi" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(3); - //#line 100 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 100 "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]; @@ -1346,12 +1346,12 @@ // Rule 13: MethodPrimaryPrefix ::= Primary . ErrorId$ErrorId // case 13: { - //#line 109 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 107 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 107 "x10/parser/MissingId.gi" Expr Primary = (Expr) getRhsSym(1); - //#line 107 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 107 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 109 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 109 "lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[2]; a[0] = Primary; a[1] = id(getRhsFirstTokenIndex(3)); @@ -1363,10 +1363,10 @@ // Rule 14: MethodSuperPrefix ::= super . ErrorId$ErrorId // case 14: { - //#line 117 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 115 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 115 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(3); - //#line 117 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 117 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(id(getRhsFirstTokenIndex(3))); break; } @@ -1375,14 +1375,14 @@ // Rule 15: MethodClassNameSuperPrefix ::= ClassName . super$sup . ErrorId$ErrorId // case 15: { - //#line 122 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 120 "x10/parser/MissingId.gi" ParsedName ClassName = (ParsedName) getRhsSym(1); - //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "x10/parser/MissingId.gi" IToken sup = (IToken) getRhsIToken(3); - //#line 120 "C:/eclipsews/head1/x10.compiler/src/x10/parser/MissingId.gi" + //#line 120 "x10/parser/MissingId.gi" IToken ErrorId = (IToken) getRhsIToken(5); - //#line 122 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 122 "lpg.generator/templates/java/btParserTemplateF.gi" Object[] a = new Object[3]; a[0] = ClassName; a[1] = pos(getRhsFirstTokenIndex(3)); @@ -1395,9 +1395,9 @@ // Rule 16: Modifiersopt ::= $Empty // case 16: { - //#line 1190 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1190 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1190 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1190 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new LinkedList<Modifier>()); break; } @@ -1406,12 +1406,12 @@ // Rule 17: Modifiersopt ::= Modifiersopt Modifier // case 17: { - //#line 1195 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1193 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 1195 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1193 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1193 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 1193 "x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1195 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1195 "lpg.generator/templates/java/btParserTemplateF.gi" Modifiersopt.add(Modifier); break; } @@ -1420,9 +1420,9 @@ // Rule 18: Modifier ::= abstract // case 18: { - //#line 1201 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1201 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1201 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1201 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ABSTRACT)); break; } @@ -1431,10 +1431,10 @@ // Rule 19: Modifier ::= Annotation // case 19: { - //#line 1206 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1204 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 1206 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1204 "x10/parser/x10.g" AnnotationNode Annotation = (AnnotationNode) getRhsSym(1); - //#line 1206 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1206 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new AnnotationModifier(Annotation)); break; } @@ -1443,147 +1443,169 @@ // Rule 20: Modifier ::= atomic // case 20: { - //#line 1211 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1211 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1211 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1211 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.ATOMIC)); break; } // - // Rule 21: Modifier ::= final + // Rule 21: Modifier ::= extern // case 21: { - //#line 1221 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1216 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1221 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.FINAL)); + //#line 1216 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.EXTERN)); break; } // - // Rule 22: Modifier ::= native + // Rule 22: Modifier ::= final // case 22: { - //#line 1231 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1221 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1231 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.NATIVE)); + //#line 1221 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.FINAL)); break; } // - // Rule 23: Modifier ::= private + // Rule 23: Modifier ::= global // case 23: { - //#line 1236 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1226 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1236 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.PRIVATE)); + //#line 1226 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.GLOBAL)); break; } // - // Rule 24: Modifier ::= protected + // Rule 24: Modifier ::= native // case 24: { - //#line 1241 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1231 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1241 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.PROTECTED)); + //#line 1231 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.NATIVE)); break; } // - // Rule 25: Modifier ::= public + // Rule 25: Modifier ::= private // case 25: { - //#line 1246 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1236 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1246 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.PUBLIC)); + //#line 1236 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.PRIVATE)); break; } // - // Rule 26: Modifier ::= static + // Rule 26: Modifier ::= protected // case 26: { - //#line 1251 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1241 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1251 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.STATIC)); + //#line 1241 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.PROTECTED)); break; } // - // Rule 27: Modifier ::= transient + // Rule 27: Modifier ::= public // case 27: { - //#line 1256 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1246 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1256 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - setResult(new FlagModifier(pos(), FlagModifier.TRANSIENT)); + //#line 1246 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.PUBLIC)); break; } // - // Rule 28: Modifier ::= clocked + // Rule 28: Modifier ::= static // case 28: { - //#line 1261 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1251 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1261 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1251 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.STATIC)); + break; + } + + // + // Rule 29: Modifier ::= transient + // + case 29: { + //#line 1256 "lpg.generator/templates/java/btParserTemplateF.gi" + + //#line 1256 "lpg.generator/templates/java/btParserTemplateF.gi" + setResult(new FlagModifier(pos(), FlagModifier.TRANSIENT)); + break; + } + + // + // Rule 30: Modifier ::= clocked + // + case 30: { + //#line 1261 "lpg.generator/templates/java/btParserTemplateF.gi" + + //#line 1261 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new FlagModifier(pos(), FlagModifier.CLOCKED)); break; } // - // Rule 30: MethodModifiersopt ::= MethodModifiersopt property$property + // Rule 32: MethodModifiersopt ::= MethodModifiersopt property$property // - case 30: { - //#line 1268 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1266 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + case 32: { + //#line 1268 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1266 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1266 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 1266 "x10/parser/x10.g" IToken property = (IToken) getRhsIToken(2); - //#line 1268 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1268 "lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(new FlagModifier(pos(getRhsFirstTokenIndex(2)), FlagModifier.PROPERTY)); break; } // - // Rule 31: MethodModifiersopt ::= MethodModifiersopt Modifier + // Rule 33: MethodModifiersopt ::= MethodModifiersopt Modifier // - case 31: { - //#line 1273 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1271 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + case 33: { + //#line 1273 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1271 "x10/parser/x10.g" List<Modifier> MethodModifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1271 "C:/eclipsews/head1/x10.compiler/src/x10/parser/x10.g" + //#line 1271 "x10/parser/x10.g" Modifier Modifier = (Modifier) getRhsSym(2); - //#line 1273 "C:/eclipsews/head1/lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1273 "lpg.generator/templates/java/btParserTemplateF.gi" MethodModifiersopt.add(Modifier); break; } // - // Rule 32: TypeDefDeclaration ::= Modifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; + // Rule 34: TypeDefDeclaration ::= Modifiersopt type Identifier TypeParametersopt FormalParametersopt WhereClauseopt = Type ; // - case 32: { - //#line 1279 "C:/eclipsew... [truncated message content] |
From: <yz...@us...> - 2010-09-27 15:51:01
|
Revision: 16723 http://x10.svn.sourceforge.net/x10/?rev=16723&view=rev Author: yzibin Date: 2010-09-27 15:50:55 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Vijay wrote: when (b=true) { instead of when (b==true) { fixed a bug when using static fields with a "this." prefix. Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-27 15:01:18 UTC (rev 16722) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-27 15:50:55 UTC (rev 16723) @@ -717,15 +717,16 @@ private boolean isTargetThis(X10Call call) { final MethodInstance methodInstance = call.methodInstance(); - return !isProperty(methodInstance.def()) && isThis(call.target()); + final MethodDef def = methodInstance.def(); + return !isProperty(def) && !def.flags().isStatic() && isThis(call.target()); } private boolean isTargetThis(FieldAssign f) { FieldDef def = f.fieldInstance().def(); - return !isProperty(def) && isThis(f.target()); + return !isProperty(def) && !def.flags().isStatic() && isThis(f.target()); } private boolean isTargetThis(Field f) { FieldDef def = f.fieldInstance().def(); - return !isProperty(def) && isThis(f.target()); + return !isProperty(def) && !def.flags().isStatic() && isThis(f.target()); } private boolean isThis(Node n) { if (n==null || !(n instanceof Special)) return false; Modified: trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 2010-09-27 15:01:18 UTC (rev 16722) +++ trunk/x10.tests/examples/Constructs/Atomic/NoFutureForceInWhen.x10 2010-09-27 15:50:55 UTC (rev 16723) @@ -21,7 +21,7 @@ try { val b=true; val x = Future.make[int](()=>0); - when (b=true) { + when (b==true) { x.force(); } } catch (IllegalOperationException) { Modified: trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 2010-09-27 15:01:18 UTC (rev 16722) +++ trunk/x10.tests/examples/Constructs/Atomic/NoFutureMakeInWhen.x10 2010-09-27 15:50:55 UTC (rev 16723) @@ -20,7 +20,7 @@ public def run(): boolean = { try { val b=true; - when (b=true) { + when (b==true) { val x = Future.make[int](()=>0); } } catch (IllegalOperationException) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ipe...@us...> - 2010-09-27 16:22:31
|
Revision: 16725 http://x10.svn.sourceforge.net/x10/?rev=16725&view=rev Author: ipeshansky Date: 2010-09-27 16:22:23 +0000 (Mon, 27 Sep 2010) Log Message: ----------- Reinstate r16714 with the correctly regenerated parser. Modified Paths: -------------- 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.dist/samples/ArraySum.x10 trunk/x10.dist/samples/Histogram.x10 trunk/x10.dist/samples/NQueensPar.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v3.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v4.x10 trunk/x10.dist/samples/tutorial/HeatTransfer_v5.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.tests/examples/Constructs/Array/ArrayAccessEqualRank3a.x10 trunk/x10.tests/examples/Constructs/Array/BoxArrayAssign.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D.x10 trunk/x10.tests/examples/Constructs/Array/StencilForeach2D_Dep.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest4.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest7.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest9.x10 trunk/x10.tests/examples/Constructs/CollectingFinish/CF7.x10 trunk/x10.tests/examples/Constructs/DepType/MethodArgDepTypes2.x10 trunk/x10.tests/examples/Constructs/Distribution/ArrayToDist.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach1.x10 trunk/x10.tests/examples/Constructs/ForEach/Foreach2.x10 trunk/x10.tests/examples/Constructs/Future/FutureTest3.x10 trunk/x10.tests/examples/Misc/IfElseFinishBug.x10 trunk/x10.tests/examples/Misc/Stencil1D.x10 trunk/x10.tests/examples/Samples/HeatTransferTest_v4.x10 Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-27 15:58:48 UTC (rev 16724) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-09-27 16:22:23 UTC (rev 16725) @@ -3154,9 +3154,9 @@ } // - // Rule 143: OfferStatement ::= offer Expression ; + // Rule 141: OfferStatement ::= offer Expression ; // - case 143: { + case 141: { //#line 2134 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2132 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(2); @@ -3166,9 +3166,9 @@ } // - // Rule 144: IfThenStatement ::= if ( Expression ) Statement + // Rule 142: IfThenStatement ::= if ( Expression ) Statement // - case 144: { + case 142: { //#line 2140 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2138 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3180,9 +3180,9 @@ } // - // Rule 145: IfThenElseStatement ::= if ( Expression ) Statement$s1 else Statement$s2 + // Rule 143: IfThenElseStatement ::= if ( Expression ) Statement$s1 else Statement$s2 // - case 145: { + case 143: { //#line 2146 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2144 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3196,9 +3196,9 @@ } // - // Rule 146: EmptyStatement ::= ; + // Rule 144: EmptyStatement ::= ; // - case 146: { + case 144: { //#line 2152 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2152 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -3207,9 +3207,9 @@ } // - // Rule 147: LabeledStatement ::= Identifier : LoopStatement + // Rule 145: LabeledStatement ::= Identifier : LoopStatement // - case 147: { + case 145: { //#line 2158 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2156 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -3221,9 +3221,9 @@ } // - // Rule 153: ExpressionStatement ::= StatementExpression ; + // Rule 150: ExpressionStatement ::= StatementExpression ; // - case 153: { + case 150: { //#line 2170 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2168 "x10/parser/x10.g" Expr StatementExpression = (Expr) getRhsSym(1); @@ -3233,9 +3233,9 @@ } // - // Rule 161: AssertStatement ::= assert Expression ; + // Rule 158: AssertStatement ::= assert Expression ; // - case 161: { + case 158: { //#line 2184 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2182 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(2); @@ -3245,9 +3245,9 @@ } // - // Rule 162: AssertStatement ::= assert Expression$expr1 : Expression$expr2 ; + // Rule 159: AssertStatement ::= assert Expression$expr1 : Expression$expr2 ; // - case 162: { + case 159: { //#line 2189 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2187 "x10/parser/x10.g" Expr expr1 = (Expr) getRhsSym(2); @@ -3259,9 +3259,9 @@ } // - // Rule 163: SwitchStatement ::= switch ( Expression ) SwitchBlock + // Rule 160: SwitchStatement ::= switch ( Expression ) SwitchBlock // - case 163: { + case 160: { //#line 2195 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2193 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3273,9 +3273,9 @@ } // - // Rule 164: SwitchBlock ::= { SwitchBlockStatementGroupsopt SwitchLabelsopt } + // Rule 161: SwitchBlock ::= { SwitchBlockStatementGroupsopt SwitchLabelsopt } // - case 164: { + case 161: { //#line 2201 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2199 "x10/parser/x10.g" List<Stmt> SwitchBlockStatementGroupsopt = (List<Stmt>) getRhsSym(2); @@ -3288,9 +3288,9 @@ } // - // Rule 166: SwitchBlockStatementGroups ::= SwitchBlockStatementGroups SwitchBlockStatementGroup + // Rule 163: SwitchBlockStatementGroups ::= SwitchBlockStatementGroups SwitchBlockStatementGroup // - case 166: { + case 163: { //#line 2209 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2207 "x10/parser/x10.g" List<SwitchElement> SwitchBlockStatementGroups = (List<SwitchElement>) getRhsSym(1); @@ -3303,9 +3303,9 @@ } // - // Rule 167: SwitchBlockStatementGroup ::= SwitchLabels BlockStatements + // Rule 164: SwitchBlockStatementGroup ::= SwitchLabels BlockStatements // - case 167: { + case 164: { //#line 2216 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2214 "x10/parser/x10.g" List<SwitchElement> SwitchLabels = (List<SwitchElement>) getRhsSym(1); @@ -3320,9 +3320,9 @@ } // - // Rule 168: SwitchLabels ::= SwitchLabel + // Rule 165: SwitchLabels ::= SwitchLabel // - case 168: { + case 165: { //#line 2225 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2223 "x10/parser/x10.g" Case SwitchLabel = (Case) getRhsSym(1); @@ -3334,9 +3334,9 @@ } // - // Rule 169: SwitchLabels ::= SwitchLabels SwitchLabel + // Rule 166: SwitchLabels ::= SwitchLabels SwitchLabel // - case 169: { + case 166: { //#line 2232 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2230 "x10/parser/x10.g" List<SwitchElement> SwitchLabels = (List<SwitchElement>) getRhsSym(1); @@ -3349,9 +3349,9 @@ } // - // Rule 170: SwitchLabel ::= case ConstantExpression : + // Rule 167: SwitchLabel ::= case ConstantExpression : // - case 170: { + case 167: { //#line 2239 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2237 "x10/parser/x10.g" Expr ConstantExpression = (Expr) getRhsSym(2); @@ -3361,9 +3361,9 @@ } // - // Rule 171: SwitchLabel ::= default : + // Rule 168: SwitchLabel ::= default : // - case 171: { + case 168: { //#line 2244 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2244 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -3372,9 +3372,9 @@ } // - // Rule 172: WhileStatement ::= while ( Expression ) Statement + // Rule 169: WhileStatement ::= while ( Expression ) Statement // - case 172: { + case 169: { //#line 2250 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2248 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3386,9 +3386,9 @@ } // - // Rule 173: DoStatement ::= do Statement while ( Expression ) ; + // Rule 170: DoStatement ::= do Statement while ( Expression ) ; // - case 173: { + case 170: { //#line 2256 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2254 "x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(2); @@ -3400,9 +3400,9 @@ } // - // Rule 176: BasicForStatement ::= for ( ForInitopt ; Expressionopt ; ForUpdateopt ) Statement + // Rule 173: BasicForStatement ::= for ( ForInitopt ; Expressionopt ; ForUpdateopt ) Statement // - case 176: { + case 173: { //#line 2265 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2263 "x10/parser/x10.g" List<ForInit> ForInitopt = (List<ForInit>) getRhsSym(3); @@ -3418,9 +3418,9 @@ } // - // Rule 178: ForInit ::= LocalVariableDeclaration + // Rule 175: ForInit ::= LocalVariableDeclaration // - case 178: { + case 175: { //#line 2272 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2270 "x10/parser/x10.g" List<LocalDecl> LocalVariableDeclaration = (List<LocalDecl>) getRhsSym(1); @@ -3432,9 +3432,9 @@ } // - // Rule 180: StatementExpressionList ::= StatementExpression + // Rule 177: StatementExpressionList ::= StatementExpression // - case 180: { + case 177: { //#line 2282 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2280 "x10/parser/x10.g" Expr StatementExpression = (Expr) getRhsSym(1); @@ -3446,9 +3446,9 @@ } // - // Rule 181: StatementExpressionList ::= StatementExpressionList , StatementExpression + // Rule 178: StatementExpressionList ::= StatementExpressionList , StatementExpression // - case 181: { + case 178: { //#line 2289 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2287 "x10/parser/x10.g" List<Eval> StatementExpressionList = (List<Eval>) getRhsSym(1); @@ -3460,9 +3460,9 @@ } // - // Rule 182: BreakStatement ::= break Identifieropt ; + // Rule 179: BreakStatement ::= break Identifieropt ; // - case 182: { + case 179: { //#line 2295 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2293 "x10/parser/x10.g" Id Identifieropt = (Id) getRhsSym(2); @@ -3472,9 +3472,9 @@ } // - // Rule 183: ContinueStatement ::= continue Identifieropt ; + // Rule 180: ContinueStatement ::= continue Identifieropt ; // - case 183: { + case 180: { //#line 2301 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2299 "x10/parser/x10.g" Id Identifieropt = (Id) getRhsSym(2); @@ -3484,9 +3484,9 @@ } // - // Rule 184: ReturnStatement ::= return Expressionopt ; + // Rule 181: ReturnStatement ::= return Expressionopt ; // - case 184: { + case 181: { //#line 2307 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2305 "x10/parser/x10.g" Expr Expressionopt = (Expr) getRhsSym(2); @@ -3496,9 +3496,9 @@ } // - // Rule 185: ThrowStatement ::= throw Expression ; + // Rule 182: ThrowStatement ::= throw Expression ; // - case 185: { + case 182: { //#line 2313 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2311 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(2); @@ -3508,9 +3508,9 @@ } // - // Rule 186: TryStatement ::= try Block Catches + // Rule 183: TryStatement ::= try Block Catches // - case 186: { + case 183: { //#line 2319 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2317 "x10/parser/x10.g" Block Block = (Block) getRhsSym(2); @@ -3522,9 +3522,9 @@ } // - // Rule 187: TryStatement ::= try Block Catchesopt Finally + // Rule 184: TryStatement ::= try Block Catchesopt Finally // - case 187: { + case 184: { //#line 2324 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2322 "x10/parser/x10.g" Block Block = (Block) getRhsSym(2); @@ -3538,9 +3538,9 @@ } // - // Rule 188: Catches ::= CatchClause + // Rule 185: Catches ::= CatchClause // - case 188: { + case 185: { //#line 2330 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2328 "x10/parser/x10.g" Catch CatchClause = (Catch) getRhsSym(1); @@ -3552,9 +3552,9 @@ } // - // Rule 189: Catches ::= Catches CatchClause + // Rule 186: Catches ::= Catches CatchClause // - case 189: { + case 186: { //#line 2337 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2335 "x10/parser/x10.g" List<Catch> Catches = (List<Catch>) getRhsSym(1); @@ -3567,9 +3567,9 @@ } // - // Rule 190: CatchClause ::= catch ( FormalParameter ) Block + // Rule 187: CatchClause ::= catch ( FormalParameter ) Block // - case 190: { + case 187: { //#line 2344 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2342 "x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(3); @@ -3581,9 +3581,9 @@ } // - // Rule 191: Finally ::= finally Block + // Rule 188: Finally ::= finally Block // - case 191: { + case 188: { //#line 2350 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2348 "x10/parser/x10.g" Block Block = (Block) getRhsSym(2); @@ -3593,9 +3593,9 @@ } // - // Rule 192: ClockedClause ::= clocked ( ClockList ) + // Rule 189: ClockedClause ::= clocked ( ClockList ) // - case 192: { + case 189: { //#line 2356 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2354 "x10/parser/x10.g" List<Expr> ClockList = (List<Expr>) getRhsSym(3); @@ -3605,9 +3605,9 @@ } // - // Rule 193: AsyncStatement ::= async ClockedClauseopt Statement + // Rule 190: AsyncStatement ::= async ClockedClauseopt Statement // - case 193: { + case 190: { //#line 2363 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2361 "x10/parser/x10.g" List<Expr> ClockedClauseopt = (List<Expr>) getRhsSym(2); @@ -3619,9 +3619,9 @@ } // - // Rule 194: AsyncStatement ::= clocked async Statement + // Rule 191: AsyncStatement ::= clocked async Statement // - case 194: { + case 191: { //#line 2368 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2366 "x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(3); @@ -3631,9 +3631,9 @@ } // - // Rule 195: AtStatement ::= at PlaceExpressionSingleList Statement + // Rule 192: AtStatement ::= at PlaceExpressionSingleList Statement // - case 195: { + case 192: { //#line 2375 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2373 "x10/parser/x10.g" Expr PlaceExpressionSingleList = (Expr) getRhsSym(2); @@ -3645,9 +3645,9 @@ } // - // Rule 196: AtomicStatement ::= atomic Statement + // Rule 193: AtomicStatement ::= atomic Statement // - case 196: { + case 193: { //#line 2381 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2379 "x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(2); @@ -3657,9 +3657,9 @@ } // - // Rule 197: WhenStatement ::= when ( Expression ) Statement + // Rule 194: WhenStatement ::= when ( Expression ) Statement // - case 197: { + case 194: { //#line 2388 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2386 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3671,120 +3671,9 @@ } // - // Rule 198: WhenStatement ::= WhenStatement or$or ( Expression ) Statement + // Rule 195: AtEachStatement ::= ateach ( LoopIndex in Expression ) ClockedClauseopt Statement // - case 198: { - //#line 2393 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2391 "x10/parser/x10.g" - When WhenStatement = (When) getRhsSym(1); - //#line 2391 "x10/parser/x10.g" - IToken or = (IToken) getRhsIToken(2); - //#line 2391 "x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(4); - //#line 2391 "x10/parser/x10.g" - Stmt Statement = (Stmt) getRhsSym(6); - //#line 2393 "lpg.generator/templates/java/btParserTemplateF.gi" - WhenStatement.addBranch(pos(getRhsFirstTokenIndex(2), getRightSpan()), Expression, Statement); - setResult(WhenStatement); - break; - } - - // - // Rule 199: ForEachStatement ::= foreach ( LoopIndex in Expression ) ClockedClauseopt Statement - // - case 199: { - //#line 2400 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2398 "x10/parser/x10.g" - X10Formal LoopIndex = (X10Formal) getRhsSym(3); - //#line 2398 "x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(5); - //#line 2398 "x10/parser/x10.g" - List<Expr> ClockedClauseopt = (List<Expr>) getRhsSym(7); - //#line 2398 "x10/parser/x10.g" - Stmt Statement = (Stmt) getRhsSym(8); - //#line 2400 "lpg.generator/templates/java/btParserTemplateF.gi" - FlagsNode fn = LoopIndex.flags(); - if (! fn.flags().isFinal()) { - syntaxError("Enhanced foreach loop may not have var loop index" + LoopIndex, LoopIndex.position()); - fn = fn.flags(fn.flags().Final()); - LoopIndex = LoopIndex.flags(fn); - } - setResult(nf.ForEach(pos(), - LoopIndex, - Expression, - ClockedClauseopt, - Statement)); - break; - } - - // - // Rule 200: ForEachStatement ::= clocked foreach ( LoopIndex in Expression ) Statement - // - case 200: { - //#line 2415 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2413 "x10/parser/x10.g" - X10Formal LoopIndex = (X10Formal) getRhsSym(4); - //#line 2413 "x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(6); - //#line 2413 "x10/parser/x10.g" - Stmt Statement = (Stmt) getRhsSym(8); - //#line 2415 "lpg.generator/templates/java/btParserTemplateF.gi" - FlagsNode fn = LoopIndex.flags(); - if (! fn.flags().isFinal()) { - syntaxError("Enhanced foreach loop cannot have var loop index" + LoopIndex, LoopIndex.position()); - fn = fn.flags(fn.flags().Final()); - LoopIndex = LoopIndex.flags(fn); - } - setResult(nf.ForEach(pos(), - LoopIndex, - Expression, - Statement)); - break; - } - - // - // Rule 201: ForEachStatement ::= foreach ( Expression ) Statement - // - case 201: { - //#line 2429 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2427 "x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(3); - //#line 2427 "x10/parser/x10.g" - Stmt Statement = (Stmt) getRhsSym(5); - //#line 2429 "lpg.generator/templates/java/btParserTemplateF.gi" - Id name = nf.Id(pos(), Name.makeFresh()); - TypeNode type = nf.UnknownTypeNode(pos()); - setResult(nf.ForEach(pos(), - nf.X10Formal(pos(), nf.FlagsNode(pos(), Flags.FINAL), type, name, null, true), - Expression, - new TypedList<Expr>(new LinkedList<Expr>(), Expr.class, false), - Statement)); - break; - } - - // - // Rule 202: ForEachStatement ::= clocked foreach ( Expression ) Statement - // - case 202: { - //#line 2440 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2438 "x10/parser/x10.g" - Expr Expression = (Expr) getRhsSym(4); - //#line 2438 "x10/parser/x10.g" - Stmt Statement = (Stmt) getRhsSym(6); - //#line 2440 "lpg.generator/templates/java/btParserTemplateF.gi" - Id name = nf.Id(pos(), Name.makeFresh()); - TypeNode type = nf.UnknownTypeNode(pos()); - setResult(nf.ForEach(pos(), - nf.X10Formal(pos(), nf.FlagsNode(pos(), Flags.FINAL), type, name, null, true), - Expression, - Statement)); - break; - } - - // - // Rule 203: AtEachStatement ::= ateach ( LoopIndex in Expression ) ClockedClauseopt Statement - // - case 203: { + case 195: { //#line 2451 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2449 "x10/parser/x10.g" X10Formal LoopIndex = (X10Formal) getRhsSym(3); @@ -3810,9 +3699,9 @@ } // - // Rule 204: AtEachStatement ::= clocked ateach ( LoopIndex in Expression ) Statement + // Rule 196: AtEachStatement ::= clocked ateach ( LoopIndex in Expression ) Statement // - case 204: { + case 196: { //#line 2466 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2464 "x10/parser/x10.g" X10Formal LoopIndex = (X10Formal) getRhsSym(4); @@ -3835,9 +3724,9 @@ } // - // Rule 205: AtEachStatement ::= ateach ( Expression ) Statement + // Rule 197: AtEachStatement ::= ateach ( Expression ) Statement // - case 205: { + case 197: { //#line 2480 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2478 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3855,9 +3744,9 @@ } // - // Rule 206: AtEachStatement ::= clocked ateach ( Expression ) Statement + // Rule 198: AtEachStatement ::= clocked ateach ( Expression ) Statement // - case 206: { + case 198: { //#line 2491 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2489 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(4); @@ -3874,9 +3763,9 @@ } // - // Rule 207: EnhancedForStatement ::= for ( LoopIndex in Expression ) Statement + // Rule 199: EnhancedForStatement ::= for ( LoopIndex in Expression ) Statement // - case 207: { + case 199: { //#line 2501 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2499 "x10/parser/x10.g" X10Formal LoopIndex = (X10Formal) getRhsSym(3); @@ -3899,9 +3788,9 @@ } // - // Rule 208: EnhancedForStatement ::= for ( Expression ) Statement + // Rule 200: EnhancedForStatement ::= for ( Expression ) Statement // - case 208: { + case 200: { //#line 2515 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2513 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -3918,9 +3807,9 @@ } // - // Rule 209: FinishStatement ::= finish Statement + // Rule 201: FinishStatement ::= finish Statement // - case 209: { + case 201: { //#line 2527 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2525 "x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(2); @@ -3930,9 +3819,9 @@ } // - // Rule 210: FinishStatement ::= clocked finish Statement + // Rule 202: FinishStatement ::= clocked finish Statement // - case 210: { + case 202: { //#line 2532 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2530 "x10/parser/x10.g" Stmt Statement = (Stmt) getRhsSym(3); @@ -3942,9 +3831,9 @@ } // - // Rule 211: PlaceExpressionSingleList ::= ( PlaceExpression ) + // Rule 203: PlaceExpressionSingleList ::= ( PlaceExpression ) // - case 211: { + case 203: { //#line 2537 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2535 "x10/parser/x10.g" Expr PlaceExpression = (Expr) getRhsSym(2); @@ -3954,9 +3843,9 @@ } // - // Rule 213: NextStatement ::= next ; + // Rule 205: NextStatement ::= next ; // - case 213: { + case 205: { //#line 2545 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2545 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -3965,9 +3854,9 @@ } // - // Rule 214: ResumeStatement ::= resume ; + // Rule 206: ResumeStatement ::= resume ; // - case 214: { + case 206: { //#line 2551 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2551 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -3976,9 +3865,9 @@ } // - // Rule 215: ClockList ::= Clock + // Rule 207: ClockList ::= Clock // - case 215: { + case 207: { //#line 2557 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2555 "x10/parser/x10.g" Expr Clock = (Expr) getRhsSym(1); @@ -3990,9 +3879,9 @@ } // - // Rule 216: ClockList ::= ClockList , Clock + // Rule 208: ClockList ::= ClockList , Clock // - case 216: { + case 208: { //#line 2564 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2562 "x10/parser/x10.g" List<Expr> ClockList = (List<Expr>) getRhsSym(1); @@ -4005,9 +3894,9 @@ } // - // Rule 217: Clock ::= Expression + // Rule 209: Clock ::= Expression // - case 217: { + case 209: { //#line 2572 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2570 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(1); @@ -4017,9 +3906,9 @@ } // - // Rule 219: CastExpression ::= ExpressionName + // Rule 211: CastExpression ::= ExpressionName // - case 219: { + case 211: { //#line 2585 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2583 "x10/parser/x10.g" ParsedName ExpressionName = (ParsedName) getRhsSym(1); @@ -4029,9 +3918,9 @@ } // - // Rule 220: CastExpression ::= CastExpression as Type + // Rule 212: CastExpression ::= CastExpression as Type // - case 220: { + case 212: { //#line 2590 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2588 "x10/parser/x10.g" Expr CastExpression = (Expr) getRhsSym(1); @@ -4043,9 +3932,9 @@ } // - // Rule 221: TypeParamWithVarianceList ::= TypeParamWithVariance + // Rule 213: TypeParamWithVarianceList ::= TypeParamWithVariance // - case 221: { + case 213: { //#line 2597 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2595 "x10/parser/x10.g" TypeParamNode TypeParamWithVariance = (TypeParamNode) getRhsSym(1); @@ -4057,9 +3946,9 @@ } // - // Rule 222: TypeParamWithVarianceList ::= TypeParamWithVarianceList , TypeParamWithVariance + // Rule 214: TypeParamWithVarianceList ::= TypeParamWithVarianceList , TypeParamWithVariance // - case 222: { + case 214: { //#line 2604 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2602 "x10/parser/x10.g" List<TypeParamNode> TypeParamWithVarianceList = (List<TypeParamNode>) getRhsSym(1); @@ -4072,9 +3961,9 @@ } // - // Rule 223: TypeParameterList ::= TypeParameter + // Rule 215: TypeParameterList ::= TypeParameter // - case 223: { + case 215: { //#line 2611 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2609 "x10/parser/x10.g" TypeParamNode TypeParameter = (TypeParamNode) getRhsSym(1); @@ -4086,9 +3975,9 @@ } // - // Rule 224: TypeParameterList ::= TypeParameterList , TypeParameter + // Rule 216: TypeParameterList ::= TypeParameterList , TypeParameter // - case 224: { + case 216: { //#line 2618 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2616 "x10/parser/x10.g" List<TypeParamNode> TypeParameterList = (List<TypeParamNode>) getRhsSym(1); @@ -4101,9 +3990,9 @@ } // - // Rule 225: TypeParamWithVariance ::= Identifier + // Rule 217: TypeParamWithVariance ::= Identifier // - case 225: { + case 217: { //#line 2625 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2623 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4113,9 +4002,9 @@ } // - // Rule 226: TypeParamWithVariance ::= + Identifier + // Rule 218: TypeParamWithVariance ::= + Identifier // - case 226: { + case 218: { //#line 2630 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2628 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); @@ -4125,9 +4014,9 @@ } // - // Rule 227: TypeParamWithVariance ::= - Identifier + // Rule 219: TypeParamWithVariance ::= - Identifier // - case 227: { + case 219: { //#line 2635 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2633 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(2); @@ -4137,9 +4026,9 @@ } // - // Rule 228: TypeParameter ::= Identifier + // Rule 220: TypeParameter ::= Identifier // - case 228: { + case 220: { //#line 2641 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2639 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4149,9 +4038,9 @@ } // - // Rule 229: AssignmentExpression ::= Expression$expr1 -> Expression$expr2 + // Rule 221: AssignmentExpression ::= Expression$expr1 -> Expression$expr2 // - case 229: { + case 221: { //#line 2666 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2664 "x10/parser/x10.g" Expr expr1 = (Expr) getRhsSym(1); @@ -4164,9 +4053,9 @@ } // - // Rule 230: ClosureExpression ::= FormalParameters WhereClauseopt HasResultTypeopt Offersopt => ClosureBody + // Rule 222: ClosureExpression ::= FormalParameters WhereClauseopt HasResultTypeopt Offersopt => ClosureBody // - case 230: { + case 222: { //#line 2672 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2670 "x10/parser/x10.g" List<Formal> FormalParameters = (List<Formal>) getRhsSym(1); @@ -4185,9 +4074,9 @@ } // - // Rule 231: LastExpression ::= Expression + // Rule 223: LastExpression ::= Expression // - case 231: { + case 223: { //#line 2679 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2677 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(1); @@ -4197,9 +4086,9 @@ } // - // Rule 232: ClosureBody ::= ConditionalExpression + // Rule 224: ClosureBody ::= ConditionalExpression // - case 232: { + case 224: { //#line 2685 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2683 "x10/parser/x10.g" Expr ConditionalExpression = (Expr) getRhsSym(1); @@ -4209,9 +4098,9 @@ } // - // Rule 233: ClosureBody ::= Annotationsopt { BlockStatementsopt LastExpression } + // Rule 225: ClosureBody ::= Annotationsopt { BlockStatementsopt LastExpression } // - case 233: { + case 225: { //#line 2690 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2688 "x10/parser/x10.g" List<AnnotationNode> Annotationsopt = (List<AnnotationNode>) getRhsSym(1); @@ -4230,9 +4119,9 @@ } // - // Rule 234: ClosureBody ::= Annotationsopt Block + // Rule 226: ClosureBody ::= Annotationsopt Block // - case 234: { + case 226: { //#line 2700 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2698 "x10/parser/x10.g" List<AnnotationNode> Annotationsopt = (List<AnnotationNode>) getRhsSym(1); @@ -4246,9 +4135,9 @@ } // - // Rule 235: AtExpression ::= at PlaceExpressionSingleList ClosureBody + // Rule 227: AtExpression ::= at PlaceExpressionSingleList ClosureBody // - case 235: { + case 227: { //#line 2709 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2707 "x10/parser/x10.g" Expr PlaceExpressionSingleList = (Expr) getRhsSym(2); @@ -4260,9 +4149,9 @@ } // - // Rule 236: FinishExpression ::= finish ( Expression ) Block + // Rule 228: FinishExpression ::= finish ( Expression ) Block // - case 236: { + case 228: { //#line 2715 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2713 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); @@ -4274,23 +4163,23 @@ } // - // Rule 237: WhereClauseopt ::= $Empty + // Rule 229: WhereClauseopt ::= $Empty // - case 237: + case 229: setResult(null); break; // - // Rule 239: PlaceExpressionSingleListopt ::= $Empty + // Rule 231: PlaceExpressionSingleListopt ::= $Empty // - case 239: + case 231: setResult(null); break; // - // Rule 241: ClockedClauseopt ::= $Empty + // Rule 233: ClockedClauseopt ::= $Empty // - case 241: { + case 233: { //#line 2763 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2763 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -4299,9 +4188,9 @@ } // - // Rule 243: identifier ::= IDENTIFIER$ident + // Rule 235: identifier ::= IDENTIFIER$ident // - case 243: { + case 235: { //#line 2774 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2772 "x10/parser/x10.g" IToken ident = (IToken) getRhsIToken(1); @@ -4312,9 +4201,9 @@ } // - // Rule 244: TypeName ::= Identifier + // Rule 236: TypeName ::= Identifier // - case 244: { + case 236: { //#line 2781 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2779 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4324,9 +4213,9 @@ } // - // Rule 245: TypeName ::= TypeName . Identifier + // Rule 237: TypeName ::= TypeName . Identifier // - case 245: { + case 237: { //#line 2786 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2784 "x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(1); @@ -4342,9 +4231,9 @@ } // - // Rule 247: TypeArguments ::= [ TypeArgumentList ] + // Rule 239: TypeArguments ::= [ TypeArgumentList ] // - case 247: { + case 239: { //#line 2798 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2796 "x10/parser/x10.g" List<TypeNode> TypeArgumentList = (List<TypeNode>) getRhsSym(2); @@ -4354,9 +4243,9 @@ } // - // Rule 248: TypeArgumentList ::= Type + // Rule 240: TypeArgumentList ::= Type // - case 248: { + case 240: { //#line 2805 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2803 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); @@ -4368,9 +4257,9 @@ } // - // Rule 249: TypeArgumentList ::= TypeArgumentList , Type + // Rule 241: TypeArgumentList ::= TypeArgumentList , Type // - case 249: { + case 241: { //#line 2812 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2810 "x10/parser/x10.g" List<TypeNode> TypeArgumentList = (List<TypeNode>) getRhsSym(1); @@ -4382,9 +4271,9 @@ } // - // Rule 250: PackageName ::= Identifier + // Rule 242: PackageName ::= Identifier // - case 250: { + case 242: { //#line 2822 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2820 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4394,9 +4283,9 @@ } // - // Rule 251: PackageName ::= PackageName . Identifier + // Rule 243: PackageName ::= PackageName . Identifier // - case 251: { + case 243: { //#line 2827 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2825 "x10/parser/x10.g" ParsedName PackageName = (ParsedName) getRhsSym(1); @@ -4412,9 +4301,9 @@ } // - // Rule 252: ExpressionName ::= Identifier + // Rule 244: ExpressionName ::= Identifier // - case 252: { + case 244: { //#line 2843 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2841 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4424,9 +4313,9 @@ } // - // Rule 253: ExpressionName ::= AmbiguousName . Identifier + // Rule 245: ExpressionName ::= AmbiguousName . Identifier // - case 253: { + case 245: { //#line 2848 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2846 "x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -4442,9 +4331,9 @@ } // - // Rule 254: MethodName ::= Identifier + // Rule 246: MethodName ::= Identifier // - case 254: { + case 246: { //#line 2858 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2856 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4454,9 +4343,9 @@ } // - // Rule 255: MethodName ::= AmbiguousName . Identifier + // Rule 247: MethodName ::= AmbiguousName . Identifier // - case 255: { + case 247: { //#line 2863 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2861 "x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -4472,9 +4361,9 @@ } // - // Rule 256: PackageOrTypeName ::= Identifier + // Rule 248: PackageOrTypeName ::= Identifier // - case 256: { + case 248: { //#line 2873 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2871 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4484,9 +4373,9 @@ } // - // Rule 257: PackageOrTypeName ::= PackageOrTypeName . Identifier + // Rule 249: PackageOrTypeName ::= PackageOrTypeName . Identifier // - case 257: { + case 249: { //#line 2878 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2876 "x10/parser/x10.g" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(1); @@ -4502,9 +4391,9 @@ } // - // Rule 258: AmbiguousName ::= Identifier + // Rule 250: AmbiguousName ::= Identifier // - case 258: { + case 250: { //#line 2888 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2886 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(1); @@ -4514,9 +4403,9 @@ } // - // Rule 259: AmbiguousName ::= AmbiguousName . Identifier + // Rule 251: AmbiguousName ::= AmbiguousName . Identifier // - case 259: { + case 251: { //#line 2893 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2891 "x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); @@ -4532,9 +4421,9 @@ } // - // Rule 260: CompilationUnit ::= PackageDeclarationopt TypeDeclarationsopt + // Rule 252: CompilationUnit ::= PackageDeclarationopt TypeDeclarationsopt // - case 260: { + case 252: { //#line 2905 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2903 "x10/parser/x10.g" PackageNode PackageDeclarationopt = (PackageNode) getRhsSym(1); @@ -4559,9 +4448,9 @@ } // - // Rule 261: CompilationUnit ::= PackageDeclarationopt ImportDeclarations TypeDeclarationsopt + // Rule 253: CompilationUnit ::= PackageDeclarationopt ImportDeclarations TypeDeclarationsopt // - case 261: { + case 253: { //#line 2923 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2921 "x10/parser/x10.g" PackageNode PackageDeclarationopt = (PackageNode) getRhsSym(1); @@ -4578,9 +4467,9 @@ } // - // Rule 262: CompilationUnit ::= ImportDeclarations PackageDeclaration$misplacedPackageDeclaration ImportDeclarationsopt$misplacedImportDeclarations TypeDeclarationsopt + // Rule 254: CompilationUnit ::= ImportDeclarations PackageDeclaration$misplacedPackageDeclaration ImportDeclarationsopt$misplacedImportDeclarations TypeDeclarationsopt // - case 262: { + case 254: { //#line 2931 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2929 "x10/parser/x10.g" List<Import> ImportDeclarations = (List<Import>) getRhsSym(1); @@ -4601,9 +4490,9 @@ } // - // Rule 263: CompilationUnit ::= PackageDeclaration ImportDeclarations PackageDeclaration$misplacedPackageDeclaration ImportDeclarationsopt$misplacedImportDeclarations TypeDeclarationsopt + // Rule 255: CompilationUnit ::= PackageDeclaration ImportDeclarations PackageDeclaration$misplacedPackageDeclaration ImportDeclarationsopt$misplacedImportDeclarations TypeDeclarationsopt // - case 263: { + case 255: { //#line 2941 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2939 "x10/parser/x10.g" PackageNode PackageDeclaration = (PackageNode) getRhsSym(1); @@ -4626,9 +4515,9 @@ } // - // Rule 264: ImportDeclarations ::= ImportDeclaration + // Rule 256: ImportDeclarations ::= ImportDeclaration // - case 264: { + case 256: { //#line 2952 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2950 "x10/parser/x10.g" Import ImportDeclaration = (Import) getRhsSym(1); @@ -4640,9 +4529,9 @@ } // - // Rule 265: ImportDeclarations ::= ImportDeclarations ImportDeclaration + // Rule 257: ImportDeclarations ::= ImportDeclarations ImportDeclaration // - case 265: { + case 257: { //#line 2959 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2957 "x10/parser/x10.g" List<Import> ImportDeclarations = (List<Import>) getRhsSym(1); @@ -4656,9 +4545,9 @@ } // - // Rule 266: TypeDeclarations ::= TypeDeclaration + // Rule 258: TypeDeclarations ::= TypeDeclaration // - case 266: { + case 258: { //#line 2967 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2965 "x10/parser/x10.g" TopLevelDecl TypeDeclaration = (TopLevelDecl) getRhsSym(1); @@ -4671,9 +4560,9 @@ } // - // Rule 267: TypeDeclarations ::= TypeDeclarations TypeDeclaration + // Rule 259: TypeDeclarations ::= TypeDeclarations TypeDeclaration // - case 267: { + case 259: { //#line 2975 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2973 "x10/parser/x10.g" List<TopLevelDecl> TypeDeclarations = (List<TopLevelDecl>) getRhsSym(1); @@ -4687,9 +4576,9 @@ } // - // Rule 268: PackageDeclaration ::= Annotationsopt package PackageName ; + // Rule 260: PackageDeclaration ::= Annotationsopt package PackageName ; // - case 268: { + case 260: { //#line 2983 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2981 "x10/parser/x10.g" List<AnnotationNode> Annotationsopt = (List<AnnotationNode>) getRhsSym(1); @@ -4703,9 +4592,9 @@ } // - // Rule 271: SingleTypeImportDeclaration ::= import TypeName ; + // Rule 263: SingleTypeImportDeclaration ::= import TypeName ; // - case 271: { + case 263: { //#line 2997 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 2995 "x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(2); @@ -4715,9 +4604,9 @@ } // - // Rule 272: TypeImportOnDemandDeclaration ::= import PackageOrTypeName . * ; + // Rule 264: TypeImportOnDemandDeclaration ::= import PackageOrTypeName . * ; // - case 272: { + case 264: { //#line 3003 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3001 "x10/parser/x10.g" ParsedName PackageOrTypeName = (ParsedName) getRhsSym(2); @@ -4727,9 +4616,9 @@ } // - // Rule 276: TypeDeclaration ::= ; + // Rule 268: TypeDeclaration ::= ; // - case 276: { + case 268: { //#line 3018 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3018 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -4738,9 +4627,9 @@ } // - // Rule 277: Interfaces ::= implements InterfaceTypeList + // Rule 269: Interfaces ::= implements InterfaceTypeList // - case 277: { + case 269: { //#line 3135 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3133 "x10/parser/x10.g" List<TypeNode> InterfaceTypeList = (List<TypeNode>) getRhsSym(2); @@ -4750,9 +4639,9 @@ } // - // Rule 278: InterfaceTypeList ::= Type + // Rule 270: InterfaceTypeList ::= Type // - case 278: { + case 270: { //#line 3141 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3139 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); @@ -4764,9 +4653,9 @@ } // - // Rule 279: InterfaceTypeList ::= InterfaceTypeList , Type + // Rule 271: InterfaceTypeList ::= InterfaceTypeList , Type // - case 279: { + case 271: { //#line 3148 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3146 "x10/parser/x10.g" List<TypeNode> InterfaceTypeList = (List<TypeNode>) getRhsSym(1); @@ -4779,9 +4668,9 @@ } // - // Rule 280: ClassBody ::= { ClassBodyDeclarationsopt } + // Rule 272: ClassBody ::= { ClassBodyDeclarationsopt } // - case 280: { + case 272: { //#line 3158 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3156 "x10/parser/x10.g" List<ClassMember> ClassBodyDeclarationsopt = (List<ClassMember>) getRhsSym(2); @@ -4791,9 +4680,9 @@ } // - // Rule 282: ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration + // Rule 274: ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration // - case 282: { + case 274: { //#line 3165 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3163 "x10/parser/x10.g" List<ClassMember> ClassBodyDeclarations = (List<ClassMember>) getRhsSym(1); @@ -4806,9 +4695,9 @@ } // - // Rule 284: ClassBodyDeclaration ::= ConstructorDeclaration + // Rule 276: ClassBodyDeclaration ::= ConstructorDeclaration // - case 284: { + case 276: { //#line 3187 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3185 "x10/parser/x10.g" ConstructorDecl ConstructorDeclaration = (ConstructorDecl) getRhsSym(1); @@ -4820,9 +4709,9 @@ } // - // Rule 286: ClassMemberDeclaration ::= MethodDeclaration + // Rule 278: ClassMemberDeclaration ::= MethodDeclaration // - case 286: { + case 278: { //#line 3196 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3194 "x10/parser/x10.g" ClassMember MethodDeclaration = (ClassMember) getRhsSym(1); @@ -4834,9 +4723,9 @@ } // - // Rule 287: ClassMemberDeclaration ::= PropertyMethodDeclaration + // Rule 279: ClassMemberDeclaration ::= PropertyMethodDeclaration // - case 287: { + case 279: { //#line 3203 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3201 "x10/parser/x10.g" ClassMember PropertyMethodDeclaration = (ClassMember) getRhsSym(1); @@ -4848,9 +4737,9 @@ } // - // Rule 288: ClassMemberDeclaration ::= TypeDefDeclaration + // Rule 280: ClassMemberDeclaration ::= TypeDefDeclaration // - case 288: { + case 280: { //#line 3210 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3208 "x10/parser/x10.g" TypeDecl TypeDefDeclaration = (TypeDecl) getRhsSym(1); @@ -4862,9 +4751,9 @@ } // - // Rule 289: ClassMemberDeclaration ::= ClassDeclaration + // Rule 281: ClassMemberDeclaration ::= ClassDeclaration // - case 289: { + case 281: { //#line 3217 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3215 "x10/parser/x10.g" ClassDecl ClassDeclaration = (ClassDecl) getRhsSym(1); @@ -4876,9 +4765,9 @@ } // - // Rule 290: ClassMemberDeclaration ::= InterfaceDeclaration + // Rule 282: ClassMemberDeclaration ::= InterfaceDeclaration // - case 290: { + case 282: { //#line 3224 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3222 "x10/parser/x10.g" ClassDecl InterfaceDeclaration = (ClassDecl) getRhsSym(1); @@ -4890,9 +4779,9 @@ } // - // Rule 291: ClassMemberDeclaration ::= ; + // Rule 283: ClassMemberDeclaration ::= ; // - case 291: { + case 283: { //#line 3231 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 3231 "lpg.generator/templates/java/btParserTemplateF.gi" @@ -4902,9 +4791,9 @@ } // - // Rule 292: FormalDeclarators ::= FormalDeclarator + // Rule 284: FormalDeclarators ::= FormalDeclarator // - case 292: { + case 284: { ... [truncated message content] |
From: <bh...@us...> - 2010-09-28 18:13:30
|
Revision: 16753 http://x10.svn.sourceforge.net/x10/?rev=16753&view=rev Author: bherta Date: 2010-09-28 18:13:24 +0000 (Tue, 28 Sep 2010) Log Message: ----------- debug mapping improvements Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java trunk/x10.runtime/src-cpp/x10aux/debug.h Modified: trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java =================================================================== --- trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-09-28 17:33:08 UTC (rev 16752) +++ trunk/x10.compiler/src/x10cpp/debug/LineNumberMap.java 2010-09-28 18:13:24 UTC (rev 16753) @@ -17,6 +17,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.Hashtable; +import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import java.util.TreeSet; @@ -270,11 +271,17 @@ } + private static ArrayList<Integer> arrayMap = new ArrayList<Integer>(); + private static ArrayList<Integer> refMap = new ArrayList<Integer>(); + private static ArrayList<LocalVariableMapInfo> localVariables; + private static Hashtable<String, ArrayList<MemberVariableMapInfo>> memberVariables; + static int determineTypeId(String type) { + //System.out.println("looking up type \""+type+"\""); if (type.equals("x10.lang.Int") || type.startsWith("x10.lang.Int{")) return 5; - if (type.startsWith("x10.array.Array") || type.startsWith("x10.array.DistArray")) + if (type.startsWith("x10.array.Array") || type.startsWith("x10.array.DistArray") || type.startsWith("x10.lang.ValRail")) return 17; if (type.startsWith("x10.lang.PlaceLocalHandle")) return 15; @@ -300,13 +307,28 @@ return 10; if (type.equals("x10.lang.Char") || type.startsWith("x10.lang.Char{")) return 11; - - //System.out.println("Can't find a match for \""+type+"\" defaulting to Class"); return 12; } + static int determineSubtypeId(String type, ArrayList<Integer> list) + { + int bracketStart = type.indexOf('['); + int bracketEnd = type.lastIndexOf(']'); + if (bracketStart != -1 && bracketEnd != -1) + { + String subtype = type.substring(bracketStart+1, bracketEnd); + int subtypeId = determineTypeId(subtype); + list.add(subtypeId); + int position = list.size(); + list.add(determineSubtypeId(subtype, list)); + return position; + } + else + return -1; + } + private class LocalVariableMapInfo { int _x10name; // Index of the X10 variable name in _X10strings @@ -316,10 +338,8 @@ String _x10index; // Index of X10 file name in _X10sourceList int _x10startLine; // First line number of X10 line range int _x10endLine; // Last line number of X10 line range - } + } - private static ArrayList<LocalVariableMapInfo> localVariables; - public void addLocalVariableMapping(String name, String type, int startline, int endline, String file) { if (localVariables == null) @@ -328,7 +348,12 @@ LocalVariableMapInfo v = new LocalVariableMapInfo(); v._x10name = stringId(name); v._x10type = determineTypeId(type); - v._x10typeIndex = -1; // TODO? + if (v._x10type == 15) + v._x10typeIndex = determineSubtypeId(type, refMap); + else if (v._x10type == 17) + v._x10typeIndex = determineSubtypeId(type, arrayMap); + else + v._x10typeIndex = -1; v._cppName = stringId(Emitter.mangled_non_method_name(name)); v._x10index = file; v._x10startLine = startline; @@ -338,16 +363,13 @@ private class MemberVariableMapInfo { - int _x10Type; // Classification of this type + int _x10type; // Classification of this type int _x10typeIndex; // Index of the X10 type into appropriate _X10typeMap int _x10memberName; // Index of the X10 member name in _X10strings int _cppMemberName; // Index of the C++ member name in _X10strings int _cppClass; // Index of the C++ containing struct/class name in _X10strings } - //private static ArrayList<MemberVariableMapInfo> memberVariables; - private static Hashtable<String, ArrayList<MemberVariableMapInfo>> memberVariables; - public void addClassMemberVariable(String name, String type, String containingClass) { if (memberVariables == null) @@ -360,8 +382,13 @@ } MemberVariableMapInfo v = new MemberVariableMapInfo(); - v._x10Type = determineTypeId(type); - v._x10typeIndex = stringId(type); + v._x10type = determineTypeId(type); + if (v._x10type == 15) + v._x10typeIndex = determineSubtypeId(type, refMap); + else if (v._x10type == 17) + v._x10typeIndex = determineSubtypeId(type, arrayMap); + else + v._x10typeIndex = -1; v._x10memberName = stringId(name); v._cppMemberName = stringId(Emitter.mangled_non_method_name(name)); v._cppClass = stringId(containingClass); @@ -804,9 +831,7 @@ w.forceNewline(); } - // variable map stuff - // TODO - check to see if they exist before printing them - + // variable map stuff w.writeln("static const struct _X10LocalVarMap _X10variableNameList[] __attribute__((used)) "+debugDataSectionAttr+" = {"); for (LocalVariableMapInfo v : localVariables) w.writeln(" { "+offsets[v._x10name]+", "+v._x10type+", "+v._x10typeIndex+", "+offsets[v._cppName]+", "+findFile(v._x10index, files)+", "+v._x10startLine+", "+v._x10endLine+" }, // "+m.lookupString(v._x10name)); @@ -819,7 +844,7 @@ { w.writeln("static const struct _X10TypeMember _X10"+classname+"Members[] __attribute__((used)) "+debugDataSectionAttr+" = {"); for (MemberVariableMapInfo v : memberVariables.get(classname)) - w.writeln(" { "+v._x10Type+", "+v._x10typeIndex+", "+offsets[v._x10memberName]+", "+offsets[v._cppMemberName]+", "+offsets[v._cppClass]+" }, // "+m.lookupString(v._x10memberName)); + w.writeln(" { "+v._x10type+", "+v._x10typeIndex+", "+offsets[v._x10memberName]+", "+offsets[v._cppMemberName]+", "+offsets[v._cppClass]+" }, // "+m.lookupString(v._x10memberName)); w.writeln("};"); w.forceNewline(); } @@ -839,10 +864,25 @@ w.writeln("};"); w.forceNewline(); - w.writeln("static const struct _X10ArrayMap _X10ArrayMapList[] __attribute__((used)) "+debugDataSectionAttr+" = {"); - // TODO - w.writeln("};"); - w.forceNewline(); + if (!arrayMap.isEmpty()) + { + w.writeln("static const struct _X10ArrayMap _X10ArrayMapList[] __attribute__((used)) "+debugDataSectionAttr+" = {"); + Iterator<Integer> iterator = arrayMap.iterator(); + while(iterator.hasNext()) + w.writeln(" { "+iterator.next()+", "+iterator.next()+" },"); + w.writeln("};"); + w.forceNewline(); + } + + if (!refMap.isEmpty()) + { + w.writeln("static const struct _X10RefMap _X10RefMapList[] __attribute__((used)) "+debugDataSectionAttr+" = {"); + Iterator<Integer> iterator = refMap.iterator(); + while(iterator.hasNext()) + w.writeln(" { "+iterator.next()+", "+iterator.next()+" },"); + w.writeln("};"); + w.forceNewline(); + } } // A meta-structure that refers to all of the above @@ -866,11 +906,13 @@ } else { w.writeln("0,"); } - // TODO - check to see if they exist before printing them w.writeln("sizeof(_X10variableNameList),"); w.writeln("sizeof(_X10ClassMapList),"); w.writeln("sizeof(_X10ClosureMapList),"); - w.writeln("sizeof(_X10ArrayMapList),"); + if (!arrayMap.isEmpty()) + w.writeln("sizeof(_X10ArrayMapList),"); + else + w.writeln("0,"); w.writeln("_X10strings,"); if (!m.isEmpty()) { @@ -888,11 +930,13 @@ w.writeln("NULL,"); } - // TODO - check to see if they exist before printing them w.writeln("_X10variableNameList,"); w.writeln("_X10ClassMapList,"); w.writeln("_X10ClosureMapList,"); - w.write("_X10ArrayMapList"); + if (!arrayMap.isEmpty()) + w.write("_X10ArrayMapList"); + else + w.write("NULL"); w.end(); w.newline(); w.writeln("};"); Modified: trunk/x10.runtime/src-cpp/x10aux/debug.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-09-28 17:33:08 UTC (rev 16752) +++ trunk/x10.runtime/src-cpp/x10aux/debug.h 2010-09-28 18:13:24 UTC (rev 16753) @@ -105,7 +105,7 @@ struct _X10TypeMember { - uint32_t _x10Type; // Classification of this type + uint32_t _x10type; // Classification of this type uint32_t _x10typeIndex; // Index of the X10 type into appropriate _X10typeMap uint32_t _x10memberName; // Index of the X10 member name in _X10strings uint32_t _cppMemberName; // Index of the C++ member name in _X10strings @@ -135,20 +135,20 @@ struct _X10ArrayMap { - uint32_t _x10type; // Classification of this type + uint32_t _x10type; // Classification of the type inside the array uint32_t _x10typeIndex; // Index of the X10 type into appropriate _X10typeMap (if applicable) }; struct _X10RefMap { - uint32_t _x10type; // Classification of this type - uint32_t _x10ReferredType; // type number of the referred type + uint32_t _x10type; // Classification of the type inside the reference + uint32_t _x10typeIndex; // Index of the X10 type into appropriate _X10typeMap (if applicable) }; struct _X10TypedefMap { uint32_t _x10type; // Classification of this type - uint32_t _x10ReferredType; // type number of the referred type + uint32_t _x10typeIndex; // Index of the X10 type into appropriate _X10typeMap (if applicable) uint32_t _x10Name; // Offset to the name of the typedef in _X10strings }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-09-28 21:35:41
|
Revision: 16767 http://x10.svn.sourceforge.net/x10/?rev=16767&view=rev Author: yzibin Date: 2010-09-28 21:35:34 +0000 (Tue, 28 Sep 2010) Log Message: ----------- - added a private method that includes the fields initializers, and added a call to it after AssignProperty call. - fixed XTENLANG-1451 - checking that "this" is not used until after AssignPropertyCall, and that AssignPropertyCall is called exactly once (after a super call). Modified Paths: -------------- trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 Modified: trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2010-09-28 21:35:34 UTC (rev 16767) @@ -90,13 +90,6 @@ return n; } - /** - * ConstructorCall and AssignPropertyCall are a static context. - */ - public Context enterScope(Context c) { - return c.pushStatic(); - } - /** Reconstruct the constructor call. */ protected ConstructorCall_c reconstruct(Expr qualifier, List<Expr> arguments) { if (qualifier != this.qualifier || ! CollectionUtil.allEqual(arguments, this.arguments)) { Modified: trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java 2010-09-28 21:35:34 UTC (rev 16767) @@ -126,12 +126,6 @@ return sb.toString(); } - /** - * ConstructorCall and AssignPropertyCall are a static context. - */ - public Context enterScope(Context c) { - return c.pushStatic(); - } public Node typeCheck(ContextVisitor tc) { TypeSystem ts = tc.typeSystem(); @@ -165,6 +159,7 @@ checkReturnType(tc, pos, thisConstructor, definedProperties, arguments); } + /* We check that "this" is not allowed in CheckEscapingThis.CheckCtor ThisChecker thisC = (ThisChecker) new ThisChecker(tc.job()).context(tc.context()); for (int i=0; i < aSize; i++) { Expr arg = arguments.get(i); @@ -173,7 +168,7 @@ if (thisC.error()) { Errors.issue(job, new Errors.ThisNotPermittedInPropertyInitializer(arg, position())); } - } + } */ List<X10FieldInstance> properties = new ArrayList<X10FieldInstance>(); for (FieldInstance fi : definedProperties) { Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-28 21:35:34 UTC (rev 16767) @@ -377,7 +377,85 @@ } } + static enum CtorState { Start, SawCtor, SawProperty }; + public class CheckCtor extends NodeVisitor { + private CtorState state = CtorState.Start; + private boolean wasSuperCall = false; + private final X10ConstructorDecl_c ctor; + private CheckCtor(X10ConstructorDecl_c ctor) { + this.ctor = ctor; + if (getConstructorCall(ctor)==null) { + // There is no 'this(...)' or 'super(...)' calls, so we implicitly start after a 'super()' call + state = CtorState.SawCtor; + wasSuperCall = true; + } + } + private void postCheck() { + switch (state) { + case Start: + assert false : "There must be a super call (either explicit or implicit)"; + case SawCtor: + if (hasProperties && wasSuperCall) + reportError("You must call 'property(...)' at least once",ctor.position()); + break; + } + } + + @Override public Node leave(Node old, Node n, NodeVisitor v) { + Position pos = n.position(); + if (n instanceof ConstructorCall) { + ConstructorCall constructorCall = (ConstructorCall) n; + switch (state) { + case Start: + state = CtorState.SawCtor; + wasSuperCall = constructorCall.kind()==ConstructorCall.SUPER; + break; + case SawCtor: + reportError("Can only have a single 'this(...)' or 'super(...)' in a constructor",pos); + break; + case SawProperty: + reportError("'this(...)' or 'super(...)' must come before 'property(...)'",pos); + break; + } + } else if (n instanceof AssignPropertyCall) { + switch (state) { + case Start: + assert false : "implicit super() call is handled at the beginning, see getConstructorCall"; + case SawCtor: + if (!wasSuperCall) + reportError("You cannot call 'property(...)' after 'this(...)'",pos); + else if (!hasProperties) { + // This error is already reported: "The property initializer must have the same number of arguments as properties for the class." + //reportError("You can call 'property(...)' only if the class defined properties",pos); + } else { + state = CtorState.SawProperty; + } + break; + case SawProperty: + reportError("You can call 'property(...)' at most once",pos); + break; + } + + } else if (isThis(n)) { + Special special = (Special) n; + if (special.kind()==Special.SUPER) { + if (state==CtorState.Start) + reportError("You can use 'super' only after 'super(...)'",pos); + } else if (!canUseThis()) + reportError(hasProperties ? "Can use 'this' only after 'property(...)'" : "Can use 'this' only after 'this(...)' or 'super(...)'", pos); + } + return n; + } + private boolean canUseThis() { + return state==CtorState.SawProperty || // after call to 'property(...)' + (!hasProperties && state==CtorState.SawCtor) || // after call to 'this(...)' or 'super(...)' if there are no properties + (state==CtorState.SawCtor && !wasSuperCall); // after call to 'this(...)' + } + + } + + // we gather info on every private/final/@NonEscaping method private static class MethodInfo { private Set<FieldDef> canReadFrom = null; @@ -389,6 +467,7 @@ private final X10NodeFactory nf; private final X10TypeSystem ts; private final X10ClassDecl_c xlass; + private final boolean hasProperties; // this this class defined properties (excluding properties of the sueprclass). if so, there must be exactly one "property(...)" private final boolean isXlassFinal; private final Type xlassType; // the keys are either X10ConstructorDecl_c or X10MethodDecl_c @@ -419,6 +498,7 @@ this.ts = ts; nf = (X10NodeFactory)ts.extensionInfo().nodeFactory(); this.xlass = xlass; + hasProperties = xlass.properties()!=null && xlass.properties().size()>0; isXlassFinal = xlass.flags().flags().isFinal(); this.xlassType = X10TypeMixin.baseType(xlass.classDef().asType()); // calculate the set of all fields (including inherited fields) @@ -564,9 +644,13 @@ if (procBody==null) continue; assert proc instanceof X10ConstructorDecl_c : proc; final X10ConstructorDecl_c ctor = (X10ConstructorDecl_c) proc; + final CheckCtor checkCtor = new CheckCtor(ctor); + ctor.visit(checkCtor); + checkCtor.postCheck(); // ctors are implicitly NonEscaping - if (isCallingOtherCtor(ctor)) { - // ignore in dataflow ctors that call other ctors (using "this(...)"). We can reuse ConstructorCallChecker, but for better efficiency, we just check it directly + final ConstructorCall cc = getConstructorCall(ctor); + if (cc!=null && cc.kind() == ConstructorCall.THIS) { + // ignore in dataflow ctors that call other ctors (using "this(...)"). } else { // add field initializers to all ctors ctorsForDataFlow.add(ctor); @@ -617,19 +701,17 @@ } return null; } - private static boolean isCallingOtherCtor(X10ConstructorDecl_c ctor) { + private static ConstructorCall getConstructorCall(X10ConstructorDecl_c ctor) { + // We can reuse ConstructorCallChecker, but for better efficiency, we just check it directly final Block ctorBody = ctor.body(); assert ctorBody!=null; final List<Stmt> stmts = ctorBody.statements(); for (Stmt s : stmts) { if (s instanceof ConstructorCall) { - ConstructorCall cc = (ConstructorCall) s; - if (cc.kind() == ConstructorCall.THIS) { - return true; - } + return (ConstructorCall) s; } } - return false; + return null; } private X10MethodDecl_c findMethod(X10Call call) { MethodInstance mi2 = call.methodInstance(); @@ -730,7 +812,17 @@ private boolean isThis(Node n) { if (n==null || !(n instanceof Special)) return false; final Special special = (Special) n; - return //special.kind()==Special.THIS && // both this and super cannot escape - ts.typeEquals(X10TypeMixin.baseType(special.type()), xlassType,null); + final Type type = X10TypeMixin.baseType(special.type()); + // both this and super cannot escape + // for "super.", it resolves to the superclass, so I need to go up the superclasses + Type thisClass = xlassType; + while (thisClass!=null) { + if (ts.typeEquals(type, thisClass,null)) return true; + if (!thisClass.isClass()) return false; + final Type superClass = thisClass.toClass().superClass(); + if (superClass==null) return false; + thisClass = X10TypeMixin.baseType(superClass); + } + return false; } } \ No newline at end of file Modified: trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java =================================================================== --- trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.compiler/src/x10/visit/FieldInitializerMover.java 2010-09-28 21:35:34 UTC (rev 16767) @@ -30,6 +30,11 @@ import polyglot.ast.NodeFactory; import polyglot.ast.Special; import polyglot.ast.Stmt; +import polyglot.ast.MethodDecl_c; +import polyglot.ast.TypeNode; +import polyglot.ast.MethodDecl; +import polyglot.ast.Call; +import polyglot.ast.Id; import polyglot.frontend.Job; import polyglot.types.ConstructorInstance; import polyglot.types.FieldDef; @@ -37,6 +42,12 @@ import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.TypeSystem; +import polyglot.types.Flags; +import polyglot.types.Types; +import polyglot.types.Name; +import polyglot.types.MethodDef; +import polyglot.types.Ref; +import polyglot.types.FieldInstance; import polyglot.util.Position; import polyglot.visit.ContextVisitor; import polyglot.visit.NodeVisitor; @@ -44,11 +55,29 @@ import x10.types.X10Def; import x10.types.X10TypeMixin; import x10.types.X10TypeSystem; +import x10.ast.X10MethodDecl_c; +import x10.ast.AssignPropertyCall; /** * Visitor that moves field initializers to the constructor * and insert explicit super constructor invocations * unless constructor is annotated @NoSuperCall. + * +Yoav added: + * Field initializers are placed after the AssignProperty call, because we have a 3-phase init: super, properties, ctor-code + * Note that the type of a field may refer to a property, so even field assignment is prohibited until after the AssignProperty call. + * + * Finally, we do not move constant fields because it is possible to switch over a constant field (final fields with compile-time known value): + * E.g., in Java (and similarly in X10): +class Test { + final int i=2+1; + void test() { + switch(3*4) { + case i: + case 4: + } + } +} */ public class FieldInitializerMover extends ContextVisitor { X10TypeSystem xts; @@ -68,104 +97,146 @@ Type t = (Type) xts.systemResolver().find(QName.make("x10.compiler.NoSuperCall")); return ((X10Def) cdecl.constructorDef()).annotationsMatching(t).isEmpty(); } + class FindProperty extends NodeVisitor { + private final Stmt evalCall; + private boolean didFindProperty = false; + private FindProperty(Stmt evalCall) { + this.evalCall = evalCall; + } + @Override public Node leave(Node old, Node n, NodeVisitor v) { + if (n instanceof AssignPropertyCall) { + AssignPropertyCall propCall = (AssignPropertyCall) n; + didFindProperty = true; + return nf.Block(n.position().markCompilerGenerated(),propCall,evalCall); + } + return n; + } + } + private ClassDecl changeClass(ClassDecl cdecl) throws SemanticException { + final ClassBody cb = cdecl.body(); + final List<ClassMember> members = new ArrayList<ClassMember>(); - @Override - public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { - if (n instanceof ClassDecl) { - ClassDecl cdecl = (ClassDecl) n; - ClassBody cb = cdecl.body(); - List<Stmt> assignments = new ArrayList<Stmt>(); - List<ClassMember> members = new ArrayList<ClassMember>(); - - for (ClassMember cm : cb.members()) { - if (cm instanceof FieldDecl) { - FieldDecl fd = (FieldDecl) cm; - FieldDef def = fd.fieldDef(); + final Position p = cdecl.position().markCompilerGenerated(); + final Special this_ = (Special) nf.This(p).type(cdecl.classDef().asType()); - if (fd.init() != null && !def.flags().isStatic() && !def.isConstant()) { - Position p = fd.init().position(); - Special this_ = nf.This(p); - this_ = (Special) this_.type(def.asInstance().container()); - FieldAssign a = nf.FieldAssign(p, this_, nf.Id(p, def.name()), Assign.ASSIGN, fd.init()); - a = a.fieldInstance(def.asInstance()); - a = (FieldAssign) a.type(def.asInstance().type()); - - assert this_.type() != null; - assert a.type() != null; - - Eval eval = nf.Eval(p, a); - assignments.add(eval); - - fd = fd.init(null); - } + List<Stmt> assignments = new ArrayList<Stmt>(); + for (ClassMember cm : cb.members()) { + if (cm instanceof FieldDecl) { + FieldDecl fd = (FieldDecl) cm; + FieldDef def = fd.fieldDef(); - members.add(fd); + if (fd.init() != null && !def.flags().isStatic() && !def.isConstant()) { + final FieldInstance fieldInstance = def.asInstance(); + + FieldAssign a = nf.FieldAssign(p, this_, nf.Id(p, def.name()), Assign.ASSIGN, fd.init()); + a = a.fieldInstance(fieldInstance); + a = (FieldAssign) a.type(fieldInstance.type()); + + assert this_.type() != null; + assert a.type() != null; + + Eval eval = nf.Eval(p, a); + assignments.add(eval); + + fd = fd.init(null); } - else { - members.add(cm); - } + + members.add(fd); } - - /* if (assignments.size() > 0) */ { - List<ClassMember> members2 = new ArrayList<ClassMember>(); + else { + members.add(cm); + } + } + Stmt evalCall = nf.Block(p); // an empty statement + if (assignments.size()>0) { + // create a private method that includes all the field initializers + final Ref<Type> refRet = Types.ref(ts.Void()); + TypeNode returnType = nf.TypeNodeFromQualifiedName(p,QName.make("void")).typeRef(refRet); + final Name name = Name.makeFresh("__fieldInitializers"); + final Id nameId = nf.Id(p, name); + final Flags flags = Flags.PRIVATE.Final(); + MethodDecl method = nf.MethodDecl(p,nf.FlagsNode(p, flags),returnType, nameId, + Collections.EMPTY_LIST, nf.Block(p,assignments)); + MethodDef md = ts.methodDef(p,Types.ref(cdecl.classDef().asType()), flags,refRet,name,Collections.EMPTY_LIST); + method = method.methodDef(md); + members.add(method); - for (ClassMember cm : members) { - if (cm instanceof ConstructorDecl) { - ConstructorDecl cd = (ConstructorDecl) cm; + // create the call to __fieldInitializers + Call call = nf.Call(p,this_,nameId,Collections.EMPTY_LIST).methodInstance(md.asInstance()); + call = (Call) call.type(ts.Void()); + evalCall = nf.Eval(p, call); + } - Block body = cd.body(); - if (body == null) { - body = job().extensionInfo().nodeFactory().Block(cd.position()); - } - List<Stmt> stmts = body.statements(); - if (stmts.size() > 0) { - Stmt s = stmts.get(0); - if (s instanceof ConstructorCall) { - ConstructorCall cc = (ConstructorCall) s; - if (cc.kind() == ConstructorCall.SUPER) { - List<Stmt> ss = new ArrayList<Stmt>(); - ss.add(s); - ss.addAll(assignments); - ss.addAll(stmts.subList(1, stmts.size())); - body = body.statements(ss); - } - } - else { - // implicit super call - List<Stmt> ss = new ArrayList<Stmt>(); - if (cdecl.superClass() != null && mustCallSuper(cd)) - ss.add(superCall(cdecl.superClass().type())); - ss.addAll(assignments); - ss.addAll(stmts); - body = body.statements(ss); - } - } - else { - // implicit super call + final List<ClassMember> members2 = new ArrayList<ClassMember>(); + + for (ClassMember cm : members) { + if (cm instanceof ConstructorDecl) { + ConstructorDecl cd = (ConstructorDecl) cm; + + Block body = cd.body(); + if (body == null) { + body = nf.Block(p); + } + + // if there is a property(...) call, then we replace it with: { property(...); __fieldInitializers(); } + FindProperty findProperty = new FindProperty(evalCall); + body = (Block) body.visit(findProperty); + boolean didFindProperty = findProperty.didFindProperty; + + List<Stmt> stmts = body.statements(); + if (stmts.size() > 0) { + Stmt s = stmts.get(0); + if (s instanceof ConstructorCall) { + ConstructorCall cc = (ConstructorCall) s; + if (cc.kind() == ConstructorCall.SUPER) { List<Stmt> ss = new ArrayList<Stmt>(); - if (cdecl.superClass() != null && mustCallSuper(cd)) - ss.add(superCall(cdecl.superClass().type())); - ss.addAll(assignments); - ss.addAll(stmts); + ss.add(s); + if (!didFindProperty) ss.add(evalCall); + ss.addAll(stmts.subList(1, stmts.size())); body = body.statements(ss); } - - if (body != cd.body()) { - cd = (ConstructorDecl) cd.body(body); - } - - members2.add(cd); } else { - members2.add(cm); + // implicit super call + List<Stmt> ss = new ArrayList<Stmt>(); + if (cdecl.superClass() != null && mustCallSuper(cd)) + ss.add(superCall(cdecl.superClass().type())); + if (!didFindProperty) ss.add(evalCall); + ss.addAll(stmts); + body = body.statements(ss); } } - - members = members2; + else { + // implicit super call + List<Stmt> ss = new ArrayList<Stmt>(); + if (cdecl.superClass() != null && mustCallSuper(cd)) + ss.add(superCall(cdecl.superClass().type())); + if (!didFindProperty) ss.add(evalCall); + ss.addAll(stmts); + body = body.statements(ss); + } + + if (body != cd.body()) { + cd = (ConstructorDecl) cd.body(body); + } + + members2.add(cd); } - - return cdecl.body(cb.members(members)); + else { + members2.add(cm); + } } + + + return cdecl.body(cb.members(members2)); + } + @Override + public Node leaveCall(Node old, Node n, NodeVisitor v) throws SemanticException { + if (n instanceof ClassDecl) { + final ClassDecl cdecl = (ClassDecl) n; + if (!cdecl.flags().flags().isInterface()) + return changeClass(cdecl); + } return super.leaveCall(old, n, v); } Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-28 21:35:34 UTC (rev 16767) @@ -772,3 +772,13 @@ this.b = b; } } + +class TestSwitchOnFinalVal { + val i=2+1; + def this() { + switch(3+0) { + case i: + case 4: + } + } +} \ No newline at end of file Modified: trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 =================================================================== --- trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 2010-09-28 21:35:33 UTC (rev 16766) +++ trunk/x10.tests/examples/Misc/RecursiveConstraint.x10 2010-09-28 21:35:34 UTC (rev 16767) @@ -26,17 +26,17 @@ private val item: int; def this(item:int){ + property(here); this.left = null; this.right = null; this.item = item; - property(here); } def this(left:Tree{self.home==here}, right:Tree, item:int){ + property(here); this.left = left; this.right = right; this.item = item; - property(here); } static def bottomUpTree(item:int, depth:int): Tree{self.home==here} = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-09-29 17:38:39
|
Revision: 16788 http://x10.svn.sourceforge.net/x10/?rev=16788&view=rev Author: dgrove-oss Date: 2010-09-29 17:38:33 +0000 (Wed, 29 Sep 2010) Log Message: ----------- Change AtomicBoolean from being a NativeRep class to being a normal X10 class with a few @Native methods. Modified Paths: -------------- trunk/x10.runtime/src-cpp/Makefile trunk/x10.runtime/src-cpp/x10rt.h trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.cc trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.h trunk/x10.runtime/src-x10/x10/compiler/Volatile.x10 trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h Modified: trunk/x10.runtime/src-cpp/Makefile =================================================================== --- trunk/x10.runtime/src-cpp/Makefile 2010-09-29 17:04:42 UTC (rev 16787) +++ trunk/x10.runtime/src-cpp/Makefile 2010-09-29 17:38:33 UTC (rev 16788) @@ -95,6 +95,7 @@ x10aux/alloc.o \ x10aux/assert.o \ x10aux/atomic_ops.o \ + x10aux/atomic_boolean_funs.o \ x10aux/basic_functions.o \ x10aux/boolean_utils.o \ x10aux/bootstrap.o \ @@ -147,7 +148,6 @@ x10/lang/Thread.o \ x10/util/GrowableRail.o \ x10/util/IndexedMemoryChunk.o \ - x10/util/concurrent/atomic/AtomicBoolean.o \ x10/util/concurrent/atomic/AtomicInteger.o \ x10/util/concurrent/atomic/AtomicLong.o \ x10/util/concurrent/atomic/AtomicReference.o Deleted: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2010-09-29 17:04:42 UTC (rev 16787) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc 2010-09-29 17:38:33 UTC (rev 16788) @@ -1,44 +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. - */ - -#include <x10/util/concurrent/atomic/AtomicBoolean.h> - -using namespace x10::lang; -using namespace x10::util::concurrent::atomic; - -x10aux::ref<AtomicBoolean> -AtomicBoolean::_make() { - x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc<AtomicBoolean>()) AtomicBoolean(); - this_->_constructor(0); - return this_; -} - -x10aux::ref<AtomicBoolean> -AtomicBoolean::_make(x10_boolean val) { - x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc<AtomicBoolean>()) AtomicBoolean(); - this_->_constructor(val); - return this_; -} - -void AtomicBoolean::_serialize_body(x10aux::serialization_buffer &buf) { - this->Object::_serialize_body(buf); -} - -void AtomicBoolean::_deserialize_body(x10aux::deserialization_buffer& buf) { - this->Object::_deserialize_body(buf); -} - -const x10aux::serialization_id_t AtomicBoolean::_serialization_id = - x10aux::DeserializationDispatcher::addDeserializer(AtomicBoolean::_deserializer<Reference>); - -RTT_CC_DECLS1(AtomicBoolean, "x10.util.concurrent.atomic.AtomicBoolean", Object) - -// vim:tabstop=4:shiftwidth=4:expandtab Deleted: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2010-09-29 17:04:42 UTC (rev 16787) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h 2010-09-29 17:38:33 UTC (rev 16788) @@ -1,104 +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. - */ - -#ifndef X10_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H -#define X10_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H - -#include <x10/lang/Object.h> -#include <x10aux/serialization.h> -#include <x10aux/atomic_ops.h> -#include <x10aux/boolean_utils.h> - -namespace x10 { - namespace util { - namespace concurrent { - namespace atomic { - - /** - * Native implementation of AtomicBoolean. - */ - class AtomicBoolean : public x10::lang::Object { - public: - RTT_H_DECLS_CLASS; - - static x10aux::ref<AtomicBoolean> _make(); - static x10aux::ref<AtomicBoolean> _make(x10_boolean val); - - protected: - x10aux::ref<AtomicBoolean> _constructor(x10_boolean val) { - this->x10::lang::Object::_constructor(); - _val = (val ? 1 :0); - return this; - } - - public: - static const x10aux::serialization_id_t _serialization_id; - - virtual x10aux::serialization_id_t _get_serialization_id() { return _serialization_id; }; - - virtual void _serialize_body(x10aux::serialization_buffer &buf); - - template<class T> static x10aux::ref<T> _deserializer(x10aux::deserialization_buffer &buf); - - virtual void _deserialize_body(x10aux::deserialization_buffer& buf); - - private: - /* - * An x10_int that is constrained to a 0/1 and interpreted as an x10_boolean. - * We do this so that we know that compareAndSet_32 can work on the whole memory word. - */ - volatile x10_int _val; - - public: - x10_boolean get() { return _val == 1; } - - void set(x10_boolean newVal) { _val = (newVal ? 1 : 0); } - - x10_boolean compareAndSet(x10_boolean expect, x10_boolean update) { - x10_int expectI = expect ? 1 : 0; - x10_int updateI = update ? 1 : 0; - x10_int oldVal = x10aux::atomic_ops::compareAndSet_32(&_val, expectI, updateI) == expectI; - return oldVal == 1; - } - - x10_boolean weakCompareAndSet(x10_boolean expect, x10_boolean update) { - // TODO: for minor optimization on ppc we could add a weakCompareAndSet in atomic_ops and use that here - x10_int expectI = expect ? 1 : 0; - x10_int updateI = update ? 1 : 0; - x10_int oldVal = x10aux::atomic_ops::compareAndSet_32(&_val, expectI, updateI) == expectI; - return oldVal == 1; - } - - x10_boolean getAndSet(x10_boolean update) { - x10_boolean oldVal = get(); - set(update); - return oldVal; - } - - x10aux::ref<x10::lang::String> toString() { - return x10aux::boolean_utils::toString(_val); - } - }; - - template<class T> x10aux::ref<T> AtomicBoolean::_deserializer(x10aux::deserialization_buffer &buf) { - x10aux::ref<AtomicBoolean> this_ = new (x10aux::alloc<AtomicBoolean>()) AtomicBoolean(); - buf.record_reference(this_); // TODO: avoid; no global refs; final class - this_->_deserialize_body(buf); - return this_; - } - } - } - } -} - -#endif /* X10_UTIL_CONCURRENT_ATOMIC_ATOMICBOOLEAN_H */ - -// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.cc (from rev 16777, trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.cc) =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.cc (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.cc 2010-09-29 17:38:33 UTC (rev 16788) @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#include <x10aux/atomic_boolean_funs.h> +#include <x10aux/atomic_ops.h> +#include <x10/util/concurrent/atomic/AtomicBoolean.h> + +using namespace x10aux; +using namespace x10::util::concurrent::atomic; + +x10_boolean atomic_boolean_funs::compareAndSet(ref<AtomicBoolean> obj, + x10_boolean expect, x10_boolean update) { + x10_int expectI = expect ? 1 : 0; + x10_int updateI = update ? 1 : 0; + x10_int oldVal = x10aux::atomic_ops::compareAndSet_32(&(obj->FMGL(value)), expectI, updateI) == expectI; + return oldVal == 1; +} + +x10_boolean atomic_boolean_funs::weakCompareAndSet(ref<AtomicBoolean> obj, + x10_boolean expect, x10_boolean update) { + // TODO: for minor optimization on ppc we could add a weakCompareAndSet in atomic_ops and use that here + x10_int expectI = expect ? 1 : 0; + x10_int updateI = update ? 1 : 0; + x10_int oldVal = x10aux::atomic_ops::compareAndSet_32(&(obj->FMGL(value)), expectI, updateI) == expectI; + return oldVal == 1; +} + +// vim:tabstop=4:shiftwidth=4:expandtab Copied: trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.h (from rev 16777, trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicBoolean.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/atomic_boolean_funs.h 2010-09-29 17:38:33 UTC (rev 16788) @@ -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. + */ + +#ifndef X10AUX_ATOMIC_BOOLEAN_FUNS_H +#define X10AUX_ATOMIC_BOOLEAN_FUNS_H + +#include <x10aux/ref.h> + +namespace x10 { namespace util { namespace concurrent { namespace atomic { class AtomicBoolean; }}}} + +namespace x10aux { + + class atomic_boolean_funs { + public: + static x10_boolean compareAndSet(x10aux::ref<x10::util::concurrent::atomic::AtomicBoolean> obj, + x10_boolean expect, x10_boolean update); + + static x10_boolean weakCompareAndSet(x10aux::ref<x10::util::concurrent::atomic::AtomicBoolean> obj, + x10_boolean expect, x10_boolean update); + }; +} + +#endif /* X10_AUX_ATOMIC_BOOLEAN_FUNS_H */ + +// vim:tabstop=4:shiftwidth=4:expandtab Modified: trunk/x10.runtime/src-cpp/x10rt.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt.h 2010-09-29 17:04:42 UTC (rev 16787) +++ trunk/x10.runtime/src-cpp/x10rt.h 2010-09-29 17:38:33 UTC (rev 16788) @@ -21,7 +21,9 @@ #include <x10aux/static_init.h> #include <x10aux/hash.h> #include <x10aux/basic_functions.h> + #include <x10aux/atomic_ops.h> +#include <x10aux/atomic_boolean_funs.h> #include <x10aux/itables.h> Added: trunk/x10.runtime/src-x10/x10/compiler/Volatile.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/Volatile.x10 (rev 0) +++ trunk/x10.runtime/src-x10/x10/compiler/Volatile.x10 2010-09-29 17:38:33 UTC (rev 16788) @@ -0,0 +1,19 @@ +/* + * 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.lang.annotations.FieldAnnotation; + +/** + * We use this annotation to tell the compiler that a field should be marked as volatile. + */ +public interface Volatile extends FieldAnnotation { } Property changes on: trunk/x10.runtime/src-x10/x10/compiler/Volatile.x10 ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 2010-09-29 17:04:42 UTC (rev 16787) +++ trunk/x10.runtime/src-x10/x10/util/concurrent/atomic/AtomicBoolean.x10 2010-09-29 17:38:33 UTC (rev 16788) @@ -13,36 +13,48 @@ import x10.compiler.Native; import x10.compiler.NativeRep; +import x10.compiler.Volatile; @NativeRep("java", "java.util.concurrent.atomic.AtomicBoolean", null, "x10.rtt.Types.ATOMIC_BOOLEAN") -@NativeRep("c++", "x10aux::ref<x10::util::concurrent::atomic::AtomicBoolean>", "x10::util::concurrent::atomic::AtomicBoolean", null) public final class AtomicBoolean { - - public native def this():AtomicBoolean; - public native def this(v:boolean):AtomicBoolean; - - @Native("java", "#0.get()") - @Native("c++", "(#0)->get()") - public native def get():boolean; + /* + * An int that will only contain 0 or 1 and is interpreted as an boolean. + * We do this instead of using a boolean so that we know that compareAndSet_32 + * can work on the whole memory word. + */ + private @Volatile var value:int; + + public def this():AtomicBoolean { + value = 0; + } + public def this(v:boolean):AtomicBoolean { + value = v ? 1 : 0; + } + + @Native("java", "#0.get()") + public def get():boolean = value == 1; - @Native("java", "#0.set(#1)") - @Native("c++", "(#0)->set(#1)") - public native def set(v:boolean):void; + @Native("java", "#0.set(#1)") + public def set(v:boolean):void { + value = v ? 1 : 0; + } - @Native("java", "#0.compareAndSet(#1,#2)") - @Native("c++", "(#0)->compareAndSet(#1,#2)") - public native def compareAndSet(expect:boolean, update:boolean):boolean; + @Native("java", "#0.compareAndSet(#1,#2)") + @Native("c++", "x10aux::atomic_boolean_funs::compareAndSet(#0, #1, #2)") + public native def compareAndSet(expect:boolean, update:boolean):boolean; - @Native("java", "#0.weakCompareAndSet(#1,#2)") - @Native("c++", "(#0)->weakCompareAndSet(#1,#2)") - public native def weakCompareAndSet(expect:boolean, update:boolean):boolean; - - @Native("java", "#0.getAndSet(#1)") - @Native("c++", "(#0)->getAndSet(#1)") - public native def getAndSet(v:boolean):boolean; + @Native("java", "#0.weakCompareAndSet(#1,#2)") + @Native("c++", "x10aux::atomic_boolean_funs::weakCompareAndSet(#0, #1, #2)") + public native def weakCompareAndSet(expect:boolean, update:boolean):boolean; + + @Native("java", "#0.getAndSet(#1)") + public def getAndSet(v:boolean):boolean { + val oldVal = get(); + set(v); + return oldVal; + } - @Native("java", "#0.toString()") - @Native("c++", "(#0)->toString()") - public native def toString():String; + @Native("java", "#0.toString()") + public def toString():String = get().toString(); } Added: trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 2010-09-29 17:38:33 UTC (rev 16788) @@ -0,0 +1,35 @@ +/* + * 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.concurrent.atomic.AtomicBoolean; + +/** + * Simple test cases for AtomicBoolean API functions. + */ +public class AtomicBooleanTest extends x10Test { + + public def run():Boolean { + val ab = new AtomicBoolean(true); + + var success:Boolean = ab.compareAndSet(false, false); + chk(!success && ab.get() == true); // compareAndSet should have failed, value still true + + success = ab.compareAndSet(true, false); + chk(success && ab.get() == false); // compareAndSet should have succeeded; value is now false. + + return true; + } + + public static def main(Array[String]) { + new AtomicBooleanTest().execute(); + } +} Property changes on: trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.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: <dgr...@us...> - 2010-09-29 19:03:19
|
Revision: 16792 http://x10.svn.sourceforge.net/x10/?rev=16792&view=rev Author: dgrove-oss Date: 2010-09-29 19:03:12 +0000 (Wed, 29 Sep 2010) Log Message: ----------- If a field has an @Volatile annotation, then add the volatile modifier to the field declaration in the generated C++ code. Serialization support for volatile x10_int. (better way to support this?) Add serialization check to AtomicBooleanTest. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-09-29 18:22:35 UTC (rev 16791) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-09-29 19:03:12 UTC (rev 16792) @@ -858,7 +858,7 @@ h.write(flags.retain(Flags.STATIC).translate()); } - if (query.hasAnnotation(n, "x10.lang.shared")) { + if (query.hasAnnotation(n, "x10.lang.shared") || query.hasAnnotation(n, "x10.compiler.Volatile")) { h.write("volatile "); } Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-09-29 18:22:35 UTC (rev 16791) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-09-29 19:03:12 UTC (rev 16792) @@ -278,7 +278,18 @@ PRIMITIVE_WRITE(x10_double) //PRIMITIVE_WRITE(x10_addr_t) // already defined above //PRIMITIVE_WRITE(remote_ref) - + + template<> inline void serialization_buffer::Write<volatile x10_int>::_(serialization_buffer &buf, \ + const volatile x10_int &val) {\ + _S_("Serializing "<<star_rating<x10_int>()<<" a "<<ANSI_SER<<TYPENAME(x10_int)<<ANSI_RESET<<": " \ + <<val<<" into buf: "<<&buf); \ + /* *(TYPE*) buf.cursor = val; // Cannot do this because of alignment */ \ + if (buf.cursor + sizeof(x10_int) >= buf.limit) buf.grow(); \ + memcpy(buf.cursor, const_cast<x10_int*>(&val), sizeof(x10_int)); \ + code_bytes((x10_int*)buf.cursor); \ + buf.cursor += sizeof(x10_int); \ + } + // Case for references e.g. ref<Reference>, template<class T> struct serialization_buffer::Write<ref<T> > { static void _(serialization_buffer &buf, ref<T> val); Modified: trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 2010-09-29 18:22:35 UTC (rev 16791) +++ trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10 2010-09-29 19:03:12 UTC (rev 16792) @@ -26,6 +26,17 @@ success = ab.compareAndSet(true, false); chk(success && ab.get() == false); // compareAndSet should have succeeded; value is now false. + // Now check that serialization works + val ab2 = new AtomicBoolean(); + ab2.set(true); + chk(ab2.get()); + at (here.next()) { + chk(ab2.get()); + ab2.set(false); + chk(!ab2.get()); + } + chk(ab2.get()); // original should not have been changed by update of copy inside of at + return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-09-30 02:35:26
|
Revision: 16802 http://x10.svn.sourceforge.net/x10/?rev=16802&view=rev Author: dgrove-oss Date: 2010-09-30 02:35:20 +0000 (Thu, 30 Sep 2010) Log Message: ----------- Update serialization methods of AtomicReference for 2.1 object model. Not as easy to avoid having this class be a NativeRep because we need to play some somewhat sleazy games with the value field to get volatile refs to work correctly. Fix bug in compareAndSet impl where C++ code didn't actually match X10 code. Add simple test for AtomicReference API. Modified Paths: -------------- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h Added Paths: ----------- trunk/x10.tests/examples/Constructs/Atomic/AtomicReferenceTest.x10 Modified: trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h =================================================================== --- trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-09-30 02:25:56 UTC (rev 16801) +++ trunk/x10.runtime/src-cpp/x10/util/concurrent/atomic/AtomicReference.h 2010-09-30 02:35:20 UTC (rev 16802) @@ -72,9 +72,9 @@ void set(T val); - T compareAndSet(T oldVal, T newVal); + x10_boolean compareAndSet(T oldVal, T newVal); - T weakCompareAndSet(T oldVal, T newVal); + x10_boolean weakCompareAndSet(T oldVal, T newVal); T getAndSet(T val); @@ -106,16 +106,14 @@ _data = tmp; } - template<class T> T AtomicReference<T>::compareAndSet(T oldVal, T newVal) { + template<class T> x10_boolean AtomicReference<T>::compareAndSet(T oldVal, T newVal) { x10::lang::Object *oldValPtr = oldVal.operator->(); /* Does two things: gets backing S* ptr from ref<S> and upcasts S* to Object* */ x10::lang::Object *newValPtr = newVal.operator->(); /* Does two things: gets backing S* ptr from ref<S> and upcasts S* to Object* */ x10::lang::Object *res = (x10::lang::Object *)x10aux::atomic_ops::compareAndSet_ptr((volatile void**)&_data, (void*)oldValPtr, (void*)newValPtr); - x10aux::ref<x10::lang::Object> res2 = res; /* boxes to ref */ - T res3 = res2; /* downcast from ref<Object> to T (ref<S>) */ - return res3; + return res == oldValPtr; } - template<class T> T AtomicReference<T>::weakCompareAndSet(T oldVal, T newVal) { + template<class T> x10_boolean AtomicReference<T>::weakCompareAndSet(T oldVal, T newVal) { // TODO: for minor optimization on ppc we could add a weakCompareAndSet_ptr in atomic_ops and use that here return compareAndSet(oldVal, newVal); } @@ -143,18 +141,25 @@ template<class T> void AtomicReference<T>::_serialize_body(x10aux::serialization_buffer &buf) { this->Object::_serialize_body(buf); + x10::lang::Object* tmp = (x10::lang::Object*)_data; /* drops volatile */ + x10aux::ref<x10::lang::Object> tmp2 = tmp; /* boxes to ref */ + T tmp3 = tmp2; /* downcast from ref<Object> to T (ref<S) */ + buf.write(tmp3); } template<class T> void AtomicReference<T>::_deserialize_body(x10aux::deserialization_buffer& buf) { this->Object::_deserialize_body(buf); + T tmp = buf.read<T>(); + x10::lang::Object *tmp2 = tmp.operator->(); /* Does two things: gets backing S* ptr from ref<S> and upcasts S* to Object* */ + _data = tmp2; } template<class T> template<class U> x10aux::ref<U> AtomicReference<T>::_deserializer(x10aux::deserialization_buffer &buf) { x10aux::ref<AtomicReference<T> > this_ = new (x10aux::alloc<AtomicReference<T> >()) AtomicReference<T> (); - buf.record_reference(this_); // TODO: avoid; no global refs; final class + buf.record_reference(this_); this_->_deserialize_body(buf); return this_; } Copied: trunk/x10.tests/examples/Constructs/Atomic/AtomicReferenceTest.x10 (from rev 16792, trunk/x10.tests/examples/Constructs/Atomic/AtomicBooleanTest.x10) =================================================================== --- trunk/x10.tests/examples/Constructs/Atomic/AtomicReferenceTest.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Atomic/AtomicReferenceTest.x10 2010-09-30 02:35:20 UTC (rev 16802) @@ -0,0 +1,47 @@ +/* + * 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.concurrent.atomic.AtomicReference; + +/** + * Simple test cases for AtomicReference API functions. + */ +public class AtomicReferenceTest extends x10Test { + + public def run():Boolean { + val obj1 = "abc"; + val obj2 = "def"; + val obj3 = "ghi"; + val ref = AtomicReference.newAtomicReference[String](obj1); + + var success:Boolean = ref.compareAndSet(obj2, obj3); + chk(!success && ref.get() == obj1); // compareAndSet should have failed, value still true + + success = ref.compareAndSet(obj1, obj3); + chk(success && ref.get() == obj3); // compareAndSet should have succeeded; value is now false. + + // Now check that serialization works + at (here.next()) { + chk(ref.get().equals(obj3)); + chk(ref.get() == obj3); + ref.set("xyz"); + chk(ref.get().equals("xyz")); + } + chk(ref.get() == obj3); // original should not have been changed by update of copy inside of at + + return true; + } + + public static def main(Array[String]) { + new AtomicReferenceTest().execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mt...@us...> - 2010-09-30 09:14:46
|
Revision: 16805 http://x10.svn.sourceforge.net/x10/?rev=16805&view=rev Author: mtake Date: 2010-09-30 09:14:39 +0000 (Thu, 30 Sep 2010) Log Message: ----------- Fix again XTENLANG-1858 Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/core/Ref.java trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-09-30 08:04:40 UTC (rev 16804) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-09-30 09:14:39 UTC (rev 16805) @@ -1356,24 +1356,9 @@ } } - // Note: @NativeRep'ed class doesn't capture outer this - boolean no_outer = false; - X10ClassDef def = (X10ClassDef) ct.def(); - if (er.getJavaRep(def) != null) { - no_outer = true; - } - List<Expr> l = c.arguments(); for (Iterator<Expr> i = l.iterator(); i.hasNext(); ) { Expr e = (Expr) i.next(); - - if (no_outer) { - no_outer = false; - if (e instanceof Local_c && InnerClassRemover.OUTER_FIELD_NAME.toString().equals(((Local_c) e).name().toString())) { - continue; - } - } - c.print(e, w, tr); if (i.hasNext()) { w.write(","); Modified: trunk/x10.runtime/src-java/x10/core/Ref.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/Ref.java 2010-09-30 08:04:40 UTC (rev 16804) +++ trunk/x10.runtime/src-java/x10/core/Ref.java 2010-09-30 09:14:39 UTC (rev 16805) @@ -20,6 +20,9 @@ public Ref() {} + // XTENLANG-1858: every Java class that could be an (non-static) inner class must have constructors with the outer instance parameter + public Ref(Object out$) {} + public static RuntimeType<Ref> _RTT = new RuntimeType<Ref>(Ref.class) { @Override public String typeName() { Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java 2010-09-30 08:04:40 UTC (rev 16804) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/X10Throwable.java 2010-09-30 09:14:39 UTC (rev 16805) @@ -33,6 +33,23 @@ super(message, cause); } + // XTENLANG-1858: every Java class that could be an (non-static) inner class must have constructors with the outer instance parameter + public X10Throwable(Object out$) { + super(); + } + + public X10Throwable(Object out$, String message) { + super(message); + } + + public X10Throwable(Object out$, java.lang.Throwable cause) { + super(cause); + } + + public X10Throwable(Object out$, String message, java.lang.Throwable cause) { + super(message, cause); + } + static public X10Throwable getCorrespondingX10Exception(java.lang.RuntimeException e) { String newExcName = "x10.lang.RuntimeException"; if (e instanceof java.lang.ArithmeticException) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <spa...@us...> - 2010-09-30 15:06:03
|
Revision: 16807 http://x10.svn.sourceforge.net/x10/?rev=16807&view=rev Author: sparksparkspark Date: 2010-09-30 15:05:54 +0000 (Thu, 30 Sep 2010) Log Message: ----------- More work on CUDA -- KMeansCUDA now runs with same result as CPU (only tested on single GPU so far) CUDABlackScholes now runs and verifies CUDAKernelTest runs and verifies No performance runs so far Arrays on GPU now have length as well as backing buffer, could potentially be used to do array bounds checks in the future Fixed bugs where buffer was not copied when retained by X10RT (dangling pointers) Introduce post kernel callbacks at X10 level, in order to: * Fix memory leak on GPU, assume arrays do not escape within cuda code (we have no kernels that will leak) Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.compiler/src/x10cuda/types/SharedMem.java trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java trunk/x10.dist/samples/CUDA/CUDABlackScholes.x10 trunk/x10.dist/samples/CUDA/KMeansCUDA.x10 trunk/x10.runtime/src-cpp/x10/util/IndexedMemoryChunk.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.cc trunk/x10.runtime/src-cpp/x10aux/deserialization_dispatcher.h trunk/x10.runtime/src-cpp/x10aux/network.cc trunk/x10.runtime/src-cpp/x10aux/static_init.cc trunk/x10.runtime/src-cpp/x10rt.h trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/RemoteArray.x10 trunk/x10.runtime/src-x10/x10/util/CUDAUtilities.x10 trunk/x10.runtime/x10rt/common/x10rt_cuda.cc trunk/x10.runtime/x10rt/include/x10rt_types.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/cuda_kernel.cuh Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10aux/kernel.cuh Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-09-30 13:55:33 UTC (rev 16806) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-09-30 15:05:54 UTC (rev 16807) @@ -91,6 +91,7 @@ static final String DESERIALIZER_METHOD = "_deserializer"; static final String DESERIALIZE_BODY_METHOD = "_deserialize_body"; public static final String DESERIALIZE_CUDA_METHOD = "_deserialize_cuda"; + public static final String POST_CUDA_METHOD = "_post_cuda"; static final String STRUCT_EQUALS = "x10aux::struct_equals"; public static final String STRUCT_EQUALS_METHOD = "_struct_equals"; public static final String REFERENCE_TYPE = "x10::lang::Reference"; Modified: trunk/x10.compiler/src/x10cuda/types/SharedMem.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2010-09-30 13:55:33 UTC (rev 16806) +++ trunk/x10.compiler/src/x10cuda/types/SharedMem.java 2010-09-30 15:05:54 UTC (rev 16807) @@ -35,10 +35,10 @@ abstract public void generateSize(StreamWrapper inc, Translator tr); } - private static class Rail extends Decl { + private static class Array extends Decl { public final Expr numElements; public final Expr init; - public Rail (LocalDecl ast, Expr numElements, Expr init) { + public Array (LocalDecl ast, Expr numElements, Expr init) { super(ast); this.numElements = numElements; this.init = init; @@ -46,25 +46,43 @@ public void generateDef(StreamWrapper out, String offset, Translator tr) { String name = ast.name().id().toString(); // FIXME: x10_float is baked in here - out.write("x10_float *"+name+" = (x10_float*) &__shm["+offset+"];"); out.newline(); + out.write("x10aux::cuda_array<x10_float> "+name+" = { "); + if (numElements!=null) { + tr.print(null, numElements, out); + } else { + tr.print(null, init, out); + out.write(".size"); + } + out.write(", (x10_float*) &__shm["+offset+"] };"); out.newline(); } public void generateInit(StreamWrapper out, String offset, Translator tr) { out.write("{"); out.newline(4); out.begin(0); out.write("x10_int __len = "); - tr.print(null, numElements, out); + if (numElements!=null) { + tr.print(null, numElements, out); + } else { + tr.print(null, init, out); + out.write(".size"); + } out.write(";"); out.newline(); - out.write("for (int i=0 ; i<__len ; ++i) {"); out.newline(4); out.begin(0); - // TODO: assumes rail initialised with another rail -- closure version also possible - out.write(ast.name().id()+"[i] = "); + + out.write("for (int __i=0 ; __i<__len ; ++__i) {"); out.newline(4); out.begin(0); + // TODO: assumes Array initialised with another Array -- closure version also possible + out.write(ast.name().id()+".apply("); tr.print(null, init, out); - out.write("[i];"); out.newline(); + out.write(".raw[__i], __i);"); out.newline(); out.end(); out.newline(); out.write("}"); out.end(); out.newline(); out.write("}"); } public void generateSize(StreamWrapper inc, Translator tr) { - tr.print(null, numElements, inc); + if (numElements!=null) { + tr.print(null, numElements, inc); + } else { + tr.print(null, init, inc); + inc.write("->FMGL(rawLength)"); + } // FIXME: x10_float is baked in here inc.write("*sizeof(x10_float)"); @@ -86,10 +104,15 @@ } } - public void addRail(LocalDecl ast, Expr numElements, Expr init) { - decls.add(new Rail(ast,numElements,init)); + public void addArrayInitClosure(LocalDecl ast, Expr numElements, Expr init) { + assert false : "This does not actually work, I think"; + decls.add(new Array(ast, numElements, init)); } + public void addArrayInitArray(LocalDecl ast, Expr init) { + decls.add(new Array(ast, null, init)); + } + public void addVar(LocalDecl ast) { decls.add(new Var(ast)); } Modified: trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java =================================================================== --- trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2010-09-30 13:55:33 UTC (rev 16806) +++ trunk/x10.compiler/src/x10cuda/types/X10CUDAContext_c.java 2010-09-30 15:05:54 UTC (rev 16807) @@ -87,7 +87,7 @@ j.compiler().outputFiles().add(wrappingClass()+".cu"); ((X10CPPCompilerOptions)j.extensionInfo().getOptions()).compilationUnits().add(wrappingClass()+".cu"); cudaStream.write("#include <x10aux/config.h>"); cudaStream.newline(); - cudaStream.write("#include <x10aux/kernel.cuh>"); cudaStream.newline(); + cudaStream.write("#include <x10aux/cuda_kernel.cuh>"); cudaStream.newline(); cudaStream.forceNewline(); cudaStream.write("extern __shared__ char __shm[];"); cudaStream.newline(); cudaStream.write("extern __constant__ char __cmem[64*1024];"); cudaStream.newline(); Modified: trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-09-30 13:55:33 UTC (rev 16806) +++ trunk/x10.compiler/src/x10cuda/visit/CUDACodeGenerator.java 2010-09-30 15:05:54 UTC (rev 16807) @@ -116,6 +116,7 @@ import x10.ast.X10Instanceof_c; import x10.ast.X10Loop; import x10.ast.X10Loop_c; +import x10.ast.X10New_c; import x10.ast.X10Special_c; import x10.ast.X10Unary_c; import x10.extension.X10Ext; @@ -155,370 +156,360 @@ public class CUDACodeGenerator extends MessagePassingCodeGenerator { - private static final String ANN_KERNEL = "x10.compiler.CUDA"; - private static final String ANN_DIRECT_PARAMS = "x10.compiler.CUDADirectParams"; + private static final String ANN_KERNEL = "x10.compiler.CUDA"; + private static final String ANN_DIRECT_PARAMS = "x10.compiler.CUDADirectParams"; - public CUDACodeGenerator(StreamWrapper sw, Translator tr) { - super(sw, tr); - } + public CUDACodeGenerator(StreamWrapper sw, Translator tr) { + super(sw, tr); + } - protected String[] getCurrentNativeStrings() { - if (!generatingKernel()) - return new String[] { CPP_NATIVE_STRING }; - return new String[] { CUDA_NATIVE_STRING, CPP_NATIVE_STRING }; - } + protected String[] getCurrentNativeStrings() { + if (!generatingKernel()) + return new String[] { CPP_NATIVE_STRING }; + return new String[] { CUDA_NATIVE_STRING, CPP_NATIVE_STRING }; + } - private X10CUDAContext_c context() { - return (X10CUDAContext_c) tr.context(); - } + private X10CUDAContext_c context() { + return (X10CUDAContext_c) tr.context(); + } - private X10TypeSystem_c xts() { - return (X10TypeSystem_c) tr.typeSystem(); - } + private X10TypeSystem_c xts() { + return (X10TypeSystem_c) tr.typeSystem(); + } - // defer to CUDAContext.cudaStream() - private ClassifiedStream cudaStream() { - return context().cudaStream(sw, tr.job()); - } + // defer to CUDAContext.cudaStream() + private ClassifiedStream cudaStream() { + return context().cudaStream(sw, tr.job()); + } - private boolean generatingKernel() { - return context().generatingKernel(); - } + private boolean generatingKernel() { + return context().generatingKernel(); + } - private void generatingKernel(boolean v) { - context().generatingKernel(v); - } + private void generatingKernel(boolean v) { + context().generatingKernel(v); + } - private Type getType(String name) throws SemanticException { - return (Type) xts().systemResolver().find(QName.make(name)); - } + private Type getType(String name) throws SemanticException { + return (Type) xts().systemResolver().find(QName.make(name)); + } - // does the block have the annotation that denotes that it should be - // split-compiled to cuda? - private boolean blockIsKernel(Node n) { - return nodeHasAnnotation(n, ANN_KERNEL); - } + // does the block have the annotation that denotes that it should be + // split-compiled to cuda? + private boolean blockIsKernel(Node n) { + return nodeHasAnnotation(n, ANN_KERNEL); + } - // does the block have the annotation that denotes that it should be - // compiled to use conventional cuda kernel params - private boolean kernelWantsDirectParams(Node n) { - return nodeHasAnnotation(n, ANN_DIRECT_PARAMS); - } + // does the block have the annotation that denotes that it should be + // compiled to use conventional cuda kernel params + private boolean kernelWantsDirectParams(Node n) { + return nodeHasAnnotation(n, ANN_DIRECT_PARAMS); + } - // does the block have the given annotation - private boolean nodeHasAnnotation(Node n, String ann) { - X10Ext ext = (X10Ext) n.ext(); - try { - return !ext.annotationMatching(getType(ann)).isEmpty(); - } catch (SemanticException e) { - assert false : e; - return false; // in case asserts are off - } - } + // does the block have the given annotation + private boolean nodeHasAnnotation(Node n, String ann) { + X10Ext ext = (X10Ext) n.ext(); + try { + return !ext.annotationMatching(getType(ann)).isEmpty(); + } catch (SemanticException e) { + assert false : e; + return false; // in case asserts are off + } + } - private String env = "__env"; + private String env = "__env"; - private Type arrayCargo(Type typ) { - if (xts().isArray(typ)) { - typ = typ.toClass(); - X10ClassType ctyp = (X10ClassType) typ; - assert ctyp.typeArguments().size() == 1; - return ctyp.typeArguments().get(0); - } - if (xts().isRemoteArray(typ)) { - typ = typ.toClass(); - X10ClassType ctyp = (X10ClassType) typ; - assert ctyp.typeArguments().size() == 1; - Type type2 = ctyp.typeArguments().get(0); - X10ClassType ctyp2 = (X10ClassType) typ; - assert ctyp2.typeArguments().size() == 1; - return ctyp2.typeArguments().get(0); - } - return null; - - } + private Type arrayCargo(Type typ) { + if (xts().isArray(typ)) { + typ = typ.toClass(); + X10ClassType ctyp = (X10ClassType) typ; + assert ctyp.typeArguments().size() == 1; + return ctyp.typeArguments().get(0); + } + if (xts().isRemoteArray(typ)) { + typ = typ.toClass(); + X10ClassType ctyp = (X10ClassType) typ; + assert ctyp.typeArguments().size() == 1; + Type type2 = ctyp.typeArguments().get(0); + X10ClassType ctyp2 = (X10ClassType) typ; + assert ctyp2.typeArguments().size() == 1; + return ctyp2.typeArguments().get(0); + } + return null; - private boolean isFloatArray(Type typ) { - Type cargo = arrayCargo(typ); - return cargo != null && cargo.isFloat(); - } + } - private boolean isIntArray(Type typ) { - Type cargo = arrayCargo(typ); - return cargo != null && cargo.isInt(); - } - - String prependCUDAType(Type t, String rest) { - String type = Emitter.translateType(t, true); + private boolean isFloatArray(Type typ) { + Type cargo = arrayCargo(typ); + return cargo != null && cargo.isFloat(); + } - if (isIntArray(t)) { - type = "x10_int *"; - } else if (isFloatArray(t)) { - type = "x10_float *"; - } else { - type = type + " "; - } - - return type + rest; - } - - void handleKernel(Block_c b) { - String kernel_name = context().wrappingClosure(); - sw.write("/* block split-compiled to cuda as " + kernel_name + " */ "); - System.out.println("Kernel: "+kernel_name); + private boolean isIntArray(Type typ) { + Type cargo = arrayCargo(typ); + return cargo != null && cargo.isInt(); + } - ClassifiedStream out = cudaStream(); + String prependCUDAType(Type t, String rest) { + String type = Emitter.translateType(t, true); - // environment (passed into kernel via pointer) - generateStruct(kernel_name, out, context().kernelParams()); + if (isIntArray(t)) { + type = "x10aux::cuda_array<x10_int> "; + } else if (isFloatArray(t)) { + type = "x10aux::cuda_array<x10_float> "; + } else { + type = type + " "; + } - out.forceNewline(); + return type + rest; + } - boolean ptr = !context().directParams(); - // kernel (extern "C" to disable name-mangling which seems to be - // inconsistent across cuda versions) - out.write("extern \"C\" __global__ void " + kernel_name + "(" - + kernel_name + "_env "+(ptr?"*":"") + env + ") {"); - out.newline(4); - out.begin(0); - - if (ptr) { - for (VarInstance<?> var : context().kernelParams()) { - String name = var.name().toString(); - if (name.equals(THIS)) { - name = SAVED_THIS; - } else { - name = Emitter.mangled_non_method_name(name); - } - out.write("__shared__ "+prependCUDAType(var.type(),name) + ";"); out.newline(); - } - out.write("if (threadIdx.x==0) {"); out.newline(4); out.begin(0); - for (VarInstance<?> var : context().kernelParams()) { - String name = var.name().toString(); - if (name.equals(THIS)) { - name = SAVED_THIS; - } else { - name = Emitter.mangled_non_method_name(name); - } - out.write(name+" = "+env+"->"+name+";"); out.newline(); - } - out.end(); out.newline(); - out.write("}"); out.newline(); - out.write("__syncthreads();"); out.newline(); - out.forceNewline(); - } - + void handleKernel(Block_c b) { + String kernel_name = context().wrappingClosure(); + sw.write("/* block split-compiled to cuda as " + kernel_name + " */ "); + System.out.println("Kernel: " + kernel_name); - sw.pushCurrentStream(out); - context().shm().generateCode(sw, tr); - sw.popCurrentStream(); - - // body - sw.pushCurrentStream(out); - super.visit(b); - sw.popCurrentStream(); + ClassifiedStream out = cudaStream(); - // end - out.end(); - out.newline(); - out.write("} // " + kernel_name); out.newline(); - - out.forceNewline(); - } + // environment (passed into kernel via pointer) + generateStruct(kernel_name, out, context().kernelParams()); - private void generateStruct(String kernel_name, SimpleCodeWriter out, ArrayList<VarInstance<?>> vars) { - out.write("struct " + kernel_name + "_env {"); - out.newline(4); - out.begin(0); - // emitter.printDeclarationList(out, context(), - // context().kernelParams()); - for (VarInstance<?> var : vars) { - String name = var.name().toString(); - if (name.equals(THIS)) { - name = SAVED_THIS; - } else { - name = Emitter.mangled_non_method_name(name); - } - out.write(prependCUDAType(var.type(),name) + ";"); - out.newline(); - } - out.end(); - out.newline(); - out.write("};"); - out.newline(); - } + out.forceNewline(); - // Java cannot return multiple values from a function - class MultipleValues { - public Expr max; + boolean ptr = !context().directParams(); + // kernel (extern "C" to disable name-mangling which seems to be + // inconsistent across cuda versions) + out.write("extern \"C\" __global__ void " + kernel_name + "(" + + kernel_name + "_env " + (ptr ? "*" : "") + env + ") {"); + out.newline(4); + out.begin(0); - public Name var; + if (ptr) { + for (VarInstance<?> var : context().kernelParams()) { + String name = var.name().toString(); + if (name.equals(THIS)) { + name = SAVED_THIS; + } else { + name = Emitter.mangled_non_method_name(name); + } + out.write("__shared__ " + prependCUDAType(var.type(), name) + + ";"); + out.newline(); + } + out.write("if (threadIdx.x==0) {"); + out.newline(4); + out.begin(0); + for (VarInstance<?> var : context().kernelParams()) { + String name = var.name().toString(); + if (name.equals(THIS)) { + name = SAVED_THIS; + } else { + name = Emitter.mangled_non_method_name(name); + } + out.write(name + " = " + env + "->" + name + ";"); + out.newline(); + } + out.end(); + out.newline(); + out.write("}"); + out.newline(); + out.write("__syncthreads();"); + out.newline(); + out.forceNewline(); + } - public Block body; - } + sw.pushCurrentStream(out); + context().shm().generateCode(sw, tr); + sw.popCurrentStream(); - protected MultipleValues processLoop(X10Loop loop) { - MultipleValues r = new MultipleValues(); - Formal loop_formal = loop.formal(); - assert loop_formal instanceof X10Formal; // FIXME: proper error - X10Formal loop_x10_formal = (X10Formal) loop_formal; - assert loop_x10_formal.hasExplodedVars(); // FIXME: proper error - assert loop_x10_formal.vars().size() == 1; // FIXME: proper error - r.var = loop_x10_formal.vars().get(0).name().id(); - Expr domain = loop.domain(); - assert domain instanceof RegionMaker; // FIXME: proper error - RegionMaker region = (RegionMaker) domain; - assert region.name().toString().equals("makeRectangular") : region - .name(); // FIXME: proper error - Receiver target = region.target(); - assert target instanceof CanonicalTypeNode; // FIXME: proper error - CanonicalTypeNode target_type_node = (CanonicalTypeNode) target; - assert target_type_node.nameString().equals("Region") : target_type_node - .nameString(); // FIXME: proper error - assert region.arguments().size() == 2; // FIXME: proper error - Expr from_ = region.arguments().get(0); - Expr to_ = region.arguments().get(1); - assert from_ instanceof IntLit; // FIXME: proper error - //assert to_ instanceof IntLit; // FIXME: proper error - IntLit from = (IntLit) from_; - //IntLit to = (IntLit) to_; - assert from.value() == 0; // FIXME: proper error - //r.iterations = to.value() + 1; - r.max = to_; - r.body = (Block) loop.body(); - return r; - } + // body + sw.pushCurrentStream(out); + super.visit(b); + sw.popCurrentStream(); - 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() == 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); - assert j_ instanceof LocalDecl : j_.getClass(); - LocalDecl j = (LocalDecl) j_; - assert loop.cond() instanceof X10Call : loop.cond().getClass(); - X10Call cond = (X10Call) loop.cond(); - assert cond.name().id() == X10Binary_c.binaryMethodName(Binary.LE) : cond.name(); - List<Expr> args = cond.arguments(); - assert args.size() == 2 : args.size(); - assert args.get(0) instanceof Local : args.get(0).getClass(); - Local cond_left = (Local) args.get(0); - assert args.get(1) instanceof Local : args.get(1).getClass(); - Local cond_right = (Local) args.get(1); - /* - assert loop.cond() instanceof Binary : loop.cond().getClass(); - Binary cond = (Binary) loop.cond(); - assert cond.operator() == Binary.LE : cond.operator(); - assert cond.left() instanceof Local : cond.left().getClass(); - Local cond_left = (Local) cond.left(); - assert cond_left.name().id() == i.name().id() : cond_left; - assert cond.right() instanceof Local : cond.right().getClass(); - Local cond_right = (Local) cond.right(); - */ - assert cond_right.name().id() == j.name().id() : cond_right; - Expr from_ = i.init(); - Expr to_ = j.init(); - assert from_ instanceof IntLit : from_.getClass(); // FIXME: proper error - //assert to_ instanceof IntLit : to_.getClass(); // FIXME: proper error - IntLit from = (IntLit) from_; - //IntLit to = (IntLit) to_; - assert from.value() == 0 : from.value(); // FIXME: proper error - //r.iterations = to.value() + 1; - r.max = to_; - assert loop.body() instanceof Block : loop.body().getClass(); - Block block = (Block) loop.body(); - assert block.statements().size() == 2 : block.statements(); - Stmt first = block.statements().get(0); - assert first instanceof LocalDecl : first.getClass(); - LocalDecl real_var = (LocalDecl) first; - Stmt second = block.statements().get(1); - assert second instanceof Block : second.getClass(); - r.body = (Block) second; - r.var = real_var.name().id(); - return r; - } - - public void checkAutoVar(Stmt s) { - assert s instanceof LocalDecl : s.getClass(); // FIXME: proper error - LocalDecl s_ = (LocalDecl)s; - Expr init_expr = s_.init(); - assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: proper error - X10Call_c init_call = (X10Call_c) init_expr; - Receiver init_call_target = init_call.target(); - assert init_call_target instanceof CanonicalTypeNode : init_call_target.getClass(); // FIXME: proper error - CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; - assert init_call_target_node.nameString().equals("CUDAUtilities") : init_call_target_node.nameString(); - assert init_call.typeArguments().size() == 0 : init_call.typeArguments(); - if (init_call.name().toString().equals("autoBlocks")) { - assert context().autoBlocks()==null : "Already have autoBlocks: "+context().autoBlocks(); - context().autoBlocks(s_); - context().established().autoBlocks(s_); - } else if (init_call.name().toString().equals("autoThreads")) { - assert context().autoThreads()==null : "Already have autoThreads: "+context().autoThreads(); - context().autoThreads(s_); - context().established().autoThreads(s_); - } else { - assert false : init_call.name(); - } - } + // end + out.end(); + out.newline(); + out.write("} // " + kernel_name); + out.newline(); - public void visit(Block_c b) { + out.forceNewline(); + } + + private void generateStruct(String kernel_name, SimpleCodeWriter out, + ArrayList<VarInstance<?>> vars) { + out.write("struct " + kernel_name + "_env {"); + out.newline(4); + out.begin(0); + // emitter.printDeclarationList(out, context(), + // context().kernelParams()); + for (VarInstance<?> var : vars) { + String name = var.name().toString(); + if (name.equals(THIS)) { + name = SAVED_THIS; + } else { + name = Emitter.mangled_non_method_name(name); + } + out.write(prependCUDAType(var.type(), name) + ";"); + out.newline(); + } + out.end(); + out.newline(); + out.write("};"); + out.newline(); + } + + // Java cannot return multiple values from a function + class MultipleValues { + public Expr max; + + public Name var; + + public Block body; + } + + protected MultipleValues processLoop(X10Loop loop) { + MultipleValues r = new MultipleValues(); + Formal loop_formal = loop.formal(); + assert loop_formal instanceof X10Formal; // FIXME: proper error + X10Formal loop_x10_formal = (X10Formal) loop_formal; + assert loop_x10_formal.hasExplodedVars(); // FIXME: proper error + assert loop_x10_formal.vars().size() == 1; // FIXME: proper error + r.var = loop_x10_formal.vars().get(0).name().id(); + Expr domain = loop.domain(); + assert domain instanceof RegionMaker; // FIXME: proper error + RegionMaker region = (RegionMaker) domain; + assert region.name().toString().equals("makeRectangular") : region + .name(); // FIXME: proper error + Receiver target = region.target(); + assert target instanceof CanonicalTypeNode; // FIXME: proper error + CanonicalTypeNode target_type_node = (CanonicalTypeNode) target; + assert target_type_node.nameString().equals("Region") : target_type_node + .nameString(); // FIXME: proper error + assert region.arguments().size() == 2; // FIXME: proper error + Expr from_ = region.arguments().get(0); + Expr to_ = region.arguments().get(1); + assert from_ instanceof IntLit; // FIXME: proper error + // assert to_ instanceof IntLit; // FIXME: proper error + IntLit from = (IntLit) from_; + // IntLit to = (IntLit) to_; + assert from.value() == 0; // FIXME: proper error + // r.iterations = to.value() + 1; + r.max = to_; + r.body = (Block) loop.body(); + return r; + } + + 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() == 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); + assert j_ instanceof LocalDecl : j_.getClass(); + LocalDecl j = (LocalDecl) j_; + assert loop.cond() instanceof X10Call : loop.cond().getClass(); + X10Call cond = (X10Call) loop.cond(); + assert cond.name().id() == X10Binary_c.binaryMethodName(Binary.LE) : cond + .name(); + List<Expr> args = cond.arguments(); + assert args.size() == 2 : args.size(); + assert args.get(0) instanceof Local : args.get(0).getClass(); + Local cond_left = (Local) args.get(0); + assert args.get(1) instanceof Local : args.get(1).getClass(); + Local cond_right = (Local) args.get(1); + /* + * assert loop.cond() instanceof Binary : loop.cond().getClass(); Binary + * cond = (Binary) loop.cond(); assert cond.operator() == Binary.LE : + * cond.operator(); assert cond.left() instanceof Local : + * cond.left().getClass(); Local cond_left = (Local) cond.left(); assert + * cond_left.name().id() == i.name().id() : cond_left; assert + * cond.right() instanceof Local : cond.right().getClass(); Local + * cond_right = (Local) cond.right(); + */ + assert cond_right.name().id() == j.name().id() : cond_right; + Expr from_ = i.init(); + Expr to_ = j.init(); + assert from_ instanceof IntLit : from_.getClass(); // FIXME: proper + // error + // assert to_ instanceof IntLit : to_.getClass(); // FIXME: proper error + IntLit from = (IntLit) from_; + // IntLit to = (IntLit) to_; + assert from.value() == 0 : from.value(); // FIXME: proper error + // r.iterations = to.value() + 1; + r.max = to_; + assert loop.body() instanceof Block : loop.body().getClass(); + Block block = (Block) loop.body(); + assert block.statements().size() == 2 : block.statements(); + Stmt first = block.statements().get(0); + assert first instanceof LocalDecl : first.getClass(); + LocalDecl real_var = (LocalDecl) first; + Stmt second = block.statements().get(1); + assert second instanceof Block : second.getClass(); + r.body = (Block) second; + r.var = real_var.name().id(); + return r; + } + + public void checkAutoVar(Stmt s) { + assert s instanceof LocalDecl : s.getClass(); // FIXME: proper error + LocalDecl s_ = (LocalDecl) s; + Expr init_expr = s_.init(); + assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: + // proper + // error + X10Call_c init_call = (X10Call_c) init_expr; + Receiver init_call_target = init_call.target(); + assert init_call_target instanceof CanonicalTypeNode : init_call_target + .getClass(); // FIXME: proper error + CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; + assert init_call_target_node.nameString().equals("CUDAUtilities") : init_call_target_node + .nameString(); + assert init_call.typeArguments().size() == 0 : init_call + .typeArguments(); + if (init_call.name().toString().equals("autoBlocks")) { + assert context().autoBlocks() == null : "Already have autoBlocks: " + + context().autoBlocks(); + context().autoBlocks(s_); + context().established().autoBlocks(s_); + } else if (init_call.name().toString().equals("autoThreads")) { + assert context().autoThreads() == null : "Already have autoThreads: " + + context().autoThreads(); + context().autoThreads(s_); + context().established().autoThreads(s_); + } else { + assert false : init_call.name(); + } + } + + public void visit(Block_c b) { super.visit(b); if (blockIsKernel(b)) { Block_c closure_body = b; - //System.out.println(b); - /* example of KMeansCUDA kernel - { - [OPTIONAL] final x10.lang.Int blocks = x10.compiler.CUDAUtilities.autoBlocks(); - [OPTIONAL] final x10.lang.Int threads = x10.compiler.CUDAUtilities.autoThreads(); - [OPTIONAL]* final x10.lang.Rail[x10.lang.Float] cmem = x10.lang.Rail.make[x10.lang.Float](x10.lang.Int.operator*(num_clusters, 4), clusters_copy); - { - final x10.lang.Int block321min322 = 0; - final x10.lang.Int block321max323 = x10.lang.Int.operator-(blocks, 1); - for (x10.lang.Int block321 = block321min322;; x10.lang.Int{self==0}.operator<=(block321, block321max323)eval(block321 += 1);) { - final x10.lang.Int block = block321; - { - [OPTIONAL]* final x10.lang.Rail[x10.lang.Float] clustercache = x10.lang.Rail.make[x10.lang.Float](x10.lang.Int.operator*(num_clusters, 4), clusters_copy); - { - final x10.lang.Int{self==0} thread318min319 = 0; - final x10.lang.Int thread318max320 = x10.lang.Int.operator-(threads, 1); - for (x10.lang.Int{self==0} thread318 = thread318min319;; x10.lang.Int.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."; + //System.out.println(b); // useful for finding out what the frontend is actually giving us + + assert !generatingKernel() : "Nesting of cuda annotation makes no sense."; // TODO: assert the block is the body of an async assert b.statements().size()>=1 : b.statements(); @@ -581,23 +572,35 @@ LocalDecl ld = (LocalDecl) st; Expr init_expr = ld.init(); // TODO: primitive vals and shared vars - assert init_expr instanceof X10Call_c; // FIXME: proper error - X10Call_c init_call = (X10Call_c) init_expr; + assert init_expr instanceof X10New_c; + X10New_c init_new = (X10New_c) init_expr; + Type instantiatedType = init_new.objectType().type(); + assert xts().isArray(instantiatedType) : instantiatedType; + TypeNode rail_type_arg_node = init_new.typeArguments().get(0); + + //assert init_expr instanceof X10Call_c : init_expr.getClass(); // FIXME: proper error + //X10Call_c init_call = (X10Call_c) init_expr; // TODO: makeVal too - Receiver init_call_target = init_call.target(); - assert init_call_target instanceof CanonicalTypeNode; // FIXME: proper error - CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; - assert init_call_target_node.nameString().equals("Rail"); - assert init_call.name().toString().equals("make") : init_call.name(); // FIXME: proper error - assert init_call.typeArguments().size() == 1; - TypeNode rail_type_arg_node = init_call.typeArguments().get(0); + //Receiver init_call_target = init_call.target(); + //assert init_call_target instanceof CanonicalTypeNode; // FIXME: proper error + //CanonicalTypeNode init_call_target_node = (CanonicalTypeNode) init_call_target; + //assert init_call_target_node.nameString().equals("Rail"); + //assert init_call.name().toString().equals("make") : init_call.name(); // FIXME: proper error + //assert init_call.typeArguments().size() == 1; + //TypeNode rail_type_arg_node = init_call.typeArguments().get(0); Type rail_type_arg = rail_type_arg_node.type(); // TODO: support other types - assert rail_type_arg.isFloat(); - assert init_call.arguments().size() == 2; - Expr num_elements = init_call.arguments().get(0); - Expr rail_init_closure = init_call.arguments().get(1); - shm.addRail(ld, num_elements, rail_init_closure); + assert rail_type_arg.isFloat() : rail_type_arg; + if (init_new.arguments().size()==2) { + Expr num_elements = init_new.arguments().get(0); + Expr rail_init_closure = init_new.arguments().get(1); + shm.addArrayInitClosure(ld, num_elements, rail_init_closure); + } else { + assert init_new.arguments().size() == 1 : init_new.arguments().size(); + Expr src_array = init_new.arguments().get(0); + assert xts().isArray(src_array.type()) || xts().isRemoteArray(src_array.type()) : src_array; + shm.addArrayInitArray(ld, src_array); + } } MultipleValues inner = processLoop(for_block2); @@ -641,469 +644,574 @@ } } - public void visit(Closure_c n) { - context().establishClosure(); - String last = context().wrappingClosure(); - String lastHostClassName = context().wrappingClass(); - X10ClassType hostClassType = (X10ClassType) n.closureDef().typeContainer().get(); - String nextHostClassName = Emitter.translate_mangled_FQN(hostClassType.fullName().toString(), "_"); - String next = getClosureName(nextHostClassName, context().closureId()+1); - //System.out.println(last+" goes to "+next); - context().wrappingClosure(next); - context().wrappingClass(nextHostClassName); - super.visit(n); - context().wrappingClosure(last); - context().wrappingClass(lastHostClassName); - //System.out.println("back to "+last); - } + public void visit(Closure_c n) { + context().establishClosure(); + String last = context().wrappingClosure(); + String lastHostClassName = context().wrappingClass(); + X10ClassType hostClassType = (X10ClassType) n.closureDef() + .typeContainer().get(); + String nextHostClassName = Emitter.translate_mangled_FQN(hostClassType + .fullName().toString(), "_"); + String next = getClosureName(nextHostClassName, + context().closureId() + 1); + // System.out.println(last+" goes to "+next); + context().wrappingClosure(next); + context().wrappingClass(nextHostClassName); + super.visit(n); + context().wrappingClosure(last); + context().wrappingClass(lastHostClassName); + // System.out.println("back to "+last); + } - - protected void generateClosureDeserializationIdDef(ClassifiedStream defn_s, String cnamet, List<Type> freeTypeParams, String hostClassName, Block block) { - if (blockIsKernel(block)) { - - X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); - boolean in_template_closure = freeTypeParams.size()>0; - if (in_template_closure) - emitter.printTemplateSignature(freeTypeParams, defn_s); - defn_s.write("const x10aux::serialization_id_t "+cnamet+"::"+SharedVarsMethods.SERIALIZATION_ID_FIELD+" = "); - defn_s.newline(4); - String template = in_template_closure ? "template " : ""; - defn_s.write("x10aux::DeserializationDispatcher::addDeserializer("+ - cnamet+"::"+template+SharedVarsMethods.DESERIALIZE_METHOD+ - chevrons("x10::lang::Reference")+", true, "+ - cnamet+"::"+template+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+", "+ - "\""+hostClassName+".cubin\", \""+cnamet+"\");"); - defn_s.newline(); defn_s.forceNewline(); - } else { - super.generateClosureDeserializationIdDef(defn_s, cnamet, freeTypeParams, hostClassName, block); - } - } - - protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { - super.generateClosureSerializationFunctions(c, cnamet, inc, block); + protected void generateClosureDeserializationIdDef(ClassifiedStream defn_s, + String cnamet, List<Type> freeTypeParams, String hostClassName, + Block block) { + if (blockIsKernel(block)) { - if (blockIsKernel(block)) { - - inc.write("static void "+SharedVarsMethods.DESERIALIZE_CUDA_METHOD+"("+DESERIALIZATION_BUFFER+" &__buf, x10aux::place __gpu, size_t &__blocks, size_t &__threads, size_t &__shm, size_t &argc, char *&argv, size_t &cmemc, char *&cmemv) {"); - inc.newline(4); inc.begin(0); - - inc.write(make_ref(cnamet)+" __this = "+cnamet+"::"+DESERIALIZE_METHOD+"<"+cnamet+">(__buf);"); - inc.newline(); - - ArrayList<VarInstance<?>> env = context().kernelParams(); + X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); + boolean in_template_closure = freeTypeParams.size() > 0; + if (in_template_closure) + emitter.printTemplateSignature(freeTypeParams, defn_s); + defn_s.write("const x10aux::serialization_id_t " + cnamet + "::" + + SharedVarsMethods.SERIALIZATION_ID_FIELD + " = "); + defn_s.newline(4); + String template = in_template_closure ? "template " : ""; + defn_s.write("x10aux::DeserializationDispatcher::addDeserializer(" + + cnamet + "::" + template + + SharedVarsMethods.DESERIALIZE_METHOD + + chevrons("x10::lang::Reference") + ", true, " + + cnamet + "::" + template + SharedVarsMethods.DESERIALIZE_CUDA_METHOD + ", " + + cnamet + "::" + template + SharedVarsMethods.POST_CUDA_METHOD + ", " + + "\"" + hostClassName + ".cubin\", \"" + cnamet + "\");"); + defn_s.newline(); + defn_s.forceNewline(); + } else { + super.generateClosureDeserializationIdDef(defn_s, cnamet, + freeTypeParams, hostClassName, block); + } + } - for (VarInstance<?> var : env) { - Type t = var.type(); - String name = var.name().toString(); - inc.write(Emitter.translateType(t, true)+" "+name); - if (context().autoBlocks()!=null && var == context().autoBlocks().localDef().asInstance()) { - inc.write(";"); - } else if (context().autoThreads()!=null && var == context().autoThreads().localDef().asInstance()) { - inc.write(";"); - } else { - inc.write(" = __this->"+name+";"); - } - inc.newline(); - } - - inc.write("__shm = "); inc.begin(0); - context().shm().generateSize(inc, tr); - inc.write(";"); inc.end(); inc.newline(); - - if (context().autoBlocks()!=null && context().autoThreads()!=null) { - String bname = context().autoBlocks().name().id().toString(); - String tname = context().autoThreads().name().id().toString();; - inc.write("x10aux::blocks_threads(__gpu, x10aux::DeserializationDispatcher::getMsgType(_serialization_id), __shm, "+bname+", "+tname+");"); inc.newline(); - }// else { - inc.write("__blocks = ("); inc.begin(0); - tr.print(null, context().blocks(), inc); - inc.write(")+1;"); inc.end(); inc.newline(); + protected void generateClosureSerializationFunctions(X10CPPContext_c c, + String cnamet, StreamWrapper inc, Block block) { + super.generateClosureSerializationFunctions(c, cnamet, inc, block); - inc.write("__threads = ("); inc.begin(0); - tr.print(null, context().threads(), inc); - inc.write(")+1;"); inc.end(); inc.newline(); - //} - - generateStruct("__", inc, context().kernelParams()); - inc.write("___env __env;"); inc.newline(); - - for (VarInstance<?> var : env) { - Type t = var.type(); - String name = var.name().toString(); - inc.write("__env."+name+" = "); - - //String addr = "&(*"+name+")[0]"; // old way for rails - String addr = "&"+name+"->FMGL(raw).raw()[0]"; - //String rr = "x10aux::get_remote_ref_maybe_null("+name+".operator->())"; // old object model - String rr = "&"+name+"->FMGL(rawData).raw()[0]"; - - if (isIntArray(t)) { - if (xts().isRemoteArray(t)) { - inc.write("(x10_int*)(size_t)"+rr); - } else { - String sz = "sizeof(x10_int)*"+name+"->FMGL(rawLength)"; - inc.write("(x10_int*)(size_t)x10aux::remote_alloc(__gpu, "+sz+");"); inc.newline(); - inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", "+addr+", "+sz+")"); - } - } else if (isFloatArray(t)) { - if (xts().isRemoteArray(t)) { - inc.write("(x10_float*)(size_t)"+rr); - } else { - String sz = "sizeof(x10_float)*"+name+"->FMGL(rawLength)"; - inc.write("(x10_float*)(size_t)x10aux::remote_alloc(__gpu, "+sz+");"); inc.newline(); - inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env."+name+", "+addr+", "+sz+")"); - } - } else { - inc.write(name); - } - inc.write(";"); - inc.newline(); - } - - if (env.isEmpty()) { - inc.write("argc = 0;"); inc.end(); inc.newline(); - } else { - if (kernelWantsDirectParams(block)) { - inc.write("memcpy(argv, &__env, sizeof(__env));"); inc.newline(); - inc.write("argc = sizeof(__env);"); inc.end(); inc.newline(); - } else { - inc.write("x10_ulong __remote_env = x10aux::remote_alloc(__gpu, sizeof(__env));"); inc.newline(); - inc.write("x10aux::cuda_put(__gpu, __remote_env, &__env, sizeof(__env));"); inc.newline(); - inc.write("::memcpy(argv, &__remote_env, sizeof (void*));"); inc.newline(); - inc.write("argc = sizeof(void*);"); inc.end(); inc.newline(); - } - } - inc.write("}"); inc.newline(); inc.forceNewline(); - } - } - - public void visit(New_c n) { - assert !generatingKernel() : "New not allowed in @CUDA code."; - super.visit(n); - } + if (blockIsKernel(block)) { - @Override - public void visit(Assert_c n) { - assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; - super.visit(n); - } + ArrayList<VarInstance<?>> env = context().kernelParams(); - @Override - public void visit(Assign_c asgn) { - // TODO Auto-generated method stub - super.visit(asgn); - } + generateStruct("__cuda", inc, env); - @Override - public void visit(AssignPropertyCall_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + inc.write("static void " + + SharedVarsMethods.POST_CUDA_METHOD + + "(" + + DESERIALIZATION_BUFFER + + " &__buf, x10aux::place __gpu, size_t __blocks, size_t __threads, size_t __shm, size_t argc, char *argv, size_t cmemc, char *cmemv) {"); + inc.newline(4); + inc.begin(0); - @Override - public void visit(Await_c n) { - assert !generatingKernel() : "Await not allowed in @CUDA code."; - super.visit(n); - } + inc.write("__cuda_env __env;"); + inc.newline(); - @Override - public void visit(Binary_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + if (!kernelWantsDirectParams(block)) { + inc.write("x10_ulong __remote_env;"); + inc.newline(); + inc.write("::memcpy(&__remote_env, argv, sizeof (void*));"); + inc.newline(); + inc.write("x10aux::remote_free(__gpu, __remote_env);"); + inc.newline(); + //FIXME: any arrays referenced from the env are being leaked here. + // we need some way to record a copy of the contents of the __env on the host + // so that we do not have to fetch __remote_env back onto the host + // then we can free those arrays like in the else branch below + } else { + inc.write("::memcpy(&__env, argv, argc);"); + inc.newline(); + for (VarInstance<?> var : env) { + Type t = var.type(); + String name = var.name().toString(); + if (isIntArray(t) || isFloatArray(t)) { + if (!xts().isRemoteArray(t)) { + inc.write("x10aux::remote_free(__gpu, (x10_ulong)(size_t)__env."+name+".raw);"); + } + } + inc.newline(); + } + + } + + inc.end(); inc.newline(); + inc.write("}"); inc.newline(); + + inc.forceNewline(); + + inc.write("static void " + + SharedVarsMethods.DESERIALIZE_CUDA_METHOD + + "(" + + DESERIALIZATION_BUFFER + + " &__buf, x10aux::place __gpu, size_t &__blocks, size_t &__threads, size_t &__shm, size_t &argc, char *&argv, size_t &cmemc, char *&cmemv) {"); + inc.newline(4); + inc.begin(0); - @Override - public void visit(BooleanLit_c lit) { - // TODO Auto-generated method stub - super.visit(lit); - } + inc.write(make_ref(cnamet) + " __this = " + cnamet + "::" + + DESERIALIZE_METHOD + "<" + cnamet + ">(__buf);"); + inc.newline(); - @Override - public void visit(Branch_c br) { - // TODO Auto-generated method stub - super.visit(br); - } + for (VarInstance<?> var : env) { + Type t = var.type(); + String name = var.name().toString(); + inc.write(Emitter.translateType(t, true) + " " + name); + if (context().autoBlocks() != null + && var == context().autoBlocks().localDef() + .asInstance()) { + inc.write(";"); + } else if (context().autoThreads() != null + && var == context().autoThreads().localDef() + .asInstance()) { + inc.write(";"); + } else { + inc.write(" = __this->" + name + ";"); + } + inc.newline(); + } - @Override - public void visit(Case_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + inc.write("__shm = "); + inc.begin(0); + context().shm().generateSize(inc, tr); + inc.write(";"); + inc.end(); + inc.newline(); - @Override - public void visit(Catch_c n) { - assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; - super.visit(n); - } + if (context().autoBlocks() != null + && context().autoThreads() != null) { + String bname = context().autoBlocks().name().id().toString(); + String tname = context().autoThreads().name().id().toString(); + inc.write("x10aux::blocks_threads(__gpu, x10aux::DeserializationDispatcher::getMsgType(_serialization_id), __shm, " + + bname + ", " + tname + ");"); + inc.newline(); + }// else { + inc.write("__blocks = ("); + inc.begin(0); + tr.print(null, context().blocks(), inc); + inc.write(")+1;"); + inc.end(); + inc.newline(); - @Override - public void visit(CharLit_c lit) { - // TODO Auto-generated method stub - super.visit(lit); - } + inc.write("__threads = ("); + inc.begin(0); + tr.print(null, context().threads(), inc); + inc.write(")+1;"); + inc.end(); + inc.newline(); + // } - @Override - public void visit(ClosureCall_c c) { - assert !generatingKernel() : "Closure calls not allowed in @CUDA code."; - super.visit(c); - } + inc.write("__cuda_env __env;"); + inc.newline(); - @Override - public void visit(Conditional_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + for (VarInstance<?> var : env) { + Type t = var.type(); + String name = var.name().toString(); - @Override - public void visit(Do_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + // String addr = "&(*"+name+")[0]"; // old way for rails + String addr = "&" + name + "->FMGL(raw).raw()[0]"; + // String rr = + // "x10aux::get_remote_ref_maybe_null("+name+".operator->())"; + // // old object model + String rr = "&" + name + "->FMGL(rawData).raw()[0]"; - @Override - public void visit(Empty_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + String ts = null; + if (isIntArray(t)) { + ts = "x10_int"; + } else if (isFloatArray(t)) { + ts = "x10_float"; + } + + if (isIntArray(t) || isFloatArray(t)) { + if (xts().isRemoteArray(t)) { + inc.write("__env." + name + ".raw = ("+ts+"*)(size_t)"+rr+";"); + inc.newline(); + inc.write("__env." + name + ".size = "+name + "->FMGL(size);"); + inc.newline(); + } else { + String len = name + "->FMGL(rawLength)"; + String sz = "sizeof("+ts+")*" + len; + inc.write("__env." + name + ".raw = ("+ts+"*)(size_t)x10aux::remote_alloc(__gpu, "+sz+");"); + inc.newline(); + inc.write("__env." + name + ".size = "+len+";"); + inc.newline(); + inc.write("x10aux::cuda_put(__gpu, (x10_ulong) __env." + name + ".raw, " + addr + ", " + sz + ");"); + } + } else { + inc.write("__env." + name + " = " + name + ";"); + } + inc.newline(); + } - @Override - public void visit(Eval_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + if (env.isEmpty()) { + inc.write("argc = 0;"); + inc.end(); + inc.newline(); + } else { + if (kernelWantsDirectParams(block)) { + inc.write("memcpy(argv, &__env, sizeof(__env));"); + inc.newline(); + inc.write("argc = sizeof(__env);"); + inc.end(); + inc.newline(); + } else { + inc.write("x10_ulong __remote_env = x10aux::remote_alloc(__gpu, sizeof(__env));"); + inc.newline(); + inc.write("x10aux::cuda_put(__gpu, __remote_env, &__env, sizeof(__env));"); + inc.newline(); + inc.write("::memcpy(argv, &__remote_env, sizeof (void*));"); + inc.newline(); + inc.write("argc = sizeof(void*);"); + inc.end(); + inc.newline(); + } + } + inc.write("}"); + inc.newline(); + inc.forceNewline(); + } + } - @Override - public void visit(Field_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + public void visit(New_c n) { + assert !generatingKernel() : "New not allowed in @CUDA code."; + super.visit(n); + } - @Override - public void visit(FloatLit_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Assert_c n) { + assert !generatingKernel() : "Throwing exceptions not allowed in @CUDA code."; + super.visit(n); + } - @Override - public void visit(For_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Assign_c asgn) { + // TODO Auto-generated method stub + super.visit(asgn); + } - @Override - public void visit(ForLoop_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(AssignPropertyCall_c n) { + // TODO Auto-generated method stub + super.visit(n); + } - @Override - public void visit(Formal_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Await_c n) { + assert !generatingKernel() : "Await not allowed in @CUDA code."; + super.visit(n); + } - @Override - public void visit(Id_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Binary_c n) { + // TODO Auto-generated method stub + super.visit(n); + } - @Override - public void visit(If_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(BooleanLit_c lit) { + // TODO Auto-generated method stub + super.visit(lit); + } - @Override - public void visit(Initializer_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Branch_c br) { + // TODO Auto-generated method stub + super.visit(br); + } - @Override - public void visit(IntLit_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(Case_c n) { + // TODO Auto-generated method stub + super.visit(n); + } - @Override - public void visit(Labeled_c label) { - // TODO Auto-generated method stub - super.visit(label); - } + @Override + public void visit(Catch_c n) { + assert !generatingKernel() : "Catching exceptions not allowed in @CUDA code."; + super.visit(n); + } - @Override - public void visit(Local_c n) { - if (generatingKernel()) { - ClassifiedStream out = cudaStream(); - Name ln = n.name().id(); - if (ln == context().blocksVar()) { - out.write("blockIdx.x"); - } else if (ln == context().threadsVar()) { - out.write("threadIdx.x"); - } else if (context().shm().has(ln)) { - out.write(ln.toString()); - } else if (context().isKernelParam(ln)) { - //it seems the post-compiler is not good at hoisting these accesses so we do it ourselves - if (context().directParams()) { - out.write(env + "." + ln); - } else { - out.write(ln.toString()); - } - } else { - super.visit(n); - } - } else { - // we end up here in the _deserialize_cuda function because generatingKernel() is false - Name ln = n.name().id(); - if (context().autoBlocks()!=null && ln == context().autoBlocks().name().id()) { - sw.write(context().autoBlocks().name().id().toString()); - } else if (context().autoThreads()!=null && ln == context().autoThreads().name().id()) { - sw.write(context().autoThreads().name().id().toString()); - } else { - super.visit(n); - } - } - } + @Override + public void visit(CharLit_c lit) { + // TODO Auto-generated method stub + super.visit(lit); + } - @Override - public void visit(NullLit_c n) { - // TODO Auto-generated method stub - super.visit(n); - } + @Override + public void visit(ClosureCall_c c) { + assert !generatingKernel() : "Closure calls not allowed in @CUDA code."; + super.visit(c); + } - @Override - public void visit(Return_c ret) { - // TODO Auto-generated method stub - super.visit(ret); - } + @Override + public void visit(Conditional_c n) { + // TODO Auto-genera... [truncated message content] |
From: <yz...@us...> - 2010-09-30 16:45:07
|
Revision: 16812 http://x10.svn.sourceforge.net/x10/?rev=16812&view=rev Author: yzibin Date: 2010-09-30 16:45:01 +0000 (Thu, 30 Sep 2010) Log Message: ----------- Handled @Uncounted async S like this: async if (flag) S Modified Paths: -------------- trunk/x10.compiler/src/polyglot/visit/InitChecker.java trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/polyglot/visit/InitChecker.java =================================================================== --- trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-09-30 15:55:23 UTC (rev 16811) +++ trunk/x10.compiler/src/polyglot/visit/InitChecker.java 2010-09-30 16:45:01 UTC (rev 16812) @@ -27,6 +27,8 @@ import x10.ast.Finish_c; import x10.extension.X10Ext_c; import x10.types.X10LocalDef; +import x10.types.X10TypeSystem; +import x10.visit.Desugarer; /** * Visitor which checks that all local variables must be defined before use, @@ -283,7 +285,7 @@ final static MinMaxInitCount ONE = new MinMaxInitCount(InitCount.ONE,InitCount.ONE,InitCount.ONE,InitCount.ONE); - protected final InitCount minSeq, maxSeq, minAsync, maxAsync; + private final InitCount minSeq, maxSeq, minAsync, maxAsync; private MinMaxInitCount(InitCount minSeq, InitCount maxSeq,InitCount minAsync, InitCount maxAsync) { this.minSeq = minSeq; @@ -318,7 +320,7 @@ MinMaxInitCount finish() { return new MinMaxInitCount(minAsync,maxAsync,minAsync,maxAsync);//[c,d,c,d] } - static MinMaxInitCount join(Term node, VarDef v, boolean entry, MinMaxInitCount initCount1, MinMaxInitCount initCount2) { + static MinMaxInitCount join(X10TypeSystem xts, Term node, boolean entry, MinMaxInitCount initCount1, MinMaxInitCount initCount2) { assert !(node instanceof Finish); if (initCount1 == null) return initCount2; if (initCount2 == null) return initCount1; @@ -345,7 +347,15 @@ small.minAsync.count<=big.minAsync.count && small.maxAsync.count<=big.maxAsync.count; - return new MinMaxInitCount(small.minSeq, small.maxSeq, big.minAsync, big.maxAsync); // [a',b', c, d] + + boolean isUncounted = Desugarer.isUncountedAsync(xts,async); + //@Uncounted async S + //is treated like this: + //async if (flag) S + //so the statement in S might or might not get executed. + //Therefore even after a "finish" we still can't use anything assigned in S. + + return new MinMaxInitCount(small.minSeq, small.maxSeq, isUncounted ? small.minAsync : big.minAsync, big.maxAsync); // [a',b', c, d] } // normal join: [min(a,a'), max(b,b'), min(c,c'), max(d,d')] return new MinMaxInitCount( @@ -696,7 +706,7 @@ VarDef v = (VarDef)e.getKey(); MinMaxInitCount initCount1 = m.get(v); MinMaxInitCount initCount2 = (MinMaxInitCount)e.getValue(); - m.put(v, MinMaxInitCount.join(node,v,entry,initCount1, initCount2)); + m.put(v, MinMaxInitCount.join((X10TypeSystem)ts,node,entry,initCount1, initCount2)); } } } Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-09-30 15:55:23 UTC (rev 16811) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-09-30 16:45:01 UTC (rev 16812) @@ -55,6 +55,8 @@ import x10.ast.X10NodeFactory; import x10.ast.X10IntLit_c; import x10.ast.X10StringLit_c; +import x10.ast.Async; +import x10.ast.AnnotationNode; import x10.constraint.XFailure; import x10.constraint.XNameWrapper; import x10.constraint.XVar; @@ -64,6 +66,7 @@ import x10.types.constraints.CConstraint; import x10.types.constraints.TypeConstraint; import x10.types.constraints.XConstrainedTerm; +import x10.extension.X10Del; /** * Utilities for dealing with X10 dependent types. @@ -999,7 +1002,7 @@ public static boolean isSuppressTransientErrorField(X10FieldDef def,X10TypeSystem ts) { return isDefAnnotated(def,ts,"x10.compiler.SuppressTransientError"); } - public static String getNonEscapingReadsFrom(X10ProcedureDef def,X10TypeSystem ts) { + public static String getNonEscapingReadsFrom(X10Def def,X10TypeSystem ts) { try { Type at = (Type) ts.systemResolver().find(QName.make("x10.compiler.NonEscaping")); final List<Type> annotations = def.annotationsMatching(at); Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-30 15:55:23 UTC (rev 16811) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-09-30 16:45:01 UTC (rev 16812) @@ -55,7 +55,7 @@ private static int afterAssign(int i) { return build(isRead(i),true,true); } private static int afterRead(int i) { return build(isRead(i) || !isSeqWrite(i),isWrite(i),isSeqWrite(i)); } private static int afterSeqBlock(int bBefore, int bAfter) { return build(isRead(bBefore) || (!isSeqWrite(bBefore) && isRead(bAfter)), isWrite(bBefore) || isWrite(bAfter),isSeqWrite(bBefore) || isSeqWrite(bAfter)); } - private static int afterAsync(int i1, int i2) { return build(isRead(i1)||isRead(i2),isWrite(i1)||isWrite(i2),isSeqWrite(i1)&&isSeqWrite(i2)); } + private static int afterAsync(int i1, int i2, boolean isUncounted) { return build(isRead(i1)||isRead(i2),!isUncounted ? isWrite(i1)||isWrite(i2) : isWrite(i1)&&isWrite(i2),isSeqWrite(i1)&&isSeqWrite(i2)); } private static int afterIf(int i1, int i2) { return build(isRead(i1)||isRead(i2),isWrite(i1)&&isWrite(i2),isSeqWrite(i1)&&isSeqWrite(i2)); } private static String flagsToString(int i) { return i==0? "none," : (isRead(i)?"read," : "")+(isWrite(i)?"write," : "")+(isSeqWrite(i)?"seqWrite," : ""); } @@ -117,6 +117,7 @@ assert items.size()>=2; boolean isAsync = !entry && node instanceof Async; + boolean isUncounted = isAsync ? Desugarer.isUncountedAsync((X10TypeSystem)ts,(Async) node) : false; DataFlowItem res = new DataFlowItem(); res.initStatus.putAll(((DataFlowItem) items.get(0)).initStatus); @@ -130,7 +131,7 @@ //p.inItem = this.safeConfluence(... //p.outItems = this.flow(... - int i_res = isAsync ? afterAsync(i1,i2) : afterIf(i1,i2); + int i_res = isAsync ? afterAsync(i1,i2,isUncounted) : afterIf(i1,i2); res.initStatus.put(key,i_res); } } Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-09-30 15:55:23 UTC (rev 16811) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-09-30 16:45:01 UTC (rev 16812) @@ -449,7 +449,7 @@ Position pos = a.position(); X10Ext ext = (X10Ext) a.ext(); List<X10ClassType> refs = Emitter.annotationsNamed(xts, a, REF); - if (Emitter.hasAnnotation(xts, a, UNCOUNTED)) { + if (isUncountedAsync(xts,a)) { if (old instanceof Async) return uncountedAsync(pos, a.body()); } @@ -466,7 +466,7 @@ List<Expr> clocks = clocks(a.clocked(), a.clocks()); Position pos = a.position(); List<X10ClassType> refs = Emitter.annotationsNamed(xts, a, REF); - if (Emitter.hasAnnotation(xts, a, UNCOUNTED)) { + if (isUncountedAsync(xts,a)) { return uncountedAsync(pos, body, place); } Stmt specializedAsync = specializeAsync(a, place, body); @@ -490,6 +490,10 @@ private static final QName UNCOUNTED = QName.make("x10.compiler.Uncounted"); private static final QName REMOTE_OPERATION = QName.make("x10.compiler.RemoteOperation"); + public static boolean isUncountedAsync(X10TypeSystem xts, Async a) { + return Emitter.hasAnnotation(xts, a, UNCOUNTED); + } + /** * Recognize the following pattern: * <pre> Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-30 15:55:23 UTC (rev 16811) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-09-30 16:45:01 UTC (rev 16812) @@ -1,10 +1,103 @@ // test object initialization -import x10.compiler.*; +import x10.compiler.*; // @Uncounted @NonEscaping +class TestUncountedAsync1 { + //@Uncounted async S + //is treated like this: + //async if (flag) S + //so the statement in S might or might not get executed. + //Therefore even after a "finish" we still can't use anything assigned in S. + def test1() { + val q:Int,q2:Int; + finish { + q2=2; + use(q2); + use(q); // ERR + @Uncounted async { + use(q2); + q=1; + use(q); + } + use(q2); + use(q); // ERR + } + use(q2); + use(q); // ERR + } + def test2() { + var q:Int; + finish { + @Uncounted async { + q=1; + use(q); + } + use(q); // ERR + } + use(q); // ERR + } + def test3() { + var q:Int; + finish { + @Uncounted async { + async { // it is implicitly @Uncounted + q=1; + use(q); + } + } + use(q); // ERR + } + use(q); // ERR + } + def use(a:Int) {} + var x:Int{self!=0}; + var x2:Int{self!=0}; + def this() { // ERR: Field 'x' was not definitely assigned in this constructor. + finish { + async x2=1; + @Uncounted async { + x=1; + } + } + } + static class Box[T] { + var t:T; + def this(t:T) { this.t = t; } + } + def mainExample() { + val box = new Box[Boolean](false); + @Uncounted async { + Console.OUT.println("HELLO"); + @Uncounted async { + atomic box.t = true; + } + } + when (!box.t) {} + } +} + + +class SquareMatrixTest123(rows:Int, cols:Int, matDist:Dist, mat:DistArray[Int]){ + var z:Int = 2; + val q:Int; + def this(r:Int, c:Int{self == r}) { + val mShape = [1..r, 1..c] as Region; + val mDist = Dist.makeBlock(mShape); + z++; // ERR: Can use 'this' only after 'property(...)' + val closure = () => z++; // ERR: Can use 'this' only after 'property(...)' + val closure2 = () => q; // ERR: Can use 'this' only after 'property(...)' ERR: Cannot read from field 'q' before it is definitely assigned. + property(r, c, mDist, DistArray.make[Int](mDist, + initMat // ERR: Can use 'this' only after 'property(...)' + )); + q=3; + } + val initMat : (Point) => int = ([x,y]:Point) => x+y; +} + + class SomeSuper87 { def this(i:Int) {} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-09-30 18:42:55
|
Revision: 16814 http://x10.svn.sourceforge.net/x10/?rev=16814&view=rev Author: dgrove-oss Date: 2010-09-30 18:42:48 +0000 (Thu, 30 Sep 2010) Log Message: ----------- Change non-serialization NativeClass classes to implement CustomSerialization and define serialize to throw an exception. This will detect any doomed-to-fail attempts to serialize instances of these classes. Added compensating constructors to subclasses so that the generated deserialize code compiles. Modified Paths: -------------- trunk/TODO_21_OBJ_MODEL.txt trunk/x10.runtime/src-x10/x10/lang/Latch.x10 trunk/x10.runtime/src-x10/x10/lang/Lock.x10 trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 Modified: trunk/TODO_21_OBJ_MODEL.txt =================================================================== --- trunk/TODO_21_OBJ_MODEL.txt 2010-09-30 17:12:34 UTC (rev 16813) +++ trunk/TODO_21_OBJ_MODEL.txt 2010-09-30 18:42:48 UTC (rev 16814) @@ -1,8 +1,3 @@ -Need to look at serialization/deserialzation for all @NativeClass -classes and decide what to do. Most likely outcome is to have -@NativeClass classes throw an exception if someone attempts to -serialize them. - x10.io.GlobalStringWriter Do we really want this class? See todo in the class header. In general, normalize APIs for Global vs.Local operations, Modified: trunk/x10.runtime/src-x10/x10/lang/Latch.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Latch.x10 2010-09-30 17:12:34 UTC (rev 16813) +++ trunk/x10.runtime/src-x10/x10/lang/Latch.x10 2010-09-30 18:42:48 UTC (rev 16814) @@ -15,23 +15,30 @@ import x10.compiler.Global; @Pinned public class Latch extends Monitor implements ()=>Boolean { - private var state:boolean = false; - public def release():void { + public def this() { super(); } + + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } + + private var state:boolean = false; + + public def release():void { + lock(); + state = true; + super.release(); + } + + public def await():void { + // avoid locking if state == true + Runtime.ensureNotInAtomic(); + if (!state) { lock(); - state = true; - super.release(); - } - - public def await():void { - // avoid locking if state == true - Runtime.ensureNotInAtomic(); - if (!state) { - lock(); - while (!state) super.await(); + while (!state) super.await(); unlock(); } } - public def apply():boolean = state; // memory model? - } + public def apply():boolean = state; // memory model? +} Modified: trunk/x10.runtime/src-x10/x10/lang/Lock.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Lock.x10 2010-09-30 17:12:34 UTC (rev 16813) +++ trunk/x10.runtime/src-x10/x10/lang/Lock.x10 2010-09-30 18:42:48 UTC (rev 16814) @@ -17,15 +17,23 @@ import x10.compiler.Global; @NativeClass("java", "java.util.concurrent.locks", "ReentrantLock") - @NativeClass("c++", "x10.lang", "Lock__ReentrantLock") - @Pinned public class Lock { - public native def this(); +@NativeClass("c++", "x10.lang", "Lock__ReentrantLock") +@Pinned public class Lock implements x10.io.CustomSerialization { + public native def this(); - public native def lock():void; + public native def lock():void; - public native def tryLock():Boolean; + public native def tryLock():Boolean; - public native def unlock():void; + public native def unlock():void; - native def getHoldCount():Int; - } \ No newline at end of file + native def getHoldCount():Int; + + public def serialize():Any { + throw new UnsupportedOperationException("Cannot serialize "+typeName()); + } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } + +} \ No newline at end of file Modified: trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 2010-09-30 17:12:34 UTC (rev 16813) +++ trunk/x10.runtime/src-x10/x10/lang/Monitor.x10 2010-09-30 18:42:48 UTC (rev 16814) @@ -16,42 +16,50 @@ import x10.util.Stack; @Pinned public class Monitor extends Lock { - static type Thread = Runtime.Thread; - /** - * Parked threads - */ - private val threads = new Stack[Thread](); + public def this() { super(); } - /** - * Park calling thread - * Increment blocked thread count - * Must be called while holding the lock - * Must not be called while holding the lock more than once - */ - def await():void { - Runtime.increaseParallelism(); - val thread = Thread.currentThread(); - threads.push(thread); - while (threads.contains(thread)) { - unlock(); - Runtime.park(); - lock(); - } - } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } - /** - * Unpark every thread - * Decrement blocked thread count - * Release the lock - * Must be called while holding the lock - */ - def release():void { - val size = threads.size(); - if (size > 0) { - Runtime.decreaseParallelism(size); - for (var i:Int = 0; i<size; i++) Runtime.unpark(threads.pop()); - } + + static type Thread = Runtime.Thread; + + /** + * Parked threads + */ + private val threads = new Stack[Thread](); + + /** + * Park calling thread + * Increment blocked thread count + * Must be called while holding the lock + * Must not be called while holding the lock more than once + */ + def await():void { + Runtime.increaseParallelism(); + val thread = Thread.currentThread(); + threads.push(thread); + while (threads.contains(thread)) { unlock(); + Runtime.park(); + lock(); } } + /** + * Unpark every thread + * Decrement blocked thread count + * Release the lock + * Must be called while holding the lock + */ + def release():void { + val size = threads.size(); + if (size > 0) { + Runtime.decreaseParallelism(size); + for (var i:Int = 0; i<size; i++) Runtime.unpark(threads.pop()); + } + unlock(); + } +} + Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-09-30 17:12:34 UTC (rev 16813) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-09-30 18:42:48 UTC (rev 16814) @@ -13,12 +13,13 @@ import x10.compiler.Native; import x10.compiler.NativeClass; -import x10.compiler.NativeDef; import x10.compiler.NativeString; import x10.compiler.Pinned; import x10.compiler.Global; import x10.compiler.SuppressTransientError; +import x10.io.CustomSerialization; + import x10.util.HashMap; import x10.util.GrowableRail; import x10.util.Pair; @@ -138,7 +139,7 @@ @NativeClass("java", "x10.runtime.impl.java", "Deque") @NativeClass("c++", "x10.lang", "Deque") - @Pinned static final class Deque { + @Pinned static final class Deque implements CustomSerialization { public native def this(); public native def size():Int; @@ -148,6 +149,13 @@ public native def push(t:Object):void; public native def steal():Object; + + public def serialize():Any { + throw new UnsupportedOperationException("Cannot serialize "+typeName()); + } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } } @@ -867,8 +875,7 @@ * needed nor does the FinishState need a rail of counters: one is * enough! */ - - @Pinned static class LocalRootFinish extends Latch implements FinishState, Mortal { + @Pinned static class LocalRootFinish extends Latch implements FinishState, Mortal, CustomSerialization { private var counts:int; private var exceptions:Stack[Throwable]; public def this() { @@ -932,7 +939,15 @@ this.pushExceptionLocal(t); } public def makeRemote():RemoteFinishState = null; + + public def serialize():Any { + throw new UnsupportedOperationException("Cannot serialize "+typeName()); + } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } } + /** * SimpleRootFinish and SimpleRemoteFinish are desgined for the "finish" * which has asyncs that do not spawn asyncs in other places: in other words, @@ -940,7 +955,7 @@ * SimpleRootFinish still requires a rail of counters, but SimpleRemoteFinish * only needs a counter */ - @Pinned static class SimpleRemoteFinish implements RemoteFinishState{ + @Pinned static class SimpleRemoteFinish implements RemoteFinishState { /** * The Exception Stack is used to collect exceptions * issued when activities associated with this finish state terminate abruptly. @@ -1029,6 +1044,10 @@ public def this() { counts = 1; } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } + @Global public def equals(a:Any) = (a instanceof SimpleRootFinish) && this.root.equals((a as SimpleRootFinish).root); @Global public def hashCode() = root.hashCode(); @@ -1131,7 +1150,7 @@ @NativeClass("java", "x10.runtime.impl.java", "Thread") @NativeClass("c++", "x10.lang", "Thread") - @Pinned final static class Thread { + @Pinned final static class Thread implements CustomSerialization { /** * Allocates new thread in current place @@ -1150,8 +1169,7 @@ public native static def parkNanos(nanos:Long):void; - // Why is this global? - public native /*global*/ def unpark():void; + public native def unpark():void; public native def worker():Object; @@ -1165,6 +1183,13 @@ public static native def getTid():Long; public native def home():Place; + + public def serialize():Any { + throw new UnsupportedOperationException("Cannot serialize "+typeName()); + } + private def this(Any) { + throw new UnsupportedOperationException("Cannot deserialize "+typeName()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-09-30 19:06:25
|
Revision: 16817 http://x10.svn.sourceforge.net/x10/?rev=16817&view=rev Author: tardieu Date: 2010-09-30 19:06:14 +0000 (Thu, 30 Sep 2010) Log Message: ----------- initial commit of the work-stealing codegen are extra runtime classes Modified Paths: -------------- trunk/x10.compiler/src/x10/ExtensionInfo.java Added Paths: ----------- trunk/x10.compiler/src/x10/compiler/ trunk/x10.compiler/src/x10/compiler/ws/ trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java trunk/x10.compiler/src/x10/compiler/ws/codegen/ trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSAsyncClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSFinishStmtClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSForLoopClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMainMethodClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSMethodFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSRegularFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSSwitchClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhenFrameClassGen.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSWhileDoLoopClassGen.java trunk/x10.compiler/src/x10/compiler/ws/util/ trunk/x10.compiler/src/x10/compiler/ws/util/AddIndirectLocalDeclareVisitor.java trunk/x10.compiler/src/x10/compiler/ws/util/AdvLocalAccessToFieldAccessReplacer.java trunk/x10.compiler/src/x10/compiler/ws/util/ClosureDefReinstantiator.java trunk/x10.compiler/src/x10/compiler/ws/util/CodePatternDetector.java trunk/x10.compiler/src/x10/compiler/ws/util/ILocalToFieldContainerMap.java trunk/x10.compiler/src/x10/compiler/ws/util/LocalAccessToFieldAccessReplacer.java trunk/x10.compiler/src/x10/compiler/ws/util/ReferenceContainer.java trunk/x10.compiler/src/x10/compiler/ws/util/TransCodes.java trunk/x10.compiler/src/x10/compiler/ws/util/Triple.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraph.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCallGraphNode.java trunk/x10.compiler/src/x10/compiler/ws/util/WSCodeGenUtility.java trunk/x10.runtime/src-x10/x10/compiler/ws/ trunk/x10.runtime/src-x10/x10/compiler/ws/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/FinishFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Frame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/MainFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RegularFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RootFinish.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/RootFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Stolen.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/ trunk/x10.runtime/src-x10/x10/compiler/ws/java/AsyncFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/BoxedBoolean.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/FinishFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Frame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/MainFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RegularFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RootFinish.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/RootFrame.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Stolen.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 Modified: trunk/x10.compiler/src/x10/ExtensionInfo.java =================================================================== --- trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-09-30 19:05:51 UTC (rev 16816) +++ trunk/x10.compiler/src/x10/ExtensionInfo.java 2010-09-30 19:06:14 UTC (rev 16817) @@ -454,11 +454,8 @@ goals.add(Serialized(job)); if (x10.Configuration.WORK_STEALING) { Goal wsCodeGenGoal = WSCodeGenerator(job); - if(wsCodeGenGoal != null) { - goals.add(wsCodeGenGoal); - wsCodeGenGoal.addPrereq(TypeCheckBarrier()); - //wsCodeGenGoal.addPrereq(WSExpressionFlattener(job)); - } + goals.add(wsCodeGenGoal); + wsCodeGenGoal.addPrereq(TypeCheckBarrier()); } // try retypechecking before inlining @@ -888,28 +885,7 @@ public Goal WSCodeGenerator(Job job) { TypeSystem ts = extInfo.typeSystem(); NodeFactory nf = extInfo.nodeFactory(); - - Goal result = null; - - try { - //Use reflect to load the class from - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class<?> c = cl - .loadClass("x10.compiler.ws.WSCodeGenerator"); - Constructor<?> con = c.getConstructor(Job.class, - TypeSystem.class, - NodeFactory.class, - String.class); - ContextVisitor wsvisitor = (ContextVisitor) con.newInstance(job, ts, nf, nativeAnnotationLanguage()); - 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."); - } catch (Throwable e) { - System.err.println("[X10_WS_ERR]Error in load Work-Stealing code gen class. Ignore Work-Stealing transform."); - e.printStackTrace(); - } - return result; + return new ValidatingVisitorGoal("WSCodeGenerator", job, new x10.compiler.ws.WSCodeGenerator(job, ts, nf, nativeAnnotationLanguage())).intern(this); } public Goal Desugarer(Job job) { Added: trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java (rev 0) +++ trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java 2010-09-30 19:06:14 UTC (rev 16817) @@ -0,0 +1,290 @@ +/* + * 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.ws; + +import java.util.List; + +import polyglot.ast.ConstructorDecl; +import polyglot.ast.Expr; +import polyglot.ast.MethodDecl; +import polyglot.ast.Node; +import polyglot.ast.NodeFactory; +import polyglot.frontend.Job; +import polyglot.types.ConstructorDef; +import polyglot.types.MethodDef; +import polyglot.types.SemanticException; +import polyglot.types.TypeSystem; +import polyglot.visit.ContextVisitor; +import polyglot.visit.NodeVisitor; +import x10.ast.Async; +import x10.ast.AtEach; +import x10.ast.Closure; +import x10.ast.Here; +import x10.ast.Offer; +import x10.ast.PlacedClosure; +import x10.ast.RemoteActivityInvocation; +import x10.ast.X10ClassDecl; +import x10.ast.X10NodeFactory; +import x10.compiler.ws.codegen.WSMainMethodClassGen; +import x10.compiler.ws.codegen.WSMethodFrameClassGen; +import x10.compiler.ws.util.WSCallGraph; +import x10.types.ClosureDef; +import x10.types.X10Context; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; +import x10.util.Synthesizer; + + +/** + * Visitor that generates code for work stealing. + * @author Haibo + * @author Haichuan + * + * In work-stealing code transformation, all methods with finish-async statements, + * and all methods that invoke directly or indirectly the above methods, + * need rewriting. + * + * So it needs to build a static call-graph, and have a DFS on the reverse call-graph + * edges and mark all methods reachable. + * + * In the first step, we only mark all methods that contain finish-async as the target. + */ +public class WSCodeGenerator extends ContextVisitor { + + private static final int debugLevel = 4; + + /** + * @param job + * @param ts + * @param nf + */ + final X10TypeSystem xts; + final X10NodeFactory xnf; + final Synthesizer synth; + final String theLanguage; + + + //And some frequent used type + + + + //Trick here + //Although there are different WSVisitor, each one has the same methodRecorder; + // FIXME: get rid of the static field + static protected WSTransformState wts; + + public WSCodeGenerator(Job job, TypeSystem ts, NodeFactory nf, String theLanguage) { + super(job, ts, nf); + + if(wts == null){ + wts = new WSTransformState(); + } + wts.addWSJob(job); + + xts = (X10TypeSystem) ts; + xnf = (X10NodeFactory) nf; + synth = new Synthesizer(xnf, xts); + this.theLanguage = theLanguage; + } + + + + + @Override + public NodeVisitor begin() { + NodeVisitor nv = super.begin(); + //now initialize wstc + wts.updateContextAndVisitor(this, getX10Context(), theLanguage); + return nv; + } + + + + WSCallGraph graph; + + @Override + public NodeVisitor superEnter(Node parent, Node n) { + if (n instanceof X10ClassDecl + && ((X10ClassDecl)n).classDef().isTopLevel()) { + X10ClassDecl classDecl = (X10ClassDecl)n; + String className = classDecl.name().toString(); + if(debugLevel > 5){ + System.out.println("[WS_INFO](running) Class:" + className); + } + wts.buildCallGraph(job, xnf, xts); + } + return super.superEnter(parent, n); + } + + + + + /* + * This method will check an AST node, and decide whether transform or not. + * MethodDecl --> if it is a target method, transform it into an inner class + * X10ClassDecl --> if it contains some newly added inner classes, add these classes to the container class + * + * ConstructorDecl --> if it contains concurrent, throw error + * Closure (not place procedure) --> if it contains concurrent, throw error + * + * + * @see polyglot.visit.ErrorHandlingVisitor#leaveCall(polyglot.ast.Node, polyglot.ast.Node, polyglot.ast.Node, polyglot.visit.NodeVisitor) + */ + protected Node leaveCall(Node parent, Node old, Node n, NodeVisitor v) throws SemanticException { + Node result = n; + + //Need check whether some constructs are concurrent + if(n instanceof ConstructorDecl){ + ConstructorDecl cDecl = (ConstructorDecl)n; + ConstructorDef cDef = cDecl.constructorDef(); + if(wts.isTargetProcedure(cDef)){ + throw new SemanticException("Work-Stealing Compiling doesn't support concurrent constructor: " + cDef, + cDecl.position()); + } + } + + if(n instanceof Closure){ + if(n instanceof PlacedClosure){ + //Future & AtExpr + checkRemoteActivityPlace((PlacedClosure)n); + } + else{ + Closure closure = (Closure)n; + ClosureDef cDef = closure.closureDef(); + if(wts.isTargetProcedure(cDef)){ + throw new SemanticException("Work-Stealing Compiling doesn't support concurrent closure: " + cDef, + closure.position()); + } + } + } + + if(n instanceof RemoteActivityInvocation){ + //Other RemoteActivityInvocation, such as async, AtStmt + checkRemoteActivityPlace((RemoteActivityInvocation)n); + } + + if(n instanceof AtEach){ + throw new SemanticException("Work-Stealing Compiling only supports single place applications: " + n, + n.position()); + } + + if(n instanceof Offer){ + throw new SemanticException("Work-Stealing Compiling doesn't support collecting finish: " + n, + n.position()); + } + + if (n instanceof MethodDecl) { + MethodDecl mDecl = (MethodDecl)n; + MethodDef mDef = mDecl.methodDef(); + + if(wts.isTargetProcedure(mDef)){ + if(debugLevel > 3){ + System.out.println("[WS_INFO] Start transforming target method: " + mDef.name()); + } + + if(mDef.name().toString().equals("main")){ + WSMainMethodClassGen mainClassGen = (WSMainMethodClassGen) wts.getInnerClass(mDef); + mainClassGen.setMethodDecl(mDecl); + wts.setMainMethodClass(mainClassGen); + mainClassGen.genClass(getX10Context()); + + n = mainClassGen.getNewMainMethod(); + if(debugLevel > 3){ + System.out.println(mainClassGen.getFrameStructureDesc(4)); + } + } + else{ + WSMethodFrameClassGen methodGen = wts.getInnerClass(mDef); + methodGen.setMethodDecl(mDecl); + methodGen.genClass(getX10Context()); + n = null; + if(debugLevel > 3){ + System.out.println(methodGen.getFrameStructureDesc(4)); + } + } + } + + return n; + + } + + if (n instanceof X10ClassDecl) { + X10ClassDecl cDecl = (X10ClassDecl)n; + + List<X10ClassDecl> innerClasses = wts.getInnerClasses(cDecl.classDef()); + if (innerClasses.isEmpty()) { + return result; //No WS transformation + } + else{ + if(debugLevel > 3){ + System.out.println(); + System.out.println("[WS_INFO] Add new methods/inner-classes to class:" + n); + } + cDecl = synth.addInnerClasses(cDecl, innerClasses); + cDecl = synth.addMethods(cDecl, wts.getGeneratedMethods(cDecl.classDef())); + return cDecl; + } + } + return result; + } + + /** + * If the rActivity's place is not here, just throw error. + * @param rActivity + * @throws SemanticException + */ + protected void checkRemoteActivityPlace(RemoteActivityInvocation rActivity) throws SemanticException{ + if(!(rActivity.place() instanceof Here)){ + throw new SemanticException("Work-Stealing Compiling only supports single place applications: " + rActivity, + ((Node)rActivity).position()); + } + } + + + +// +// protected void rewriteParalleMethodToInnerClasses(MethodDecl mDecl) throws SemanticException{ +// +// //Now start to transform the parallel method to inner classes. +// //One parallel method will be transformed into several inner classes +// //1. method body: <methodName> +// //2. finish statement: <methodName>_finish +// //3. finish body: <methodName>_finish_body +// //4. async: <methodName>_async +// // For main method, it should be more complex. TODO: Main method's classes +// // +// //The process is +// //genMethodBodyClass() +// // |-> generate the fast/slow path methods simultaneously +// // | +-> genFinishStmtClass +// // | |-> generate the fast/slow path methods simultaneously +// // | +-> genFinishBodyClass +// // | ... +// // |-> generate the back path +// // +-> ... +// // +// // during the call chain, different inner classes will be added into innerClasses +// +// WSMethodFrameClassGen methodClassGen = new WSMethodFrameClassGen(xnf, getX10Context(), +// mDecl, wts); +// +// wts.putInnerClass(mDecl.methodDef(), methodClassGen); +// methodClassGen.genClass(); +// } +// + X10Context getX10Context(){ + return (X10Context)context; + } + +} + + Property changes on: trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java =================================================================== --- trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java (rev 0) +++ trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java 2010-09-30 19:06:14 UTC (rev 16817) @@ -0,0 +1,350 @@ +/* + * 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.ws; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; + +import polyglot.ast.ClassDecl; +import polyglot.ast.Node; +import polyglot.ast.SourceFile; +import polyglot.ast.TopLevelDecl; +import polyglot.frontend.Job; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.MethodDef; +import polyglot.types.ProcedureDef; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.util.Pair; +import x10.ast.X10ClassDecl; +import x10.ast.X10MethodDecl; +import x10.ast.X10NodeFactory; +import x10.compiler.ws.codegen.AbstractWSClassGen; +import x10.compiler.ws.codegen.WSMainMethodClassGen; +import x10.compiler.ws.codegen.WSMethodFrameClassGen; +import x10.compiler.ws.util.WSCallGraph; +import x10.compiler.ws.util.WSCallGraphNode; +import x10.types.X10Context; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; +import x10.util.synthesizer.MethodSynth; + +/** + * Record the WS transformation intermediate results and context. + * + * The WSState is globally exisits, however, some types need be refreshed + * each time a WSCodeGenerator begins + * + * Globally table: target methodDef -> Fast/Slow MethodSynth + * used to identify whether one method is target or not, and used for other places to generate right call + * + * State Related: + * all types + * + * + * And provide interfaces for WS code gen to query a method is a target method or not + * + * Every target method and the corresponding inner class(es) will be stored here. + * In other procedures, it need query the map. + * If it is a target method, it need transform method call to + * (1) A new innerclass instance + * (2) invoke the fast method on the instance + * + * @author Haichuan + * + */ +public class WSTransformState { + + //------------Context sensitive + WSCodeGenerator codeVisitor; + //basic types + //Base types are context irrelevant + public Type intType; + public Type frameType; + public Type finishFrameType; + public ClassType rootFinishType; + public Type mainFrameType; + public Type regularFrameType; + public Type asyncFrameType; + public Type boxedBooleanType; + public Type workerType; + public Type stackAllocateType; //annotation type + public Type inlineType; //annotation type + public Type transientType; //annotation type + public Type headerType; //annotation type + public Type uninitializedType; //annotation type + public Type futureType; + //!Type is context relevant + public Type frameHereType; + public Type finishFrameHereType; + public Type mainFrameHereType; + public Type regularFrameHereType; + public Type asyncFrameHereType; + public Type boxedBooleanHereType; + public Type workerHereType; + public Boolean realloc; + + + //-----------Global exist: + //map from a target method to the inner class + HashMap<MethodDef, WSMethodFrameClassGen> methodToInnerClassTreeMap; + //Map from a target method to the fast and slow path wrapper method + HashMap<MethodDef, MethodSynth> methodToWSMethodMap; + //The procedure def that has no transformation support, just as book keeping + //And will be fixed soon; + HashSet<ProcedureDef> concurrentProcedureSet; + + //And the main method's class tree + WSMainMethodClassGen mainMethodClass; + MethodDef mainMethodDef; //if it is not null, main method is parallel method + + //A pool to record all as-is job for WS code gen + //used to build call graph + protected HashSet<WeakReference<Job>> wsJobSet; + protected boolean isCallGraphBuild; + + public WSTransformState(){ + wsJobSet = new HashSet<WeakReference<Job>>(); + methodToInnerClassTreeMap = new HashMap<MethodDef, WSMethodFrameClassGen>(); + methodToWSMethodMap = new HashMap<MethodDef, MethodSynth>(); + concurrentProcedureSet = new HashSet<ProcedureDef>(); + } + + + public void updateContextAndVisitor(WSCodeGenerator codeVisitor, X10Context xct, String theLanguage){ + this.codeVisitor = codeVisitor; + X10TypeSystem xts = (X10TypeSystem) xct.typeSystem(); + + //initial static type + //initial all types + intType = xts.Int(); + if (theLanguage.equals("c++")) { + frameType = xts.load("x10.compiler.ws.Frame"); + finishFrameType = xts.load("x10.compiler.ws.FinishFrame"); + rootFinishType = xts.load("x10.compiler.ws.RootFinish"); + mainFrameType = xts.load("x10.compiler.ws.MainFrame"); + regularFrameType = xts.load("x10.compiler.ws.RegularFrame"); + asyncFrameType = xts.load("x10.compiler.ws.AsyncFrame"); + boxedBooleanType = xts.load("x10.compiler.ws.BoxedBoolean"); + workerType = xts.load("x10.compiler.ws.Worker"); + realloc = true; + } else { + frameType = xts.load("x10.compiler.ws.java.Frame"); + finishFrameType = xts.load("x10.compiler.ws.java.FinishFrame"); + rootFinishType = xts.load("x10.compiler.ws.java.RootFinish"); + mainFrameType = xts.load("x10.compiler.ws.java.MainFrame"); + regularFrameType = xts.load("x10.compiler.ws.java.RegularFrame"); + asyncFrameType = xts.load("x10.compiler.ws.java.AsyncFrame"); + boxedBooleanType = xts.load("x10.compiler.ws.java.BoxedBoolean"); + workerType = xts.load("x10.compiler.ws.java.Worker"); + realloc = false; + } + stackAllocateType = xts.load("x10.compiler.StackAllocate"); + inlineType = xts.load("x10.compiler.InlineOnly"); + transientType = xts.load("x10.compiler.Ephemeral"); + headerType = xts.load("x10.compiler.Header"); + uninitializedType = xts.load("x10.compiler.Uninitialized"); + futureType = xts.load("x10.util.Future"); + + + //initial context sensitive type + frameHereType = PlaceChecker.AddIsHereClause(frameType, xct); + finishFrameHereType = PlaceChecker.AddIsHereClause(finishFrameType, xct); + mainFrameHereType = PlaceChecker.AddIsHereClause(mainFrameType, xct); + regularFrameHereType = PlaceChecker.AddIsHereClause(regularFrameType, xct); + asyncFrameHereType = PlaceChecker.AddIsHereClause(asyncFrameType, xct); + boxedBooleanHereType = PlaceChecker.AddIsHereClause(boxedBooleanType, xct); + workerHereType = PlaceChecker.AddIsHereClause(workerType, xct); + } + + + /** + * Add all ws job for build a CallGraph together + * @param job + */ + public void addWSJob(Job job){ + wsJobSet.add(new WeakReference<Job>(job)); + } + + protected boolean isCallGraphBuild() { + return isCallGraphBuild; + } + + public void buildCallGraph(Job job2, X10NodeFactory xnf, X10TypeSystem xts){ + if(isCallGraphBuild){ + //System.err.println("[WS_ERR]CallGraph has been build. Will not build again!"); + return; + } + + WSCallGraph callGraph = new WSCallGraph(); + + //start to iterate the ast in jobs and build all; + for(WeakReference<Job> jobRef : wsJobSet){ + Job job = jobRef.get(); + if(job == null){ + System.err.println("[WS_ERR] CallGraphBuilding: Find one job is empty!"); + continue; + } + Node node = job.ast(); + if(node != null && node instanceof SourceFile){ + for(TopLevelDecl tld : ((SourceFile)node).decls()){ + if(tld instanceof ClassDecl){ + boolean result = callGraph.addClass((ClassDecl) tld); + if(result){ + System.out.println("[WS_INFO] CallGraphBuilding: Add one classDecl to graph: " + tld.toString()); + } + + } + } + } + else{ + if(node == null){ + System.err.println("[WS_ERR] CallGraphBuilding: AST node == null for job: " + job.source().toString()); + continue; + } + if(! (node instanceof SourceFile)){ + System.err.println("[WS_ERR] CallGraphBuilding: AST node is not SourceFile for job: " + job.source().toString()); + continue; + } + } + } + + //now do search + + callGraph.doDFSMark(); + List<WSCallGraphNode> methods = callGraph.getAllParallelMethods(); + + System.out.println("[WS_INFO] Found Parallel Methods:"); + + + for(WSCallGraphNode node : methods){ + ProcedureDef md = node.getMethodDef(); + System.out.printf(" [%s] %s\n", node.isContainsConcurrent() ? "C" : "D", + md.toString()); + + for(WSCallGraphNode callerNode : node.getCallers()){ + ProcedureDef cmd = callerNode.getMethodDef(); + System.out.printf(" <-[%s] %s\n", callerNode.isContainsConcurrent() ? "C" : "D", + cmd.toString()); + } + + this.addMethodAsTargetMethod(job2, xnf, (X10Context)xts.emptyContext(), md); + + } + isCallGraphBuild = true; + } + + + public WSCodeGenerator getCodeVisitor() { + return codeVisitor; + } + + /** + * Query one method is a target method or not + * @param procedureDef the candidate method + * @return + */ + public boolean isTargetProcedure(ProcedureDef procedureDef) { + if(methodToInnerClassTreeMap.containsKey(procedureDef) + || mainMethodDef == procedureDef){ + return true; + } + else if(concurrentProcedureSet.contains(procedureDef)){ + return true; + } + else{ + return false; + } + } + + /** + * Add one method as a target method + * @param methodDef + */ + public void addMethodAsTargetMethod(Job job, X10NodeFactory xnf, X10Context xct, ProcedureDef procedureDef){ + + if(procedureDef instanceof MethodDef){ + MethodDef methodDef = (MethodDef)procedureDef; + + WSMethodFrameClassGen methodGen; + + if(mainMethodDef == null && methodDef.name().toString().equals("main")){ + mainMethodDef = methodDef; + methodGen = new WSMainMethodClassGen(job, xnf, xct, methodDef, this); + } + + //create class gen + else methodGen = new WSMethodFrameClassGen(job, xnf, xct, methodDef, this); + MethodSynth wrapperPair= methodGen.getWraperMethodSynths(); + methodToInnerClassTreeMap.put(methodDef, methodGen); + methodToWSMethodMap.put(methodDef, wrapperPair); + } + else{ + //concurrent but no transformation support part + concurrentProcedureSet.add(procedureDef); + } + + + } + + public List<X10ClassDecl> getInnerClasses(ClassDef cDef) throws SemanticException { + ArrayList<X10ClassDecl> cDecls = new ArrayList<X10ClassDecl>(); + + for(MethodDef mDef : methodToInnerClassTreeMap.keySet()){ + + ClassDef containerDef = ((ClassType) mDef.container().get()).def(); + if(containerDef == cDef){ //only add those methods here + AbstractWSClassGen innerClass = methodToInnerClassTreeMap.get(mDef); + AbstractWSClassGen[] innerClasses = innerClass.genAllOffString(); + for(int i = 0; i <innerClasses.length; i++){ + cDecls.add(innerClasses[i].getGenClassDecl()); + } + } + } + + return cDecls; + } + + /** + * @return newly generated methods from the WS code transformation + * @throws SemanticException + */ + public List<X10MethodDecl> getGeneratedMethods(ClassDef cDef) throws SemanticException { + List<X10MethodDecl> mDecls = new ArrayList<X10MethodDecl>(); + + for(MethodDef mDef : methodToWSMethodMap.keySet()){ + ClassDef containerDef = ((ClassType) mDef.container().get()).def(); + if(containerDef == cDef){ + MethodSynth pair = methodToWSMethodMap.get(mDef); + mDecls.add(pair.close()); + } + } + return mDecls; + } + + public void setMainMethodClass(WSMainMethodClassGen mainMethodClass) { + this.mainMethodClass = mainMethodClass; + } + + public WSMethodFrameClassGen getInnerClass(MethodDef methodDef) { + return methodToInnerClassTreeMap.get(methodDef); + } + + public MethodSynth getFastAndSlowMethod(MethodDef methodDef) { + return methodToWSMethodMap.get(methodDef); + } +} Property changes on: trunk/x10.compiler/src/x10/compiler/ws/WSTransformState.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java =================================================================== --- trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java (rev 0) +++ trunk/x10.compiler/src/x10/compiler/ws/codegen/AbstractWSClassGen.java 2010-09-30 19:06:14 UTC (rev 16817) @@ -0,0 +1,1460 @@ +package x10.compiler.ws.codegen; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import polyglot.ast.Assign; +import polyglot.ast.Binary; +import polyglot.ast.Call; +import polyglot.ast.ClassBody; +import polyglot.ast.Do; +import polyglot.ast.Eval; +import polyglot.ast.Expr; +import polyglot.ast.For; +import polyglot.ast.Local; +import polyglot.ast.LocalAssign; +import polyglot.ast.LocalDecl; +import polyglot.ast.Loop; +import polyglot.ast.Node; +import polyglot.ast.Receiver; +import polyglot.ast.Return; +import polyglot.ast.Stmt; +import polyglot.ast.Switch; +import polyglot.ast.Term; +import polyglot.ast.TypeNode; +import polyglot.ast.While; +import polyglot.frontend.Job; +import polyglot.types.ClassDef; +import polyglot.types.ClassType; +import polyglot.types.FieldDef; +import polyglot.types.Flags; +import polyglot.types.MethodDef; +import polyglot.types.MethodInstance; +import polyglot.types.Name; +import polyglot.types.QName; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.Types; +import polyglot.util.Pair; +import polyglot.util.Position; +import polyglot.visit.NodeVisitor; +import x10.ast.AnnotationNode; +import x10.ast.Closure; +import x10.ast.Finish; +import x10.ast.When; +import x10.ast.X10Call; +import x10.ast.X10ClassDecl; +import x10.ast.X10NodeFactory; +import x10.extension.X10Ext_c; +import x10.compiler.ws.WSTransformState; +import x10.compiler.ws.util.AdvLocalAccessToFieldAccessReplacer; +import x10.compiler.ws.util.CodePatternDetector; +import x10.compiler.ws.util.ILocalToFieldContainerMap; +import x10.compiler.ws.util.ReferenceContainer; +import x10.compiler.ws.util.TransCodes; +import x10.compiler.ws.util.WSCodeGenUtility; +import x10.types.X10ClassDef; +import x10.types.X10ClassType; +import x10.types.X10Context; +import x10.types.X10LocalDef; +import x10.types.X10MethodDef; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; +import x10.util.Synthesizer; +import x10.util.synthesizer.ClassSynth; +import x10.util.synthesizer.CodeBlockSynth; +import x10.util.synthesizer.ConstructorSynth; +import x10.util.synthesizer.FieldSynth; +import x10.util.synthesizer.InstanceCallSynth; +import x10.util.synthesizer.MethodSynth; +import x10.util.synthesizer.NewInstanceSynth; +import x10.util.synthesizer.NewLocalVarSynth; +import x10.util.synthesizer.SuperCallSynth; +import x10.visit.ExpressionFlattener; + +/** + * @author Haichuan + * + * The base of different kinds of WS class generator + * + * Because one method will be divided into different segments (control flows) + * and each segment will be transformed into one inner class, + * these inner classes are chained together in a tree structure. + * + * In order to represent the tree structure, the AbstractWSClassGen + * is a tree node, too. It has parent and child + * + */ +public abstract class AbstractWSClassGen implements ILocalToFieldContainerMap{ + final Job job; + + //debug flag + static final public int debugLevel = 4; + + //Common static variable + static protected Position compilerPos = Position.COMPILER_GENERATED; + static protected Name FAST = Name.make("fast"); + static protected Name PUSH = Name.make("push"); + static protected Name POLL = Name.make("poll"); + static protected Name RESUME = Name.make("resume"); + static protected Name BACK = Name.make("back"); + static protected Name MOVE = Name.make("move"); + static protected Name WORKER = Name.make("worker"); + static protected Name FRAME = Name.make("frame"); + static protected Name PC = Name.make("_pc"); + static protected Name FF = Name.make("ff"); + static protected Name UP = Name.make("up"); + static protected Name ASYNCS = Name.make("asyncs"); + static protected Name REDO = Name.make("redo"); + + + + //Fields for class code gen + protected WSTransformState wts; + protected X10TypeSystem xts; + protected X10NodeFactory xnf; + protected X10Context xct; + protected Synthesizer synth; //stateless synthesizer + protected ClassSynth classSynth; //stateful synthesizer for class gen + protected MethodSynth fastMSynth; + protected MethodSynth resumeMSynth; + protected MethodSynth backMSynth; + + protected CodePatternDetector patternDetctor; + + //Fields to store the frame's info + + protected HashSet<Name> fieldNames; //store all the fields' name in current frame + protected String className; //used for child to query, and form child's name + + //Fields to maintain the tree + protected int frameDepth; //the depth to parent; + final private AbstractWSClassGen parent; + private List<AbstractWSClassGen> children; //lazy initialization + + /** + * Return direct children + * @return + */ + public AbstractWSClassGen[] getChildren() { + if(children == null){ + return new AbstractWSClassGen[0]; + } + else{ + return children.toArray(new AbstractWSClassGen[children.size()]); + } + } + + /** + * Used to pretty print + * @param indent the indent before the output + * @return + */ + public String getFrameStructureDesc(int indent){ + StringBuffer sb = new StringBuffer(); + for(int i = 0; i < indent; i++){ + sb.append(' '); + } + + sb.append(this.className); + if(this instanceof WSAsyncClassGen){ + WSAsyncClassGen aFrame = (WSAsyncClassGen)this; + + sb.append(" (k = ").append(aFrame.parentK.className).append(')'); + } + sb.append(System.getProperty("line.separator")); + + AbstractWSClassGen[] children = getChildren(); + for(AbstractWSClassGen child : children){ + sb.append(child.getFrameStructureDesc(indent + 2)); + } + return sb.toString(); + } + + + /** + * Return all the inner classes rooted by the current class as one array + * @return + */ + public AbstractWSClassGen[] genAllOffString(){ + ArrayList<AbstractWSClassGen> classes = new ArrayList<AbstractWSClassGen>(); + recursiveAddClasses(classes, this); + return classes.toArray(new AbstractWSClassGen[classes.size()]); + } + + + public int getFrameDepth() { + return frameDepth; + } + + private void recursiveAddClasses(ArrayList<AbstractWSClassGen> classes, AbstractWSClassGen parent){ + // This method is only used by public AbstractWSClassGen[] genAllOffString() + classes.add(parent); + AbstractWSClassGen[] children = parent.getChildren(); + for(AbstractWSClassGen child : children){ + recursiveAddClasses(classes, child); + } + } + + /** + * And one inner class into the current class to build the frame tree + * @param child + * @return the child's sequence id used form the child frame's name + */ + public int addChild(AbstractWSClassGen child) { + if(children == null){ + children = new ArrayList<AbstractWSClassGen>(); + } + int num = children.size(); + children.add(child); + return num; //return the number of itself + } + + + int childrenNameCount; //start from 0. not the same as children's number + //since finish frame has more children classFrame + /** + * Query the child's sequence id in parent + * @param child + * @return the id num; + */ + public synchronized int assignChildId() { + int retId = childrenNameCount; + childrenNameCount ++; + return retId; + } + + public AbstractWSClassGen getParent() { + return parent; + } + + public X10ClassDef getClassDef(){ + return classSynth.getClassDef(); + } + + //TODO: interfaces to query one specific parent + //From the list, we could query all added inner classes + + + public AbstractWSClassGen(Job job, X10NodeFactory xnf, X10Context xct, + WSTransformState wsTransformState, AbstractWSClassGen parent) { + super(); + this.job = job; + this.xnf = xnf; + this.parent = parent; + this.wts = wsTransformState; + if(parent != null){ + parent.addChild(this); //add it to parent + } + setContext(xct); + + //initial other fields + fieldNames = new HashSet<Name>(); //used to store all other fields' names + } + + /** + * Extract it as a saperate method because WSMethodFrameClassGen was created before context is available + * @param xct + */ + public void setContext(X10Context xct){ + this.xct = xct; + this.xts = (X10TypeSystem) xct.typeSystem(); //type system from from context + synth = new Synthesizer(xnf, xts); + patternDetctor = new CodePatternDetector(xnf, xct, wts); + } + + + public String getClassName() { + return className; + } + + public X10NodeFactory getX10NodeFactory() { + return xnf; + } + + public X10Context getX10Context() { + return xct; + } + + public WSTransformState getWSTransformState() { + return wts; + } + + /** + * Use the generator to generate all kinds of classes. + * Need add the new inner class to its parent frame class + * @throws SemanticException + */ + abstract protected void genClass() throws SemanticException; + + /** + * Trigger class generation, and close the class synth + * @return the generated class decl + * @throws SemanticException + */ + public X10ClassDecl getGenClassDecl() throws SemanticException{ + + return classSynth.close(); + } + + public X10ClassDef getGenClassDef(){ + return classSynth.getClassDef(); + } + + public X10ClassType getClassType(){ + return (X10ClassType) classSynth.getClassDef().asType(); + } + + public Expr getThisRef(){ + return synth.thisRef(getClassType(), compilerPos); + } + + /** + * Create "@Uninitialized var pc:Int;" + */ + protected void addPCFieldToClass(){ + //async frame need a pc + //@Uninitialized var pc:Int; + FieldSynth pcFieldSynth = classSynth.createField(compilerPos, PC.toString(), xts.Int()); + pcFieldSynth.addAnnotation(genUninitializedAnnotation()); + } + + /** + * Prepare all methods synthesizers, should be called in different children class's constructors + */ + protected void prepareMethodSynths(){ + fastMSynth = classSynth.createMethod(compilerPos, FAST.toString()); + fastMSynth.setFlag(Flags.PUBLIC); + if (!xts.isSubtype(getClassType(), wts.mainFrameType)) + fastMSynth.addAnnotation(genInlineAnnotation()); + fastMSynth.addFormal(compilerPos, Flags.FINAL, wts.workerHereType, WORKER.toString()); + + resumeMSynth = classSynth.createMethod(compilerPos, RESUME.toString()); + resumeMSynth.setFlag(Flags.PUBLIC); + resumeMSynth.addFormal(compilerPos, Flags.FINAL, wts.workerHereType, WORKER.toString()); + + backMSynth = classSynth.createMethod(compilerPos, BACK.toString()); + backMSynth.setFlag(Flags.PUBLIC); + backMSynth.addFormal(compilerPos, Flags.FINAL, wts.workerHereType, WORKER.toString()); + backMSynth.addFormal(compilerPos, Flags.FINAL, wts.frameHereType, FRAME.toString()); + } + + + /** + * Return statement throw new RuntimeException(msg + appendInfo); + * @param msg + * @param appendInfo + * @return + * @throws SemanticException + */ + protected Stmt genThrowRuntimeExceptionStmt(String msg, Expr appendInfo) throws SemanticException { + NewInstanceSynth nis = new NewInstanceSynth(xnf, xct, compilerPos, (ClassType) xts.RuntimeException()); + + Expr msgRef = synth.stringValueExpr(msg, compilerPos); + + Expr exceptionMsgRef = xnf.Binary(compilerPos, msgRef, Binary.ADD, appendInfo).type(xts.String()); + nis.addArgument(xts.String(), exceptionMsgRef); + + return xnf.Throw(compilerPos, nis.genExpr()); + } + + /** + * It will decide the right child frame's class gen, and return the right type to caller + * childSuperType could be only: asyncFrame, finishFrame, regularFrame + * asyncFrame: WSAsyncClassGen + * finishFrame: WSFinishStmtClassGen + * regularFrame:WSRegularFrameClassGen or ForLoopClassGen or DoLoopClassGen or SwitchClassGen + * @param childSuperType: could be only three: async, finish, regular + * @param stmt + * @param namePrefix: only useful for regularFrame type + * @return + * @throws SemanticException + */ + protected AbstractWSClassGen genChildFrame(Type childSuperType, Stmt stmt, String namePrefix) throws SemanticException{ + + AbstractWSClassGen childClassGen = null; + + if(childSuperType == wts.finishFrameType){ + //stmt is Finish + childClassGen = new WSFinishStmtClassGen(this, (Finish)stmt); + } + else{ + //first unroll to one stmt; //remove additional no use stmt + stmt = WSCodeGenUtility.unrollToOneStmt(stmt); + if(stmt instanceof For){ + childClassGen = new WSForLoopClassGen(this, (For)stmt); + } + else if(stmt instanceof While || stmt instanceof Do){ + childClassGen = new WSWhileDoLoopClassGen(this, (Loop)stmt); + } + else if(stmt instanceof Switch){ + childClassGen = new WSSwitchClassGen(this, (Switch)stmt); + } + else if(stmt instanceof When){ + childClassGen = new WSWhenFrameClassGen(this, (When)stmt); + } + else{ + //stmt.prettyPrint(System.out); + //TODO: optimization point: if from finish frame, the stmt is a loop + //could unloop it and call for frame directly + //assert(stmt instanceof Block); //definetly need to be block + childClassGen = new WSRegularFrameClassGen(this, stmt, namePrefix); + } + } + childClassGen.genClass(); // + return childClassGen; + } + + + protected AbstractWSClassGen genAsyncFrame(Type childSuperType, Stmt stmt, String namePrefix) throws SemanticException{ + + AbstractWSClassGen childClassGen = null; + + //stmt is async's body + childClassGen = new WSAsyncClassGen(this, stmt); + childClassGen.genClass(); // + return childClassGen; + } + + /** + * Generate this type of codes + * @StackAllocate val _m_finish_body = @StackAllocate new _finish_body(upcast[_finish,Frame](this), upcast[_finish,FinishFrame](this)); + * _m_finish_body.fast(worker); + * @return transcoces, first: fast; second resume(); + * @throws SemanticException + */ + protected TransCodes genInvocateFrameStmts(int pc, AbstractWSClassGen newClassGen) throws SemanticException{ + TransCodes transCodes = new TransCodes(pc); + + ClassType newClassType = newClassGen.getClassType(); + //pc = x; + Expr pcAssgn = synth.makeFieldAssign(compilerPos, getThisRef(), PC, + synth.intValueExpr(pc, compilerPos), xct).type(xts.Int()); + transCodes.addFirst(xnf.Eval(compilerPos, pcAssgn)); + transCodes.addSecond(xnf.Eval(compilerPos, pcAssgn)); + + + //if the new frame is an async frame, push() instructions should be inserted here + if(xts.isSubtype(newClassType, wts.asyncFrameType)){ + Expr fastWorkerRef = fastMSynth.getMethodBodySynth(compilerPos).getLocal(WORKER.toString()); + transCodes.addFirst(genContinuationPush(fastWorkerRef)); + + Expr resumeWorkerRef = resumeMSynth.getMethodBodySynth(compilerPos).getLocal(WORKER.toString()); + transCodes.addSecond(genContinuationPush(resumeWorkerRef)); + } + + + //create the instance + NewInstanceSynth niSynth = new NewInstanceSynth(xnf, xct, compilerPos, newClassType); + + //first parameter in constructor, parent + if(xts.isSubtype(newClassType, wts.asyncFrameType)){ + Expr ffRef = synth.makeFieldAccess(compilerPos, getThisRef(), FF, xct); + Expr parentRef = genUpcastCall(getClassType(), wts.frameType, ffRef); + niSynth.addArgument(wts.frameHereType, parentRef); + } + else{ //upcast[_selfType,Frame](this); + Expr parentRef = genUpcastCall(getClassType(), wts.frameType, getThisRef()); + niSynth.addArgument(wts.frameHereType, parentRef); + } + + //process the 2nd parameter, ff. + if(!xts.isSubtype(newClassType, wts.finishFrameType) && !xts.isSubtype(newClassType, wts.asyncFrameType)){ + //if target is not finish frame, need add ff as reference + Expr ffRef; + if(xts.isSubtype(getClassType(), wts.finishFrameType)){ + //if itself is ff type, upcast it self + ffRef = genUpcastCall(getClassType(), wts.finishFrameType, getThisRef()); + } + else if(xts.isSubtype(getClassType(), wts.asyncFrameType)){ + //if itself is ff type, upcast it self + Expr upRef = synth.makeFieldAccess(compilerPos, getThisRef(), UP, xct); + ffRef = genCastCall(wts.frameType, wts.finishFrameType, upRef); + } else { + //non finish frame will have ff field as ff + ffRef = synth.makeFieldAccess(compilerPos, getThisRef(), FF, xct); + } + niSynth.addArgument(wts.finishFrameHereType, ffRef); + } + + //Finally, if the newClassType is an async frame, may consider the adding formal + if(xts.isSubtype(newClassType, wts.asyncFrameType)){ + WSAsyncClassGen asyncGen = (WSAsyncClassGen)newClassGen; + //need access each formal, and add them into the parameters + for(Pair<Name, Type> formal : asyncGen.formals){ + //make an access to the value; + Expr fieldContainerRef = this.getFieldContainerRef(formal.fst(), formal.snd()); + Expr fieldRef = synth.makeFieldAccess(compilerPos, fieldContainerRef, formal.fst(), xct).type(formal.snd()); + niSynth.addArgument(formal.snd(), fieldRef); + } + } + + niSynth.addAnnotation(genStackAllocateAnnotation()); + NewLocalVarSynth localSynth = new NewLocalVarSynth(xnf, xct, compilerPos, Flags.FINAL, niSynth.genExpr()); + localSynth.addAnnotation(genStackAllocateAnnotation()); + transCodes.addFirst(localSynth.genStmt()); + transCodes.addSecond(localSynth.genStmt()); + + //now the instance's fast/slow method call + Expr localRef = localSynth.getLocal(); // point to this inner class's instance + + { //fast + Expr fastWorkerRef = fastMSynth.getMethodBodySynth(compilerPos).getLocal(WORKER.toString()); + InstanceCallSynth callSynth = new InstanceCallSynth(xnf, xct, compilerPos, localRef, FAST.toString()); + callSynth.addArgument(wts.workerHereType, fastWorkerRef); + transCodes.addFirst(callSynth.genStmt()); + } + { //resume + Expr resumeWorkerRef = resumeMSynth.getMethodBodySynth(compilerPos).getLocal(WORKER.toString()); + InstanceCallSynth callSynth = new InstanceCallSynth(xnf, xct, compilerPos, localRef, FAST.toString()); + callSynth.addArgument(wts.workerHereType, resumeWorkerRef); + transCodes.addSecond(callSynth.genStmt()); + } + return transCodes; + } + + /** + * Generate upcast[_finish_body,Continuation](this).push(worker); + * The worker ref is different for fast/resume path + * @param workerRef + * @return + * @throws SemanticException + */ + protected Stmt genContinuationPush(Expr workerRef) throws SemanticException{ + + // push(worker) + Expr castThisRef = genUpcastCall(getClassType(), wts.regularFrameType, getThisRef()); + + InstanceCallSynth icSynth = new InstanceCallSynth(xnf, xct, compilerPos, castThisRef, PUSH.toString()); + // continuationFrame + icSynth.addArgument(wts.workerHereType, workerRef); + return icSynth.genStmt(); + } + + + /** + * Normal codes, no concurrent method/construct + * Just replace local refs as field access + */ + protected TransCodes transNormalStmt(Stmt s, int pcValue, Set<Name> declaredLocals) throws SemanticException { + assert(!WSCodeGenUtility.isComplexCodeNode(s, wts)); + + TransCodes transCodes = new TransCodes(pcValue); + s = (Stmt) this.replaceLocalVarRefWithFieldAccess(s, declaredLocals); + + //need process the return's issue; + TransReturnVisitor fastRV = new TransReturnVisitor(true); + transCodes.addFirst((Stmt)s.visit(fastRV)); + TransReturnVisitor resumeRV = new TransReturnVisitor(false); + transCodes.addSecond((Stmt)s.visit(resumeRV)); + return transCodes; + } + + class TransReturnVisitor extends NodeVisitor{ + private boolean fastPath; //fast or resume path + private int noTransformDepth; //not transform "return" in Closure or anonymous class body + TransReturnVisitor(boolean fastPath){ + this.fastPath = fastPath; + } + + @Override + public NodeVisitor enter(Node n) { + if(n instanceof Closure + || n instanceof ClassBody){ + noTransformDepth++; + } + return super.enter(n); + } + + public Node leave(Node old, Node n, NodeVisitor v) { + + if(n instanceof Closure + || n instanceof ClassBody){ + noTransformDepth--; + return n; + } + + if(n instanceof Return && noTransformDepth == 0){ //return not in closure + Return r = (Return)n; + try { + if(AbstractWSClassGen.this instanceof WSMethodFrameClassGen){ + if(fastPath){ //directly return, no others + return n; + } + else{ //slow path: result = expr(); return; + List<Stmt> stmts = new ArrayList<Stmt>(); + if (r.expr() != null && r.expr().type() != xts.Void()) { + WSMethodFrameClassGen methodFrameGen = (WSMethodFrameClassGen)AbstractWSClassGen.this; + + Expr returnValueAssign; + returnValueAssign = synth.makeFieldAssign(r.position(), + getThisRef(), + methodFrameGen.getReturnFieldName(), + r.expr(), xct); + stmts.add(xnf.Eval(r.position(), returnValueAssign)); + + } + stmts.add(xnf.Return(r.position())); //return + return xnf.StmtSeq(r.position(), stmts); + } + } + else{ //non method frame + List<Stmt> stmts = new ArrayList<Stmt>(); + Name resultName = queryMethodResultFieldName(); + Name returnFlagName = queryMethodReturnFlagName(); + Expr methodFrameRef = getFieldContainerRef(returnFlagName, xts.Boolean()); + + // parent.returnFlag = true; + Expr returnFlagAssign = synth.makeFieldAssign(r.position(), methodFrameRef, + returnFlagName, + synth.booleanValueExpr(true, r.position()), xct); + stmts.add(xnf.Eval(compilerPos, returnFlagAssign)); + // parent.result = expr(); + if (r.expr() != null && r.expr().type() != xts.Void()) { + Expr returnValueAssign = synth.makeFieldAssign(r.position(), + methodFrameRef, + resultName, + r.expr(), xct); + stmts.add(xnf.Eval(compilerPos, returnValueAssign)); + } + stmts.add(xnf.Return(r.position())); //return + return xnf.StmtSeq(r.position(), stmts); + } + } catch (SemanticException e) { + System.err.println("[WS_ERR]Return transformation error:" + n.toString()); + e.printStackTrace(); + return n; + } + } + else{ //non return others + return n; + } + } + } + + /** + * Used to query the method's return field from any frames + * + * @return + */ + protected Name queryMethodResultFieldName() { + // start from this + AbstractWSClassGen classGen = this; + while (classGen != null) { + if (classGen instanceof WSMethodFrameClassGen) { + return ((WSMethodFrameClassGen) classGen).getReturnFieldName(); + } + classGen = (AbstractWSClassGen) classGen.getParent(); + } + return null; // Not found, should throw exception + } + + /** + * Used to query the method's return flag from any frames + * + * @return + */ + protected Name queryMethodReturnFlagName() { + // start from this + AbstractWSClassGen classGen = this; + while (classGen != null) { + if (classGen instanceof WSMethodFrameClassGen) { + return ((WSMethodFrameClassGen) classGen).getReturnFlagName(); + } + classGen = (AbstractWSClassGen) classGen.getParent(); + } + return null; // Not found, should throw exception + } + + /** + * Change local declare with initializer e.g. "var n:Int = 10" as only local initialize "n = 10" + * And create an inner class fields "n"; + * Here, the assign right local access will is still local access, not replaced by field access + * And then the stmt need to be processed by other transformations, + * e.g. replace local access with field access. + * @param ld + * @return null if just a decl or stmt of the intializor + */ + protected Stmt transLocalDecl(LocalDecl ld){ + //Create fields + if (((X10LocalDef) ld.localDef()).annotationsMatching(wts.transientType).isEmpty()) { + Name fieldName = ld.name().id(); + FieldSynth localFieldSynth = classSynth.createField(ld.position(), fieldName.toString(), ld.type().type()); + localFieldSynth.addAnnotation(genUninitializedAnnotation()); + fieldNames.add(fieldName); //put it into current frame's fields name lists + + //and check the intializor + Expr localInit = ld.init(); + if(localInit == null){ + return null; //just a pure declare, no initialization; + } + + //now create a local ref to this localDecl + Local local = xnf.Local(ld.position(), xnf.Id(ld.position(), ld.name().id())).localInstance(ld.localDef().asInstance()); + Expr assign = xnf.LocalAssign(localInit.position(), local, Assign.ASSIGN, localInit).type(localInit.type()); + return xnf.Eval(ld.position(), assign); + } else { + return ld; + } + } + + /** + * This one is used for async frames + * Transform a call to fast/resume/back path + * This callee is a concurrent method + */ + protected Tra... [truncated message content] |
From: <ma...@us...> - 2010-10-01 08:24:23
|
Revision: 16839 http://x10.svn.sourceforge.net/x10/?rev=16839&view=rev Author: makinoy Date: 2010-10-01 08:24:16 +0000 (Fri, 01 Oct 2010) Log Message: ----------- Added the mechanism renaming method names to support generic overloading in the Java beck-end. And fix a regression of XTENLANG-655 Modified Paths: -------------- trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java trunk/x10.runtime/src-java/x10/runtime/impl/java/Runtime.java trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 Modified: trunk/x10.compiler/src/x10/emitter/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-10-01 06:06:36 UTC (rev 16838) +++ trunk/x10.compiler/src/x10/emitter/Emitter.java 2010-10-01 08:24:16 UTC (rev 16839) @@ -1057,7 +1057,7 @@ } w.allowBreak(2, 2, " ", 1); if (X10PrettyPrinterVisitor.isGenericOverloading) { - w.write(mangleMethodName(n.methodDef())); + w.write(mangleMethodName(n.methodDef(), c.currentClass().flags().isInterface() ? false : true)); } else { tr.print(n, n.name(), w); @@ -1211,7 +1211,7 @@ w.write(" extends "); for (int i = 0; i < sups.size(); ++i) { if (i != 0) w.write(" & "); - printType(sups.get(i), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS | X10PrettyPrinterVisitor.NO_VARIANCE); + printType(sups.get(i), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS | X10PrettyPrinterVisitor.NO_VARIANCE | X10PrettyPrinterVisitor.BOX_PRIMITIVES); } } sep = ", "; @@ -1219,32 +1219,56 @@ w.end(); w.write(">"); } - - public static String mangleMethodName(MethodDef md) { + + public static String mangleMethodName(MethodDef md, boolean printIncludingGeneric) { StringBuilder sb = new StringBuilder(mangleToJava(md.name())); List<Ref<? extends Type>> formalTypes = md.formalTypes(); for (int i = 0; i < formalTypes.size(); ++i) { - Type t = X10TypeMixin.baseType(formalTypes.get(i).get()); - if (!containsTypeParam(t) && t instanceof X10ClassType) { - X10ClassType x10t = (X10ClassType) t; - if (x10t.typeArguments().size() > 0) { - sb.append("_"); - sb.append(i); - sb.append("_"); - List<Type> ts = x10t.typeArguments(); - String delim = null; - for (Type t1 : ts) { - if (delim != null) sb.append(delim); - delim = "_"; - appendParameterizedType(sb, X10TypeMixin.baseType(t1)); - } + Type type = formalTypes.get(i).get(); + mangleMethodName((ClassType) md.container().get(), sb, i, type, printIncludingGeneric); + } + return sb.toString(); + } + + public static String mangleMethodName(ClassType ct, MethodInstance mi, boolean printIncludingGeneric) { + StringBuilder sb = new StringBuilder(mangleToJava(mi.name())); + List<Type> formalTypes = mi.formalTypes(); + for (int i = 0; i < formalTypes.size(); ++i) { + Type type = formalTypes.get(i); + mangleMethodName(ct, sb, i, type, printIncludingGeneric); + } + return sb.toString(); + } + + public static void mangleMethodName(ClassType ct, StringBuilder sb, int i, Type type, boolean printIncludingGeneric) { + Type t = X10TypeMixin.baseType(type); + if (t instanceof X10ClassType && (printIncludingGeneric || (!printIncludingGeneric && !containsTypeParam(t)))) { + X10ClassType x10t = (X10ClassType) t; + if (x10t.typeArguments().size() > 0) { + sb.append("_"); + sb.append(i); + sb.append("_"); + List<Type> ts = x10t.typeArguments(); + String delim = null; + for (Type t1 : ts) { + if (delim != null) sb.append(delim); + delim = "_"; + appendParameterizedType(ct, sb, X10TypeMixin.baseType(t1)); } } } - return sb.toString(); + else if (printIncludingGeneric && t instanceof ParameterType) { + sb.append("_"); + sb.append(i); + sb.append("_"); + sb.append("$$"); + sb.append(ct.fullName().toString().replace(".", "$")); + sb.append("_"); + sb.append(((ParameterType) t).name().toString()); + } } - - private static void appendParameterizedType(StringBuilder sb, Type t) { + + private static void appendParameterizedType(ClassType ct, StringBuilder sb, Type t) { sb.append("$_"); if (t instanceof X10ClassType) { X10ClassType x10t = (X10ClassType) t; @@ -1252,10 +1276,15 @@ if (x10t.typeArguments().size() > 0) { List<Type> ts = x10t.typeArguments(); for (Type t1 : ts) { - appendParameterizedType(sb, X10TypeMixin.baseType(t1)); + appendParameterizedType(ct, sb, X10TypeMixin.baseType(t1)); } } } + else if (t instanceof ParameterType) { + sb.append(ct.fullName().toString().replace(".", "$")); + sb.append("_"); + sb.append(((ParameterType) t).name().toString()); + } else { sb.append(t.toString().replace(".", "$")); } @@ -1291,20 +1320,24 @@ methods = getInstantiatedMethods(ct, md.asInstance()); for (MethodInstance mi : methods) { - printBridgeMethod(md.asInstance(), mi.def()); + printBridgeMethod(ct, md.asInstance(), mi.def()); } } List<MethodInstance> inheriteds = new ArrayList<MethodInstance>(); - getInheritedMethods(ct, inheriteds); + List<MethodInstance> overrides = new ArrayList<MethodInstance>(); + getInheritedMethods(ct, inheriteds, overrides); for (MethodInstance mi : inheriteds) { if (isInstantiate(mi.def().returnType().get(), mi.returnType())) { - printInheritedMethodBridge(mi); - break; + printInheritedMethodBridge(ct, mi); + continue; } for (int i = 0; i < mi.formalTypes().size(); ++ i) { - if (isPrimitive(mi.formalTypes().get(i)) && isInstantiate(mi.def().formalTypes().get(i).get(), mi.formalTypes().get(i))) { - printInheritedMethodBridge(mi); + if ( + isPrimitive(mi.formalTypes().get(i)) && + isInstantiate(mi.def().formalTypes().get(i).get(), mi.formalTypes().get(i)) + ) { + printInheritedMethodBridge(ct, mi); break; } } @@ -1312,109 +1345,173 @@ List<Type> interfaces = ct.interfaces(); getImplMethods(mi, implMethods, interfaces); for (MethodInstance mi2 : implMethods) { - printBridgeMethod(mi, mi2.def()); - } + printBridgeMethod(ct, mi, mi2.def()); + } } } private void getImplMethods(MethodInstance mi, List<MethodInstance> implMethods, List<Type> interfaces) { - for (Type type : interfaces) { - if (type instanceof X10ClassType) { - List<MethodInstance> imis = ((X10ClassType) type).methods(); - for (MethodInstance imi : imis) { - if (!(imi.name().equals(mi.name()) && imi.formalTypes().size() == mi.formalTypes().size())) continue; - if (isContainInstantiateSamePlace(implMethods, imi)) continue; - Type returnType = mi.returnType(); - if ( - returnType.typeEquals(imi.returnType() , tr.context()) - && X10TypeMixin.baseType(imi.def().returnType().get()) instanceof ParameterType - && !(X10TypeMixin.baseType(returnType) instanceof ParameterType) - ) { - implMethods.add(imi); - break; - } - List<Ref<? extends Type>> types = imi.def().formalTypes(); - for (int i = 0;i < types.size(); ++i) { - if ( - mi.formalTypes().get(i).typeEquals(imi.formalTypes().get(i), tr.context()) - && isPrimitive(mi.formalTypes().get(i)) - && types.get(i).get() instanceof ParameterType - && !(mi.formalTypes().get(i) instanceof ParameterType) - ) { - implMethods.add(imi); - break; + for (Type type : interfaces) { + if (type instanceof X10ClassType) { + List<MethodInstance> imis = ((X10ClassType) type).methods(); + for (MethodInstance imi : imis) { + if (!(imi.name().equals(mi.name()) && imi.formalTypes().size() == mi.formalTypes().size())) continue; + + if (isContainInstantiateSamePlace(implMethods, imi)) continue; + + Type returnType = mi.returnType(); + if (X10PrettyPrinterVisitor.isGenericOverloading) { + if ( + returnType.typeEquals(imi.returnType() , tr.context()) + && isInstantiate(imi.def().returnType().get(), returnType) + ) { + boolean isContains = false; + List<Ref<? extends Type>> types = imi.def().formalTypes(); + for (int i = 0;i < types.size(); ++i) { + if ( + mi.formalTypes().get(i).typeEquals(imi.formalTypes().get(i), tr.context()) + && containsTypeParam(imi.def().formalTypes().get(i).get()) + ) { + isContains = true; + break; + } + } + if (!isContains) { + implMethods.add(imi); + break; + } + } + } else { + if ( + returnType.typeEquals(imi.returnType() , tr.context()) + && isInstantiate(imi.def().returnType().get(), returnType) + ) { + implMethods.add(imi); + break; + } + List<Ref<? extends Type>> types = imi.def().formalTypes(); + for (int i = 0;i < types.size(); ++i) { + if ( + mi.formalTypes().get(i).typeEquals(imi.formalTypes().get(i), tr.context()) + && isPrimitive(mi.formalTypes().get(i)) + && isInstantiate(types.get(i).get(), mi.formalTypes().get(i)) + ) { + implMethods.add(imi); + break; + } + } } } + getImplMethods(mi, implMethods, ((X10ClassType) type).interfaces()); } - getImplMethods(mi, implMethods, ((X10ClassType) type).interfaces()); } } + + private List<MethodInstance> getInstantiatedMethods(X10ClassType ct, MethodInstance mi) { + List<MethodInstance> methods = new ArrayList<MethodInstance>(); + for (MethodInstance impled : mi.implemented(tr.context())) { + if (mi.container().typeEquals(impled.container(), tr.context())) continue; + + if (X10PrettyPrinterVisitor.isGenericOverloading) { + boolean isContain = false; + for (MethodInstance mi1 : methods) { + if (mi1.def().equals(impled.def())) { + isContain = true; + } + } + if (isContain) continue; + } + else { + if (isContainInstantiateSamePlace(methods, impled)) continue; + } + + Type ti = impled.container(); + ti = X10TypeMixin.baseType(ti); + + if (ti instanceof X10ClassType && !((X10ClassType) ti).flags().isInterface()) { + if ( + X10PrettyPrinterVisitor.isGenericOverloading + || (ti.typeEquals(ct.superClass(), tr.context()) || (ct.isMember() && ti.typeEquals(ct.container(), tr.context()))) + ) { + Type returnType = mi.returnType(); + // instantiate return type + if ( + isInstantiate(impled.def().returnType().get(), returnType) + ) { + methods.add(impled); + continue; + } + else { + List<Ref<? extends Type>> types = impled.def().formalTypes(); + for (int i = 0;i < types.size(); ++i) { + if ( + ( + X10PrettyPrinterVisitor.isGenericOverloading + && containsTypeParam(types.get(i).get()) + ) + || ( + !X10PrettyPrinterVisitor.isGenericOverloading + && isPrimitive(mi.formalTypes().get(i)) + && isInstantiate(types.get(i).get(), mi.formalTypes().get(i)) + ) + ) { + methods.add(impled); + break; + } + } + } + } + } + else { + for (Type t:ct.interfaces()) { + if (existMethodInterfaces(t, ti, impled, mi)) { + methods.add(impled); + continue; + } + } + } + } + return methods; + } + + private static boolean isInstantiate(Type sup, Type t) { + return X10TypeMixin.baseType(sup) instanceof ParameterType && !(X10TypeMixin.baseType(t) instanceof ParameterType); } - - private List<MethodInstance> getInstantiatedMethods(X10ClassType ct, MethodInstance mi) { - List<MethodInstance> methods = new ArrayList<MethodInstance>(); - for (MethodInstance impled : mi.implemented(tr.context())) { - if (mi.container().typeEquals(impled.container(), tr.context())) continue; - if (isContainInstantiateSamePlace(methods, impled)) continue; - Type ti = impled.container(); - ti = X10TypeMixin.baseType(ti); - if (ti instanceof X10ClassType && !((X10ClassType) ti).flags().isInterface()) { - if ( - ti.typeEquals(ct.superClass(), tr.context()) - || (ct.isMember() && ti.typeEquals(ct.container(), tr.context())) - ) { - Type returnType = mi.returnType(); - // instantiate return type - if ( - isInstantiate(impled.def().returnType().get(), returnType) - ) { - methods.add(impled); - continue; - } - else { - // instantiate a formal type with primitive - List<Ref<? extends Type>> types = impled.def().formalTypes(); - for (int i = 0;i < types.size(); ++i) { - if ( - isPrimitive(mi.formalTypes().get(i)) && - isInstantiate(types.get(i).get(), mi.formalTypes().get(i)) - ) { - methods.add(impled); - continue; - } + private boolean existMethodInterfaces(Type t, Type type, MethodInstance mi, MethodInstance mdi) { + if (t.typeEquals(type, tr.context())) { + Type returnType = mdi.returnType(); + if ( + isInstantiate(mi.def().returnType().get(), returnType) + ) { + if (X10PrettyPrinterVisitor.isGenericOverloading) { + boolean containsTypeParam = false; + List<Ref<? extends Type>> types = mi.def().formalTypes(); + for (int i = 0;i < types.size(); ++i) { + if (containsTypeParam(types.get(i).get())) { + containsTypeParam = true; + break; } } + if (!containsTypeParam) return true; + } else { + return true; } - } else { - for (Type t:ct.interfaces()) { - if (existMethodInterfaces(t, ti, impled, mi)) { - methods.add(impled); - continue; + } + if (!X10PrettyPrinterVisitor.isGenericOverloading) { + List<Ref<? extends Type>> types = mi.def().formalTypes(); + for (int i = 0;i < types.size(); ++i) { + if (containsTypeParam(types.get(i).get())) return false; + + if ( + isPrimitive(mdi.formalTypes().get(i)) + && isInstantiate(types.get(i).get(), mdi.formalTypes().get(i)) + ) { + return true; } } } } - return methods; - } - - private static boolean isInstantiate(Type sup, Type t) { - return X10TypeMixin.baseType(sup) instanceof ParameterType && !(X10TypeMixin.baseType(t) instanceof ParameterType); - } - - private boolean existMethodInterfaces(Type t, Type type, MethodInstance mi, MethodInstance mdi) { - if (t.typeEquals(type, tr.context())) { - Type returnType = mdi.returnType(); - if (X10TypeMixin.baseType(mi.def().returnType().get()) instanceof ParameterType && !(X10TypeMixin.baseType(returnType) instanceof ParameterType)) { - return true; - } - List<Ref<? extends Type>> types = mi.def().formalTypes(); - for (int i = 0;i < types.size(); ++i) { - if (isPrimitive(mdi.formalTypes().get(i)) && types.get(i).get() instanceof ParameterType && !(mdi.formalTypes().get(i) instanceof ParameterType)) { - return true; - } - } - } t = X10TypeMixin.baseType(t); if (t instanceof X10ClassType) { for (Type ti : ((X10ClassType) t).interfaces()) { @@ -1430,50 +1527,96 @@ return type.isBoolean() || type.isNumeric() || type.isChar(); } - private void printBridgeMethod(MethodInstance impl, MethodDef def) { + private void printBridgeMethod(ClassType ct, MethodInstance impl, MethodDef def) { w.write("// bridge for " + def); w.newline(); Flags flags = X10Flags.toX10Flags(impl.flags()); w.begin(0); - w.write(flags.clearAbstract() + w.write(flags.clearAbstract().clearProtected().Public() .clear(X10Flags.SAFE) .clear(X10Flags.NATIVE) .translate() ); - + + StructType st = def.container().get(); + + if (def instanceof X10MethodDef) { + List<ParameterType> tps = ((X10MethodDef) def).typeParameters(); + if (tps.size() > 0) { + w.write("<"); + String delim = ""; + for (ParameterType pt : tps) { + w.write(delim); + delim = ","; + w.write(pt.name().toString()); + } + w.write(">"); + w.write(" "); + } + } + // e.g int m() overrides or implements T m() boolean instantiateReturnType = X10TypeMixin.baseType(def.returnType().get()) instanceof ParameterType; if (instantiateReturnType) { - printType(impl.returnType(), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS | X10PrettyPrinterVisitor.BOX_PRIMITIVES); + printType(impl.returnType(), (X10PrettyPrinterVisitor.isGenericOverloading ? 0 : X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS) | X10PrettyPrinterVisitor.BOX_PRIMITIVES); } else { - printType(impl.returnType(), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); + printType(impl.returnType(), (X10PrettyPrinterVisitor.isGenericOverloading ? 0 : X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS) ); } + boolean isInterface = false; + if (st instanceof X10ClassType && ((X10ClassType) st).flags().isInterface()) { + isInterface = true; + } + w.allowBreak(2, 2, " ", 1); - if (X10PrettyPrinterVisitor.isGenericOverloading) { - w.write(mangleMethodName(def)); - } else { + if (X10PrettyPrinterVisitor.isGenericOverloading && !isInterface) { + w.write(mangleMethodName(def, true)); + } + else if (X10PrettyPrinterVisitor.isGenericOverloading) { + w.write(mangleMethodName(def, false)); + } + else { w.write(mangleToJava(impl.name())); } if (instantiateReturnType) { w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); } + + w.write("("); + boolean first = true; + + if (X10PrettyPrinterVisitor.isGenericOverloading && def instanceof X10MethodDef && !isInterface) { + X10MethodDef x10def = (X10MethodDef) def; + for (ParameterType p : x10def.typeParameters()) { + if (!first) { + w.write(","); + w.allowBreak(0, " "); + } + first = false; + + w.write("final "); + w.write(X10PrettyPrinterVisitor.X10_RUNTIME_TYPE_CLASS); + w.write(" "); + w.write(Emitter.mangleToJava(p.name())); + } + } - w.write("("); for (int i = 0; i < def.formalTypes().size(); i++) { Type f = impl.formalTypes().get(i); - if (i != 0) { + if (!first || i != 0) { w.write(","); w.allowBreak(0, " "); } if (X10TypeMixin.baseType(def.formalTypes().get(i).get()) instanceof ParameterType) { - printType(f, X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS | X10PrettyPrinterVisitor.BOX_PRIMITIVES); + printType(f, (X10PrettyPrinterVisitor.isGenericOverloading ? 0 : X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS) | X10PrettyPrinterVisitor.BOX_PRIMITIVES); + } else { - printType(f, X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); + printType(f, X10PrettyPrinterVisitor.isGenericOverloading ? 0 : X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); + } w.write(" "); @@ -1503,16 +1646,51 @@ w.write("return "); } - w.write(mangleToJava(impl.name())); + X10TypeSystem xts = (X10TypeSystem) tr.typeSystem(); + + boolean isInterface2 = false; + StructType st2 = impl.container(); + Type bst = X10TypeMixin.baseType(st2); + if (st2 instanceof X10ClassType) { + if (xts.isInterfaceType(bst) || (xts.isFunctionType(bst) && ((X10ClassType) bst).isAnonymous())) { + isInterface2 = true; + } + } + + if (X10PrettyPrinterVisitor.isGenericOverloading && !isInterface2) { + w.write(mangleMethodName(impl.def(), true)); + } + else if (X10PrettyPrinterVisitor.isGenericOverloading) { + w.write(mangleMethodName(ct, impl, false)); + } + else { + w.write(mangleToJava(impl.name())); + } if (X10TypeMixin.baseType(impl.returnType()) instanceof ParameterType) { w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); } w.write("("); + + boolean first2 = true; + MethodInstance dmi = def.asInstance(); + if (dmi instanceof X10MethodInstance) { + X10MethodInstance x10mi = (X10MethodInstance) dmi; + for (Iterator<Type> i = x10mi.typeParameters().iterator(); i.hasNext(); ) { + final Type at = i.next(); + first2 = false; + new RuntimeTypeExpander(this, at).expand(tr); + if (i.hasNext()) { + w.write(","); + w.allowBreak(0, " "); + } + } + } + for (int i = 0; i < impl.formalTypes().size(); i++) { Type f = impl.formalTypes().get(i); - if (i != 0) { + if (!first2 || i != 0) { w.write(","); w.allowBreak(0, " "); } @@ -1533,128 +1711,135 @@ w.newline(); } - private void getInheritedMethods(X10ClassType ct, List<MethodInstance> results) { - ArrayList<MethodInstance> list = new ArrayList<MethodInstance>(ct.methods()); - list.addAll(results); - List<MethodInstance> overrides = new ArrayList<MethodInstance>(); - for (MethodInstance mi : list) { - for (MethodInstance mi2 : mi.overrides(tr.context())) { - if (ct.superClass() != null && mi2.container().typeEquals(ct.superClass(), tr.context())) { - overrides.add(mi2); - } - } - } - Type sup = ct.superClass(); - if (sup instanceof X10ClassType) { - for (MethodInstance mi : ((X10ClassType)(sup)).methods()) { - if (!mi.flags().isStatic()) { - boolean contains = false; - for (MethodInstance mi2 : overrides) { - if (mi2.isSameMethod(mi, tr.context())) { - contains = true; - break; - } - } - if (!contains) { - results.add(mi); - } - } - } - getInheritedMethods((X10ClassType) sup, results); - } - } + private void getInheritedMethods(X10ClassType ct, List<MethodInstance> results, List<MethodInstance> overrides) { + ArrayList<MethodInstance> list = new ArrayList<MethodInstance>(ct.methods()); + list.addAll(results); + for (MethodInstance mi : list) { + for (MethodInstance mi2 : mi.overrides(tr.context())) { + if (X10PrettyPrinterVisitor.isGenericOverloading || (ct.superClass() != null && mi2.container().typeEquals(ct.superClass(), tr.context()))) { + overrides.add(mi2); + } + } + } + Type sup = ct.superClass(); + if (sup instanceof X10ClassType) { + for (MethodInstance mi : ((X10ClassType)(sup)).methods()) { + if (!mi.flags().isStatic()) { + boolean contains = false; + for (MethodInstance mi2 : overrides) { + if (mi2.isSameMethod(mi, tr.context())) { + contains = true; + break; + } + } + if (!contains) { + results.add(mi); + } + } + } + getInheritedMethods((X10ClassType) sup, results, overrides); + } + } - private void printInheritedMethodBridge(MethodInstance mi) { - MethodDef def = mi.def(); - w.write("// bridge for " + def); - w.newline(); + private void printInheritedMethodBridge(ClassType ct, MethodInstance mi) { + MethodDef def = mi.def(); + w.write("// bridge for " + def); + w.newline(); + + Flags flags = X10Flags.toX10Flags(mi.flags()); + + w.begin(0); + w.write(flags.clearAbstract() + .clear(X10Flags.SAFE) + .clear(X10Flags.NATIVE) + .translate() + ); + + printType(mi.returnType(), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); + + w.allowBreak(2, 2, " ", 1); + if (X10PrettyPrinterVisitor.isGenericOverloading) { + w.write(mangleMethodName(ct, mi, true)); + } else { + w.write(mangleToJava(mi.name())); + } + + if (X10TypeMixin.baseType(mi.returnType()) instanceof ParameterType) { + w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); + } + + w.write("("); + for (int i = 0; i < def.formalTypes().size(); i++) { + Type f = mi.formalTypes().get(i); + if (i != 0) { + w.write(","); + w.allowBreak(0, " "); + } + printType(f, (X10PrettyPrinterVisitor.isGenericOverloading ? 0 : X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS)); + w.write(" "); + + Name name = Name.make("a" + (i + 1)); + w.write(name.toString()); + } + + w.end(); + w.write(")"); + + /** Remove throw types support. + if (!mi.throwTypes().isEmpty()) { + w.allowBreak(6); + w.write("throws "); + for (Iterator<Type> i = mi.throwTypes().iterator(); i.hasNext();) { + Type t = i.next(); + printType(t, X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); + if (i.hasNext()) { + w.write(","); + w.allowBreak(4, " "); + } + } + } + */ + w.write("{"); + if (!mi.returnType().isVoid()) { + w.write("return "); + } + + w.write("super."); + if (X10PrettyPrinterVisitor.isGenericOverloading) { + w.write(mangleMethodName(mi.def(), true)); + } else { + w.write(mangleToJava(mi.name())); + } + + if (X10TypeMixin.baseType(def.returnType().get()) instanceof ParameterType) { + w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); + } + + w.write("("); + for (int i = 0; i < mi.formalTypes().size(); i++) { + Type f = mi.formalTypes().get(i); + if (i != 0) { + w.write(","); + w.allowBreak(0, " "); + } + if (isPrimitive(f) && isInstantiate(def.formalTypes().get(i).get(), f)) { + w.write("("); + printType(f, X10PrettyPrinterVisitor.BOX_PRIMITIVES); + w.write(")"); + } + w.write(" "); + + Name name = Name.make("a" + (i + 1)); + w.write(name.toString()); + } + w.write(")"); + + w.write(";"); + w.write("}"); + w.newline(); + } - Flags flags = X10Flags.toX10Flags(mi.flags()); - - w.begin(0); - w.write(flags.clearAbstract() - .clear(X10Flags.SAFE) - .clear(X10Flags.NATIVE) - .translate() - ); - - printType(mi.returnType(), X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); - - w.allowBreak(2, 2, " ", 1); - w.write(mangleToJava(mi.name())); - - if (X10TypeMixin.baseType(mi.returnType()) instanceof ParameterType) { - w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); - } - - w.write("("); - for (int i = 0; i < def.formalTypes().size(); i++) { - Type f = mi.formalTypes().get(i); - if (i != 0) { - w.write(","); - w.allowBreak(0, " "); - } - printType(f, X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); - w.write(" "); - - Name name = Name.make("a" + (i + 1)); - w.write(name.toString()); - } - - w.end(); - w.write(")"); - - /** Remove throw types support. - if (!mi.throwTypes().isEmpty()) { - w.allowBreak(6); - w.write("throws "); - for (Iterator<Type> i = mi.throwTypes().iterator(); i.hasNext();) { - Type t = i.next(); - printType(t, X10PrettyPrinterVisitor.PRINT_TYPE_PARAMS); - if (i.hasNext()) { - w.write(","); - w.allowBreak(4, " "); - } - } - } -*/ - w.write("{"); - if (!mi.returnType().isVoid()) { - w.write("return "); - } - - w.write("super."); - w.write(mangleToJava(mi.name())); - - if (X10TypeMixin.baseType(def.returnType().get()) instanceof ParameterType) { - w.write(X10PrettyPrinterVisitor.RETURN_PARAMETER_TYPE_SUFFIX); - } - - w.write("("); - for (int i = 0; i < mi.formalTypes().size(); i++) { - Type f = mi.formalTypes().get(i); - if (i != 0) { - w.write(","); - w.allowBreak(0, " "); - } - if (isPrimitive(f) && isInstantiate(def.formalTypes().get(i).get(), f)) { - w.write("("); - printType(f, X10PrettyPrinterVisitor.BOX_PRIMITIVES); - w.write(")"); - } - w.write(" "); - - Name name = Name.make("a" + (i + 1)); - w.write(name.toString()); - } - w.write(")"); - - w.write(";"); - w.write("}"); - w.newline(); - } - - private boolean isContainInstantiateSamePlace(List<MethodInstance> methods, MethodInstance impled) { + private boolean isContainInstantiateSamePlace(List<MethodInstance> methods, MethodInstance impled) { for (MethodInstance mi : methods) { if ( !( @@ -2462,7 +2647,8 @@ } List<MethodInstance> inheriteds = new ArrayList<MethodInstance>(); - getInheritedMethods(ct, inheriteds); + List<MethodInstance> overrides = new ArrayList<MethodInstance>(); + getInheritedMethods(ct, inheriteds, overrides); for (MethodInstance mi : inheriteds) { List<MethodInstance> implMethods = new ArrayList<MethodInstance>(); List<Type> interfaces = ct.interfaces(); @@ -2582,7 +2768,7 @@ w.allowBreak(2, 2, " ", 1); if (X10PrettyPrinterVisitor.isGenericOverloading) { - w.write(mangleMethodName(dispatch.def())); + w.write(mangleMethodName(dispatch.def(), false)); } else { w.write(mangleToJava(dispatch.name())); @@ -2692,7 +2878,7 @@ } if (X10PrettyPrinterVisitor.isGenericOverloading) { - w.write(mangleMethodName(mi.def())); + w.write(mangleMethodName(mi.def(), true)); } else { w.write(mangleToJava(mi.name())); Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-10-01 06:06:36 UTC (rev 16838) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-10-01 08:24:16 UTC (rev 16839) @@ -91,6 +91,7 @@ import polyglot.types.QName; import polyglot.types.Ref; import polyglot.types.SemanticException; +import polyglot.types.StructType; import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; @@ -216,7 +217,7 @@ public final Type imcType; public static final String JAVA_LANG_OBJECT = "java.lang.Object"; public static final boolean isSelfDispatch = true; - public static final boolean isGenericOverloading = false; + public static final boolean isGenericOverloading = true; private static final String X10_RTT_TYPES = "x10.rtt.Types"; @@ -1928,10 +1929,23 @@ } w.write(">"); } + + boolean fromInterface = false; + StructType st = mi.def().container().get(); + Type bst = X10TypeMixin.baseType(st); + if (bst instanceof X10ClassType) { + if (xts.isInterfaceType(bst) || (xts.isFunctionType(bst) && ((X10ClassType) bst).isAnonymous())) { + fromInterface = true; + } + } - if (isGenericOverloading) { - w.write(Emitter.mangleMethodName(mi.def())); - } else { + if (isGenericOverloading && !fromInterface) { + w.write(Emitter.mangleMethodName(mi.def(), true)); + } + else if (isGenericOverloading) { + w.write(Emitter.mangleMethodName(mi.def(), false)); + } + else { w.write(Emitter.mangleToJava(c.name().id())); } Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java 2010-10-01 06:06:36 UTC (rev 16838) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/PlaceLocalHandle.java 2010-10-01 08:24:16 UTC (rev 16839) @@ -53,7 +53,7 @@ return (T)data; } - public void set(T data) { + public void set_0_$$x10$lang$PlaceLocalHandle_T(T data) { int here = Thread.currentThread().home().id; assert objects[here] == null : "At "+here+" set called on already initialized local object"; objects[here] = data; Modified: trunk/x10.runtime/src-java/x10/runtime/impl/java/Runtime.java =================================================================== --- trunk/x10.runtime/src-java/x10/runtime/impl/java/Runtime.java 2010-10-01 06:06:36 UTC (rev 16838) +++ trunk/x10.runtime/src-java/x10/runtime/impl/java/Runtime.java 2010-10-01 08:24:16 UTC (rev 16839) @@ -51,7 +51,7 @@ // build up Array[String] for args x10.array.Array<String> aargs = new x10.array.Array<String>(x10.rtt.Types.STRING, args.length); for (int i=0; i<args.length; i++) { - aargs.set$G(args[i], i); + aargs.set_0_$$x10$array$Array_T$G(args[i], i); } // execute root x10 activity Modified: trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-10-01 06:06:36 UTC (rev 16838) +++ trunk/x10.runtime/src-x10/x10/util/IndexedMemoryChunk.x10 2010-10-01 08:24:16 UTC (rev 16839) @@ -129,7 +129,7 @@ * @param numElems the number of elements to copy. * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ - @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyTo(#9, #0,#1,#2,#3,#4,#5,#6)") + @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyTo_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#9, #0,#1,#2,#3,#4,#5,#6)") @Native("c++", "(#0)->copyTo(#1,#2,#3,#4,#5,#6)") public native def asyncCopyTo (srcIndex:int, dstPlace:Place, dst:IndexedMemoryChunk[T], dstIndex:int, @@ -157,7 +157,7 @@ * @param numElems the number of elements to copy. * @param uncounted Should the spawned activity be treated as if it were annotated @Uncounted */ - @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyFrom(#9, #0,#1,#2,#3,#4,#5,#6)") + @Native("java", "x10.util.IndexedMemoryChunk__NativeRep.copyFrom_0_$_x10$util$IndexedMemoryChunk__NativeRep_T_$_3_$_x10$util$IndexedMemoryChunk__NativeRep_T_$(#9, #0,#1,#2,#3,#4,#5,#6)") @Native("c++", "(#0)->copyFrom(#1,#2,#3,#4,#5,#6)") public native def asyncCopyFrom(dstIndex:int, srcPlace:Place, src:IndexedMemoryChunk[T], srcIndex:int, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-01 19:28:44
|
Revision: 16854 http://x10.svn.sourceforge.net/x10/?rev=16854&view=rev Author: yzibin Date: 2010-10-01 19:28:37 +0000 (Fri, 01 Oct 2010) Log Message: ----------- allow calling "this.someMethod()" before the property call (provided that method is not reading nor assigning any fields) Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java =================================================================== --- trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-01 18:32:53 UTC (rev 16853) +++ trunk/x10.compiler/src/x10/visit/CheckEscapingThis.java 2010-10-01 19:28:37 UTC (rev 16854) @@ -403,8 +403,26 @@ } } - @Override public Node leave(Node old, Node n, NodeVisitor v) { + @Override public Node visitEdgeNoOverride(Node parent, Node n) { Position pos = n.position(); + if (!canUseThis() && n instanceof X10Call) { + final X10Call call = (X10Call) n; + MethodInfo info = getInfo(call); + if (info!=null) { + if (info.read.size()==0 && info.write.size()==0) { + // even though we use "this.call(...)", this is legal + // because the call doesn't read nor write to "this" + } else { + reportError("You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields.",pos); + } + for (Expr e : call.arguments()) + e.visit(this); + return n; + } + } + + n.del().visitChildren(this); + if (n instanceof ConstructorCall) { ConstructorCall constructorCall = (ConstructorCall) n; switch (state) { @@ -421,7 +439,7 @@ } } else if (n instanceof AssignPropertyCall) { switch (state) { - case Start: + case Start: assert false : "implicit super() call is handled at the beginning, see getConstructorCall"; case SawCtor: if (!wasSuperCall) @@ -444,7 +462,7 @@ if (state==CtorState.Start) reportError("You can use 'super' only after 'super(...)'",pos); } else if (!canUseThis()) - reportError(hasProperties ? "Can use 'this' only after 'property(...)'" : "Can use 'this' only after 'this(...)' or 'super(...)'", pos); + reportError(hasProperties ? "Can use 'this' only after 'property(...)'" : "Can use 'this' only after 'this(...)' or 'super(...)'.", pos); } return n; } @@ -595,7 +613,7 @@ // visit every ctor, every @NonEscaping method, and every method recursively called from them, and check that this and super do not escape - ArrayList<X10ConstructorDecl_c> ctorsForDataFlow = new ArrayList<X10ConstructorDecl_c>(); + ArrayList<X10ConstructorDecl_c> allCtors = new ArrayList<X10ConstructorDecl_c>(); for (ClassMember classMember : body.members()) { if (classMember instanceof ProcedureDecl) { final ProcedureDecl proc = (ProcedureDecl) classMember; @@ -645,23 +663,14 @@ if (procBody==null) continue; assert proc instanceof X10ConstructorDecl_c : proc; final X10ConstructorDecl_c ctor = (X10ConstructorDecl_c) proc; - final CheckCtor checkCtor = new CheckCtor(ctor); - ctor.visit(checkCtor); - checkCtor.postCheck(); - // ctors are implicitly NonEscaping - final ConstructorCall cc = getConstructorCall(ctor); - if (cc!=null && cc.kind() == ConstructorCall.THIS) { - // ignore in dataflow ctors that call other ctors (using "this(...)"). - } else { - // add field initializers to all ctors - ctorsForDataFlow.add(ctor); - } + allCtors.add(ctor); } procBody.visit(this); } } - if (fields.size()==0) return; // done! all fields have an init, thus all reads are legal (and no writes must be done). + // we still need to CheckCtor (make sure super, this and property is correct) + //if (fields.size()==0) return; // done! all fields have an init, thus all reads are legal (and no writes must be done). // do init for the fixed point alg for (Map.Entry<ProcedureDef, MethodInfo> entry : allMethods.entrySet()) { @@ -683,12 +692,23 @@ } // handle ctors and field initializers // make a new special ctor for field-init, and the ctors will use its data-flow for their INIT - if (ctorsForDataFlow.size()>0) { + if (allCtors.size()>0) { // there should be at least one auto-generated ctor fieldChecker.init = CTOR_INIT; - X10ConstructorDecl_c fieldInitCtor = (X10ConstructorDecl_c) ctorsForDataFlow.get(0).body(newInit); + X10ConstructorDecl_c fieldInitCtor = (X10ConstructorDecl_c) allCtors.get(0).body(newInit); fieldChecker.dataflow(fieldInitCtor); fieldChecker.init = fieldChecker.finalResult; - for (X10ConstructorDecl_c ctor : ctorsForDataFlow) { + for (X10ConstructorDecl_c ctor : allCtors) { + // check super, this, and property calls + final CheckCtor checkCtor = new CheckCtor(ctor); + ctor.visit(checkCtor); + checkCtor.postCheck(); + + // ctors are implicitly NonEscaping + final ConstructorCall cc = getConstructorCall(ctor); + if (cc!=null && cc.kind() == ConstructorCall.THIS) { + // ignore in dataflow ctors that call other ctors (using "this(...)"). + continue; + } // X10ConstructorDecl_c newCtor = (X10ConstructorDecl_c) ctor.body( nf.Block(pos,newInit,ctor.body()) ); //reports errors in the field-inits multiple times (if we have multiple ctors) fieldChecker.dataflow(ctor); fieldChecker.checkResult(); Modified: trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 2010-10-01 18:32:53 UTC (rev 16853) +++ trunk/x10.runtime/src-x10/x10/compiler/NonEscaping.x10 2010-10-01 19:28:37 UTC (rev 16854) @@ -26,7 +26,7 @@ * * <p>@NonEscaping marks the fact that "this" does not escape (also called leak) from the method. * A method is NonEscaping if: - * 1) the method is either final, private or annotated with @NonEscaping. + * 1) the method is either final, private, annotated with @NonEscaping, or the entire class is final. * 2) in the method body, "this" is only used in field access, field assignment, * and as the reciever of NonEscaping methods. * 2) in the method body, "super" is only used in field access, field assignment, @@ -35,8 +35,7 @@ * The compiler checks @NonEscaping as follows: * 1) @NonEscaping must be preserved by overriding, i.e., when overriding a method annotated with * @NonEscaping(readFromFields) then the overriding method must be annotated with exactly the same annotation. - * 2) The fields in readFromFields must be declared in the class (and cannot include fields of the superclass). - * 3) The method can read only from fields in readFromFields. + * 2) The method can read only from fields in readFromFields. * NonEscaping is of course not checked on native methods because they do not have a body. * * All constructors and field initializers in X10 must be NonEscaping. Modified: trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 2010-10-01 18:32:53 UTC (rev 16853) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/Worker.x10 2010-10-01 19:28:37 UTC (rev 16854) @@ -47,7 +47,7 @@ public def find():RegularFrame { var k:Object = Frame.NULL[Object](); -// if (deque.poll() != null) Runtime.println("ERROR"); +// if (deque.poll() != null) Runtime.println("deque.poll() != null"); k = fifo.steal(); while (null == k) { if (finished.value) return Frame.NULL[RegularFrame](); // TODO: termination condition Modified: trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 2010-10-01 18:32:53 UTC (rev 16853) +++ trunk/x10.runtime/src-x10/x10/compiler/ws/java/Worker.x10 2010-10-01 19:28:37 UTC (rev 16854) @@ -46,7 +46,7 @@ public def find():RegularFrame { var k:Object = null; -// if (deque.poll() != null) Runtime.println("ERROR"); +// if (deque.poll() != null) Runtime.println("deque.poll() != null"); k = fifo.steal(); while (null == k) { if (finished.value) return null; // TODO: termination condition Modified: trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-01 18:32:53 UTC (rev 16853) +++ trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 2010-10-01 19:28:37 UTC (rev 16854) @@ -2,7 +2,56 @@ import x10.compiler.*; // @Uncounted @NonEscaping +class InfiniteInit234 { + var i:Int{self!=0}; + def this() { + foo(); + } + private def foo() = foo(); +} +class AllowCallsIfNoReadNorWrite { + class Inner(i:Int) { + def this() { + val w = this.foo1(); + property(4); + } + private def foo1() = 3 + foo2(); + private def foo2() = 3; + } +} + +class DisallowCallsIfReadOrWrite { + class Inner(i:Int) { + static y=5; + var x:Int=2; + val z:Int=3; + def this() { + val w = this.foo1(); // ERR: You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields. + property(4); + } + def this(i:Int) { + val w = this.bar1(); // ERR: You can use 'this' before 'property(...)' to call only methods that do not read nor write any fields. + property(4); + } + private def foo1() = foo2()+2; + private def foo2() = foo3()+3; + private def foo3() { + x=2; // There is a write to a field in this method! + return y; + } + private def bar1() = bar2()+2; + final def bar2() { + return z; // There is a read from a field in this method! + } + } +} + +class IllegalForwardRef234 { + var i1:Int{self!=0} = i2; // ERR: Cannot read from field 'i2' before it is definitely assigned. + var i2:Int{self!=0} = i1; +} + class TestUncountedAsync1 { //@Uncounted async S //is treated like this: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-01 19:37:25
|
Revision: 16855 http://x10.svn.sourceforge.net/x10/?rev=16855&view=rev Author: dgrove-oss Date: 2010-10-01 19:37:14 +0000 (Fri, 01 Oct 2010) Log Message: ----------- WIP on allowing clousres to capture and serialize the addresses of stack variables from their lexically enclosing environments. Some simple test cases of async initialization of val locals defined outside of a finish now work with the C++ backend. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.runtime/src-cpp/x10rt.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-01 19:28:37 UTC (rev 16854) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-01 19:37:14 UTC (rev 16855) @@ -27,6 +27,7 @@ import static x10cpp.visit.SharedVarsMethods.THIS; import static x10cpp.visit.SharedVarsMethods.chevrons; import static x10cpp.visit.SharedVarsMethods.make_ref; +import static x10cpp.visit.SharedVarsMethods.make_boxed_ref; import java.util.ArrayList; import java.util.Iterator; @@ -57,6 +58,7 @@ import polyglot.types.SemanticException; import polyglot.types.Type; import polyglot.types.Types; +import polyglot.types.VarDef; import polyglot.types.VarInstance; import polyglot.util.CodeWriter; import polyglot.util.ErrorInfo; @@ -73,6 +75,7 @@ import x10.types.X10ClassType; import x10.types.X10ConstructorDef; import x10.types.X10Flags; +import x10.types.X10LocalDef; import x10.types.X10MethodDef; import x10.types.X10MethodInstance; import x10.types.X10TypeMixin; @@ -923,10 +926,12 @@ void printDeclarationList(CodeWriter w, X10CPPContext_c c, ArrayList<VarInstance<?>> vars, boolean saved_this_mechanism, boolean writable, List<VarInstance<?>> refs) { for (int i = 0; i < vars.size(); i++) { VarInstance<?> var = vars.get(i); + VarDef def = var.def(); Type t = var.type(); String type = translateType(t, true); - if ((writable && !var.name().toString().equals(THIS)) || refs.contains(var)) // this is a temporary ref - type = type + "&"; // FIXME: Hack to get writable args in finally closures + if ((writable && !var.name().toString().equals(THIS)) || refs.contains(var)) { + type = make_boxed_ref(type); + } String name = var.name().toString(); if (saved_this_mechanism && name.equals(THIS)) { assert (c.isInsideClosure()); // FIXME: Krishna, why did you add this test? Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-01 19:28:37 UTC (rev 16854) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-01 19:37:14 UTC (rev 16855) @@ -45,6 +45,7 @@ import static x10cpp.visit.SharedVarsMethods.getId; import static x10cpp.visit.SharedVarsMethods.getUniqueId_; import static x10cpp.visit.SharedVarsMethods.make_ref; +import static x10cpp.visit.SharedVarsMethods.make_boxed_ref; import static x10cpp.visit.SharedVarsMethods.refsAsPointers; import java.util.ArrayList; @@ -140,6 +141,7 @@ import polyglot.types.Type; import polyglot.types.TypeSystem; import polyglot.types.Types; +import polyglot.types.VarDef; import polyglot.types.VarInstance; import polyglot.util.CodeWriter; import polyglot.util.CollectionUtil; @@ -210,6 +212,7 @@ import x10.types.X10FieldDef; import x10.types.X10FieldInstance; import x10.types.X10Flags; +import x10.types.X10LocalDef; import x10.types.X10MethodDef; import x10.types.X10MethodInstance; import x10.types.X10ParsedClassType_c; @@ -4093,6 +4096,13 @@ refs.add(((X10Local_c) exp).varInstance()); } } + + for (VarInstance<?> var : c.variables) { + VarDef def = var.def(); + if ((def instanceof X10LocalDef) && ((X10LocalDef)def).isAsyncInit()) { + refs.add(var); + } + } emitter.printDeclarationList(inc, c, c.variables, refs); inc.forceNewline(); @@ -4102,7 +4112,7 @@ inc.write("return "+SERIALIZATION_ID_FIELD+";"); inc.end(); inc.newline(); inc.write("}"); inc.newline(); inc.forceNewline(); - generateClosureSerializationFunctions(c, cnamet, inc, n.body()); + generateClosureSerializationFunctions(c, cnamet, inc, n.body(), refs); // inc.write(cname+"("+SERIALIZATION_MARKER+") { }"); // inc.newline(); inc.forceNewline(); @@ -4116,7 +4126,7 @@ name = SAVED_THIS; else name = mangled_non_method_name(name); if (refs.contains(var)) { - inc.write(Emitter.translateType(var.type(), true) + "& " + name); + inc.write(make_boxed_ref(Emitter.translateType(var.type(), true)) + " " + name); } else { inc.write(Emitter.translateType(var.type(), true) + " " + name); } @@ -4219,7 +4229,11 @@ name = SAVED_THIS; else if (X10TypeMixin.isX10Struct(var.type())) // FIXME: duplication from visit(X10Special_c) name = "this_"; - sw.write(name); + if (refs.contains(var)) { + sw.write("&("+name+")"); + } else { + sw.write(name); + } } sw.write(")"); if (!stackAllocateClosure) { @@ -4230,9 +4244,8 @@ emitter.exitClosure(c); } - protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, Block block) { - inc.write("// TODO: handle serialization of ref fields correctly"); inc.newline(); inc.forceNewline(); - + protected void generateClosureSerializationFunctions(X10CPPContext_c c, String cnamet, StreamWrapper inc, + Block block, List<VarInstance<?>> refs) { inc.write("void "+SERIALIZE_BODY_METHOD+"("+SERIALIZATION_BUFFER+" &buf) {"); inc.newline(4); inc.begin(0); // FIXME: factor out this loop @@ -4240,9 +4253,11 @@ if (i > 0) inc.newline(); VarInstance<?> var = (VarInstance<?>) c.variables.get(i); String name = var.name().toString(); - if (name.equals(THIS)) + if (name.equals(THIS)) { name = SAVED_THIS; - else name = mangled_non_method_name(name); + } else { + name = mangled_non_method_name(name); + } inc.write("buf.write(this->" + name + ");"); } inc.end(); inc.newline(); @@ -4258,11 +4273,16 @@ VarInstance<?> var = (VarInstance<?>) c.variables.get(i); Type t = var.type(); String type = Emitter.translateType(t, true); + if (refs.contains(var)) { + type = make_boxed_ref(type); + } String name = var.name().toString(); - if (name.equals(THIS)) + if (name.equals(THIS)) { name = SAVED_THIS; - else name = mangled_non_method_name(name); - inc.write(type + " that_"+name+" = buf.read"+chevrons(Emitter.translateType(var.type(), true))+"();"); + } else { + name = mangled_non_method_name(name); + } + inc.write(type + " that_"+name+" = buf.read"+chevrons(type)+"();"); inc.newline(); } inc.write(make_ref(cnamet)+" this_ = new (storage) "+cnamet+"("); Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-10-01 19:28:37 UTC (rev 16854) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-10-01 19:37:14 UTC (rev 16855) @@ -111,6 +111,11 @@ return type+"*"; return "x10aux::ref"+chevrons(type); } + + public static String make_boxed_ref(String type) { + return "x10aux::boxed_ref"+chevrons(type); + } + static String closure_name(String prefix, int id) { return prefix + id; } Added: trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h 2010-10-01 19:37:14 UTC (rev 16855) @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#ifndef X10BOXEDREF_H +#define X10BOXEDREF_H + +#include <cstdlib> +#include <cassert> + +#include <x10aux/config.h> + +namespace x10aux { + + /** + * This class lets us wrap a pointer (eg an address on the stack) + * in a way that lets uses of the boxed_ref be unchanged + * (they can still pretend it is a stack variable), but + * allows us to keep the pointer as a x10_long to enable + * 32/64 bit platform interoperability for captured stack vars. + * We need to be able to support a stack address being captured on + * a 64 bit machine, transfered to a 32 bit machine via an at, then + * coming back to the original 64 bit machine and being dereferenced. + * + * TODO: actually hid the void* as an x10_long like we do in GlobalRef. + */ + template<class T> class boxed_ref { + protected: + void *_val; + public: + GPUSAFE boxed_ref() { } // ok to not initialize; compiler will ensure we never read unitialized boxed_ref + + GPUSAFE boxed_ref(const boxed_ref<T>& _ref) : _val(_ref._val) { } + + GPUSAFE boxed_ref(T const &val) : _val((void*)&val) { } + + GPUSAFE boxed_ref(T const *val) : _val((void*)val) { } + + GPUSAFE const boxed_ref<T>& operator=(const boxed_ref<T>& _ref) { + _val = _ref._val; + return *this; + } + + T operator=(const T &val) { + *(T*)_val = val; + return val; + } + + operator T() { + return *((T*)_val); + } + + x10_long capturedAddress() { + return (x10_long)(size_t)(_val); + } + + void setCapturedAddress(x10_long addr) { + _val = (void*)(size_t)addr; + } + }; +} + +// vim:tabstop=4:shiftwidth=4:expandtab + +#endif Property changes on: trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + native Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-10-01 19:28:37 UTC (rev 16854) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-10-01 19:37:14 UTC (rev 16855) @@ -16,6 +16,7 @@ #include <x10aux/config.h> #include <x10aux/ref.h> +#include <x10aux/boxed_ref.h> #include <x10aux/alloc.h> #include <x10aux/deserialization_dispatcher.h> @@ -225,6 +226,7 @@ // Default case for primitives and other things that never contain pointers template<class T> struct Write; template<class T> struct Write<ref<T> >; + template<class T> struct Write<boxed_ref<T> >; template<typename T> void write(const T &val); // So it can access the addr_map @@ -317,6 +319,18 @@ T::_serialize(val,buf); } + // Case for captured stack variables e.g. boxed_ref<T>, + template<class T> struct serialization_buffer::Write<boxed_ref<T> > { + static void _(serialization_buffer &buf, boxed_ref<T> val); + }; + template<class T> void serialization_buffer::Write<boxed_ref<T> >::_(serialization_buffer &buf, + boxed_ref<T> val) { + _S_("Serializing a stack variable of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" into buf: "<<&buf); + x10_long capturedAddress = val.capturedAddress(); + _S_("\tCaptured address is "<<((void*)capturedAddress)); + buf.write(capturedAddress); + } + template<typename T> void serialization_buffer::write(const T &val) { Write<T>::_(*this,val); } @@ -442,6 +456,20 @@ return T::template _deserialize<T>(buf); } + // Case for captured stack addresses, boxed_ref<T> + template<class T> struct deserialization_buffer::Read<boxed_ref<T> > { + GPUSAFE static boxed_ref<T> _(deserialization_buffer &buf); + }; + template<class T> boxed_ref<T> deserialization_buffer::Read<boxed_ref<T> >::_(deserialization_buffer &buf) { + _S_("Deserializing a stack variable of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" from buf: "<<&buf); + x10_long addr = buf.read<x10_long>(); + _S_("\tCaptured address is "<<((void*)addr)); + x10aux::boxed_ref<T> result; + result.setCapturedAddress(addr); + return result; + } + + template<typename T> GPUSAFE T deserialization_buffer::read() { return Read<T>::_(*this); } Modified: trunk/x10.runtime/src-cpp/x10rt.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt.h 2010-10-01 19:28:37 UTC (rev 16854) +++ trunk/x10.runtime/src-cpp/x10rt.h 2010-10-01 19:37:14 UTC (rev 16855) @@ -10,6 +10,7 @@ #include <x10aux/class_cast.h> #include <x10aux/ref.h> +#include <x10aux/boxed_ref.h> #include <x10aux/reference_logger.h> #include <x10aux/alloc.h> #include <x10aux/serialization.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yz...@us...> - 2010-10-01 23:22:16
|
Revision: 16872 http://x10.svn.sourceforge.net/x10/?rev=16872&view=rev Author: yzibin Date: 2010-10-01 23:22:06 +0000 (Fri, 01 Oct 2010) Log Message: ----------- Started converting error messages (finished converting all SemanticException(...) to fit in a single line as pre-processing stage) Modified Paths: -------------- trunk/x10.compiler/src/polyglot/ast/AmbExpr_c.java trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java trunk/x10.compiler/src/polyglot/ast/AmbTypeNode_c.java trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java trunk/x10.compiler/src/polyglot/ast/Assert_c.java trunk/x10.compiler/src/polyglot/ast/Assign_c.java trunk/x10.compiler/src/polyglot/ast/Binary_c.java trunk/x10.compiler/src/polyglot/ast/Call_c.java trunk/x10.compiler/src/polyglot/ast/CanonicalTypeNode_c.java trunk/x10.compiler/src/polyglot/ast/Case_c.java trunk/x10.compiler/src/polyglot/ast/Cast_c.java trunk/x10.compiler/src/polyglot/ast/Catch_c.java trunk/x10.compiler/src/polyglot/ast/ClassBody_c.java trunk/x10.compiler/src/polyglot/ast/ClassDecl_c.java trunk/x10.compiler/src/polyglot/ast/Conditional_c.java trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java trunk/x10.compiler/src/polyglot/ast/ConstructorDecl_c.java trunk/x10.compiler/src/polyglot/ast/Do_c.java trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java trunk/x10.compiler/src/polyglot/ast/For_c.java trunk/x10.compiler/src/polyglot/ast/Formal_c.java trunk/x10.compiler/src/polyglot/ast/If_c.java trunk/x10.compiler/src/polyglot/ast/Initializer_c.java trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java trunk/x10.compiler/src/polyglot/ast/Local_c.java trunk/x10.compiler/src/polyglot/ast/NewArray_c.java trunk/x10.compiler/src/polyglot/ast/New_c.java trunk/x10.compiler/src/polyglot/ast/Return_c.java trunk/x10.compiler/src/polyglot/ast/SourceFile_c.java trunk/x10.compiler/src/polyglot/ast/Special_c.java trunk/x10.compiler/src/polyglot/ast/Switch_c.java trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java trunk/x10.compiler/src/polyglot/ast/Throw_c.java trunk/x10.compiler/src/polyglot/ast/Try_c.java trunk/x10.compiler/src/polyglot/ast/Unary_c.java trunk/x10.compiler/src/polyglot/ast/While_c.java trunk/x10.compiler/src/polyglot/types/SystemResolver.java trunk/x10.compiler/src/polyglot/types/TypeEnv_c.java trunk/x10.compiler/src/polyglot/types/TypeSystem_c.java trunk/x10.compiler/src/polyglot/visit/ExceptionChecker.java trunk/x10.compiler/src/polyglot/visit/FwdReferenceChecker.java trunk/x10.compiler/src/x10/ast/AmbMacroTypeNode_c.java trunk/x10.compiler/src/x10/ast/AssignPropertyCall_c.java trunk/x10.compiler/src/x10/ast/ForLoop_c.java trunk/x10.compiler/src/x10/ast/X10AmbTypeNode_c.java trunk/x10.compiler/src/x10/ast/X10Binary_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/X10ClassDecl_c.java trunk/x10.compiler/src/x10/ast/X10Conditional_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorCall_c.java trunk/x10.compiler/src/x10/ast/X10ConstructorDecl_c.java trunk/x10.compiler/src/x10/ast/X10Do_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/X10If_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/ast/X10Return_c.java trunk/x10.compiler/src/x10/ast/X10SourceFile_c.java trunk/x10.compiler/src/x10/ast/X10Special_c.java trunk/x10.compiler/src/x10/ast/X10Unary_c.java trunk/x10.compiler/src/x10/ast/X10While_c.java trunk/x10.compiler/src/x10/compiler/ws/WSCodeGenerator.java trunk/x10.compiler/src/x10/compiler/ws/codegen/WSRegularFrameClassGen.java trunk/x10.compiler/src/x10/emitter/Emitter.java trunk/x10.compiler/src/x10/errors/Errors.java trunk/x10.compiler/src/x10/types/X10ClassDef_c.java trunk/x10.compiler/src/x10/types/X10TypeEnv_c.java trunk/x10.compiler/src/x10/types/checker/PlaceChecker.java trunk/x10.compiler/src/x10/visit/CheckNativeAnnotationsVisitor.java trunk/x10.tests/examples/Constructs/Constructor/EscapingThisTest.x10 Modified: trunk/x10.compiler/src/polyglot/ast/AmbExpr_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbExpr_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/AmbExpr_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -71,8 +71,7 @@ return n; } - throw new SemanticException("Could not find field or local " + - "variable \"" + name + "\".", pos); + throw new SemanticException("Could not find field or local variable \"" + name + "\".", pos); } public Node typeCheck(ContextVisitor tc) throws SemanticException { Modified: trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/AmbQualifierNode_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -109,9 +109,7 @@ return n; } - ex = new SemanticException("Could not find type or package \"" + - (qual == null ? name.toString() : qual.toString() + "." + name.toString()) + - "\".", position()); + ex = new SemanticException("Could not find type or package \"" + (qual == null ? name.toString() : qual.toString() + "." + name.toString()) + "\".", position()); } catch (SemanticException e) { ex = e; Modified: trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/AmbReceiver_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -48,10 +48,7 @@ return n; } - throw new SemanticException("Could not find type, field, or " + - "local variable \"" + - (prefix == null ? name.toString() : prefix.toString() + "." + name.toString()) + - "\".", position()); + throw new SemanticException("Could not find type, field, or local variable \"" + (prefix == null ? name.toString() : prefix.toString() + "." + name.toString()) + "\".", position()); } Modified: trunk/x10.compiler/src/polyglot/ast/AmbTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/AmbTypeNode_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/AmbTypeNode_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -88,9 +88,7 @@ return n; } - ex = new SemanticException("Could not find type \"" + - (prefix == null ? name.id() : prefix.toString() + "." + name.id()) + - "\".", position()); + ex = new SemanticException("Could not find type \"" + (prefix == null ? name.id() : prefix.toString() + "." + name.id()) + "\".", position()); } catch (SemanticException e) { ex = e; Modified: trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ArrayAccess_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -88,13 +88,11 @@ TypeSystem ts = tc.typeSystem(); if (! array.type().isArray()) { - throw new SemanticException( - "Subscript can only follow an array type.", position()); + throw new SemanticException("Subscript can only follow an array type.", position()); } if (! ts.isImplicitCastValid(index.type(), ts.Int(), tc.context())) { - throw new SemanticException( - "Array subscript must be an integer.", position()); + throw new SemanticException("Array subscript must be an integer.", position()); } return type(array.type().toArray().base()); Modified: trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ArrayInit_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -117,8 +117,7 @@ TypeSystem ts = tc.typeSystem(); if (! lhsType.isArray()) { - throw new SemanticException("Cannot initialize " + lhsType + - " with " + type + ".", position()); + throw new SemanticException("Cannot initialize " + lhsType + " with " + type + ".", position()); } // Check if we can assign each individual element. @@ -136,8 +135,7 @@ if (! ts.isImplicitCastValid(s, t, tc.context()) && ! ts.typeEquals(s, t, tc.context()) && ! ts.numericConversionValid(t, e.constantValue(), tc.context())) { - throw new SemanticException("Cannot assign " + s + - " to " + t + ".", e.position()); + throw new SemanticException("Cannot assign " + s + " to " + t + ".", e.position()); } } } Modified: trunk/x10.compiler/src/polyglot/ast/Assert_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Assert_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Assert_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -68,15 +68,11 @@ public Node typeCheck(ContextVisitor tc) throws SemanticException { if (! cond.type().isBoolean()) { - throw new SemanticException("Condition of assert statement " + - "must have boolean type.", - cond.position()); + throw new SemanticException("Condition of assert statement must have boolean type.", cond.position()); } if (errorMessage != null && errorMessage.type().isVoid()) { - throw new SemanticException("Error message in assert statement " + - "cannot be void.", - errorMessage.position()); + throw new SemanticException("Error message in assert statement cannot be void.", errorMessage.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Assign_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Assign_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Assign_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -98,8 +98,7 @@ ! ts.typeEquals(s, t, context) && ! ts.numericConversionValid(t, right.constantValue(), context)) { - throw new SemanticException("Cannot assign " + s + " to " + t + ".", - position()); + throw new SemanticException("Cannot assign " + s + " to " + t + ".", position()); } return n.type(t); @@ -115,9 +114,7 @@ return n.type(ts.promote(t, s)); } - throw new SemanticException("The " + op + " operator must have " - + "numeric or String operands.", - position()); + throw new SemanticException("Operator must have numeric or String operands.", position()); } if (op == SUB_ASSIGN || op == MUL_ASSIGN || @@ -126,9 +123,7 @@ return n.type(ts.promote(t, s)); } - throw new SemanticException("The " + op + " operator must have " - + "numeric operands.", - position()); + throw new SemanticException("Operator must have numeric operands.", position()); } if (op == BIT_AND_ASSIGN || op == BIT_OR_ASSIGN || op == BIT_XOR_ASSIGN) { @@ -141,9 +136,7 @@ return n.type(ts.promote(t, s)); } - throw new SemanticException("The " + op + " operator must have " - + "integral or boolean operands.", - position()); + throw new SemanticException("Operator must have integral or boolean operands.", position()); } if (op == SHL_ASSIGN || op == SHR_ASSIGN || op == USHR_ASSIGN) { @@ -153,9 +146,7 @@ return n.type(ts.promote(t)); } - throw new SemanticException("The " + op + " operator must have " - + "integral operands.", - position()); + throw new SemanticException("Operator must have integral operands.", position()); } throw new InternalCompilerError("Unrecognized assignment operator " + Modified: trunk/x10.compiler/src/polyglot/ast/Binary_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Binary_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Binary_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -259,59 +259,40 @@ Context context = tc.context(); if (op == GT || op == LT || op == GE || op == LE) { - if (! l.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - l + ".", left.position()); + final boolean isL = !l.isNumeric(); + final boolean isR = !r.isNumeric(); + if (isL || isR) { + throw new SemanticException("Operator must have numeric operands.", (isL ? left : right).position()); } - if (! r.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - r + ".", right.position()); - } - return type(ts.Boolean()); } if (op == EQ || op == NE) { if (! ts.isCastValid(l, r, context) && ! ts.isCastValid(r, l, context)) { - throw new SemanticException("The " + op + - " operator must have operands of similar type.", - position()); + throw new SemanticException("Operator must have operands of similar type.",position()); } return type(ts.Boolean()); } if (op == COND_OR || op == COND_AND) { - if (! l.isBoolean()) { - throw new SemanticException("The " + op + - " operator must have boolean operands, not type " + - l + ".", left.position()); + final boolean isL = !l.isBoolean(); + final boolean isR = !r.isBoolean(); + if (isL||isR) { + throw new SemanticException("Operator must have boolean operands.", (isL ? left:right).position()); } - if (! r.isBoolean()) { - throw new SemanticException("The " + op + - " operator must have boolean operands, not type " + - r + ".", right.position()); - } - return type(ts.Boolean()); } if (op == ADD) { if (ts.isSubtype(l, ts.String(), context) || ts.isSubtype(r, ts.String(), context)) { - if (!ts.canCoerceToString(r, tc.context())) { - throw new SemanticException("Cannot coerce an expression " + - "of type " + r + " to a String.", - right.position()); + final boolean isR = !ts.canCoerceToString(r, tc.context()); + final boolean isL = !ts.canCoerceToString(l, tc.context()); + if (isL || isR) { + throw new SemanticException("Cannot coerce an expression to a String.",(isL ? left : right).position()); } - if (!ts.canCoerceToString(l, tc.context())) { - throw new SemanticException("Cannot coerce an expression " + - "of type " + l + " to a String.", - left.position()); - } return precedence(Precedence.STRING_ADD).type(ts.String()); } @@ -324,59 +305,35 @@ } if (op == ADD) { - if (! l.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric or String operands, not type " + - l + ".", left.position()); + final boolean isL = !l.isNumeric(); + final boolean isR = !r.isNumeric(); + if (isL || isR) { + throw new SemanticException("Operator must have numeric or String operands.", (isL ? left : right).position()); } - - if (! r.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric or String operands, not type " + - r + ".", right.position()); - } } if (op == BIT_AND || op == BIT_OR || op == BIT_XOR) { - if (! ts.isImplicitCastValid(l, ts.Long(), context)) { - throw new SemanticException("The " + op + - " operator must have numeric or boolean operands, not type " + - l + ".", left.position()); + final boolean isL = !ts.isImplicitCastValid(l, ts.Long(), context); + final boolean isR = !ts.isImplicitCastValid(r, ts.Long(), context); + if (isL || isR) { + throw new SemanticException("Operator must have numeric or boolean operands.", (isL ? left : right).position()); } - - if (! ts.isImplicitCastValid(r, ts.Long(), context)) { - throw new SemanticException("The " + op + - " operator must have numeric or boolean operands, not type " + - r + ".", right.position()); - } } if (op == SUB || op == MUL || op == DIV || op == MOD) { - if (! l.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - l + ".", left.position()); + final boolean isL = !l.isNumeric(); + final boolean isR = !r.isNumeric(); + if (isL || isR) { + throw new SemanticException("Operator must have numeric operands.", (isL ? left : right).position()); } - - if (! r.isNumeric()) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - r + ".", right.position()); - } } if (op == SHL || op == SHR || op == USHR) { - if (! ts.isImplicitCastValid(l, ts.Long(), context)) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - l + ".", left.position()); + final boolean isL = !ts.isImplicitCastValid(l, ts.Long(), context); + final boolean isR = !ts.isImplicitCastValid(r, ts.Long(), context); + if (isL || isR) { + throw new SemanticException("Operator must have numeric operands.", (isL ? left:right).position()); } - - if (! ts.isImplicitCastValid(r, ts.Long(), context)) { - throw new SemanticException("The " + op + - " operator must have numeric operands, not type " + - r + ".", right.position()); - } } if (op == SHL || op == SHR || op == USHR) { Modified: trunk/x10.compiler/src/polyglot/ast/Call_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Call_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Call_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -230,9 +230,7 @@ boolean staticContext = (this.target instanceof TypeNode); if (staticContext && !mi.flags().isStatic()) { - throw new SemanticException("Cannot call non-static method " + this.name.id() - + " of " + target.type() + " in static " - + "context.", this.position()); + throw new SemanticException("Cannot call non-static method " + name.id() + " of " + target.type() + " in static context.", position()); } // If the target is super, but the method is abstract, then complain. Modified: trunk/x10.compiler/src/polyglot/ast/CanonicalTypeNode_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/CanonicalTypeNode_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/CanonicalTypeNode_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -36,9 +36,7 @@ ClassType ct = type.get().toClass(); if (ct.isTopLevel() || ct.isMember()) { if (! ts.classAccessible(ct.def(), tc.context())) { - throw new SemanticException("Cannot access class \"" + - ct + "\" from the body of \"" + - tc.context().currentClass() + "\".", position()); + throw new SemanticException("Cannot access class \"" + ct + "\" from the body of \"" + tc.context().currentClass() + "\".", position()); } } } Modified: trunk/x10.compiler/src/polyglot/ast/Case_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Case_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Case_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -91,9 +91,7 @@ TypeSystem ts = tc.typeSystem(); if (! ts.isImplicitCastValid(expr.type(), ts.Int(), tc.context()) && ! ts.isImplicitCastValid(expr.type(), ts.Char(), tc.context())) { - throw new SemanticException( - "Case label must be an byte, char, short, or int.", - position()); + throw new SemanticException("Case label must be an byte, char, short, or int.",position()); } return this; @@ -117,8 +115,7 @@ } } - throw new SemanticException("Case label must be an integral constant.", - position()); + throw new SemanticException("Case label must be an integral constant.",position()); } public Type childExpectedType(Expr child, AscriptionVisitor av) { Modified: trunk/x10.compiler/src/polyglot/ast/Cast_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Cast_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Cast_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -87,10 +87,7 @@ TypeSystem ts = tc.typeSystem(); if (! ts.isCastValid(expr.type(), castType.type(), tc.context())) { - throw new SemanticException("Cannot cast the expression of type \"" - + expr.type() + "\" to type \"" - + castType.type() + "\".", - position()); + throw new SemanticException("Cannot cast the expression of type \""+ expr.type() + "\" to type \""+ castType.type() + "\".", position()); } return type(castType.type()); Modified: trunk/x10.compiler/src/polyglot/ast/Catch_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Catch_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Catch_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -88,9 +88,7 @@ TypeSystem ts = tc.typeSystem(); if (! catchType().isThrowable()) { - throw new SemanticException( - "Can only throw subclasses of \"" + - ts.Throwable() + "\".", formal.position()); + throw new SemanticException("Can only throw subclasses of \"" +ts.Throwable() + "\".", formal.position()); } Modified: trunk/x10.compiler/src/polyglot/ast/ClassBody_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ClassBody_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ClassBody_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -85,8 +85,7 @@ FieldDef fj = (FieldDef) l.get(j); if (fi.name().equals(fj.name())) { - Errors.issue(tc.job(), - new SemanticException("Duplicate field \"" + fj + "\".", fj.position())); + reportDuplicate(fj,tc); } } } @@ -107,7 +106,7 @@ ConstructorInstance tj = cj.asInstance(); if (ti.hasFormals(tj.formalTypes(), tc.context())) { - Errors.issue(tc.job(), new SemanticException("Duplicate constructor \"" + cj + "\".", cj.position())); + reportDuplicate(cj,tc); } } } @@ -129,7 +128,7 @@ MethodInstance tj = mj.asInstance(); if (ti.isSameMethod(tj, tc.context())) { - Errors.issue(tc.job(), new SemanticException("Duplicate method \"" + mj + "\".", mj.position())); + reportDuplicate(mj,tc); } } } @@ -148,13 +147,17 @@ if (mi instanceof Named && mj instanceof Named) { if (((Named) mi).name().equals(((Named) mj).name())) { - Errors.issue(tc.job(), new SemanticException("Duplicate member type \"" + mj + "\".", mj.position())); + reportDuplicate(mj,tc); } } } } } + private void reportDuplicate(TypeObject def, ContextVisitor tc) { + new Errors.DuplicateMember(def).issue(tc.job()); + } + protected boolean isSameMethod(TypeSystem ts, MethodInstance mi, MethodInstance mj, Context context) { return mi.isSameMethod(mj, context); Modified: trunk/x10.compiler/src/polyglot/ast/ClassDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ClassDecl_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ClassDecl_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -10,7 +10,6 @@ import java.util.*; -import polyglot.frontend.Goal; import polyglot.main.Report; import polyglot.types.*; import polyglot.util.*; @@ -263,9 +262,7 @@ if (t instanceof UnknownType) throw new SemanticException(); // already reported if (! t.isClass() || t.toClass().flags().isInterface()) { - throw new SemanticException("Cannot extend type " + - t + "; not a class.", - superClass != null ? superClass.position() : position()); + throw new SemanticException("Cannot extend type " +t + "; not a class.",superClass != null ? superClass.position() : position()); } ts.checkCycles((ReferenceType) t); } @@ -275,8 +272,7 @@ assert ! (t instanceof UnknownType); if (! t.isClass() || ! t.toClass().flags().isInterface()) { String s = type.flags().isInterface() ? "extend" : "implement"; - throw new SemanticException("Cannot " + s + " type " + t + "; not an interface.", - position()); + throw new SemanticException("Cannot " + s + " type " + t + "; not an interface.",position()); } ts.checkCycles((ReferenceType) t); } @@ -439,10 +435,7 @@ Name cname = container.name(); if (cname.equals(name)) { - Errors.issue(tc.job(), new SemanticException("Cannot declare member " + - "class \"" + type.fullName() + - "\" inside class with the " + - "same name.", position())); + new Errors.SameNameClass(type,position()).issue(tc.job()); } } if (container.isNested()) { @@ -467,10 +460,7 @@ if (nm instanceof Type) { Type another = (Type) nm; if (another.isClass() && another.toClass().isLocal()) { - Errors.issue(tc.job(), new SemanticException("Cannot declare local " + - "class \"" + this.type + "\" within the same " + - "method, constructor or initializer as another " + - "local class of the same name.", position())); + Errors.issue(tc.job(), new Errors.SameNameLocal(type, position())); } } } catch (SemanticException e) { @@ -483,31 +473,31 @@ if (type.isMember() && type.flags().isInterface() && type.outer().isInnerClass()) { // it's a member interface in an inner class. Errors.issue(tc.job(), - new SemanticException("Inner classes cannot declare member interfaces.", position())); + new Errors.InnerDeclaredInterface(type, position())); } // Make sure that static members are not declared inside inner classes if (type.isMember() && type.flags().isStatic() && type.outer().isInnerClass()) { Errors.issue(tc.job(), - new SemanticException("Inner classes cannot declare static member classes.", position())); + new Errors.InnerDeclaredStatic(type, position())); } if (type.superClass() != null && isValidType(type.superClass())) { if (! type.superClass().isClass() || type.superClass().toClass().flags().isInterface()) { Errors.issue(tc.job(), - new SemanticException("Cannot extend non-class \"" + type.superClass() + "\".", + new Errors.ExtendedNonClass(type, position())); } if (type.superClass().toClass().flags().isFinal()) { Errors.issue(tc.job(), - new SemanticException("Cannot extend final class \"" + type.superClass() + "\".", + new Errors.ExtendedFinalClass(type, position())); } if (objectIsRoot() && type.typeEquals(ts.Object(), tc.context())) { Errors.issue(tc.job(), - new SemanticException("Class \"" + this.type + "\" cannot have a superclass.", + new Errors.CannotHaveSuperclass(type, superClass.position())); } } @@ -518,13 +508,13 @@ if (isValidType(t) && ! (t.isClass() && t.toClass().flags().isInterface())) { Errors.issue(tc.job(), - new SemanticException("Superinterface " + t + " of " + type + " is not an interface.", + new Errors.SuperInterfaceNotInterface(t,type, tn.position())); } if (objectIsRoot() && type.typeEquals(ts.Object(), tc.context())) { Errors.issue(tc.job(), - new SemanticException("Class " + this.type + " cannot have a superinterface.", + new Errors.ClassCannotHaveSuperInterface(type, tn.position())); } } Modified: trunk/x10.compiler/src/polyglot/ast/Conditional_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Conditional_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Conditional_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -105,9 +105,7 @@ Type t2 = e2.type(); if (! cond.type().isBoolean()) { - throw new SemanticException( - "Condition of ternary expression must be of type boolean.", - cond.position()); + throw new SemanticException("Condition of ternary expression must be of type boolean.",cond.position()); } // From the JLS, section: @@ -172,8 +170,7 @@ } } - throw new SemanticException("Could not determine type of ternary conditional expression; cannot assign " + t1 + " to " + t2 + " or vice versa.", - position()); + throw new SemanticException("Could not determine type of ternary conditional expression; cannot assign " + t1 + " to " + t2 + " or vice versa.",position()); } public Type childExpectedType(Expr child, AscriptionVisitor av) { Modified: trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ConstructorCall_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -148,33 +148,24 @@ // } if (qualifier != null) { if (kind != SUPER) { - throw new SemanticException("Can only qualify a \"super\"" + - "constructor invocation.", - position()); + throw new SemanticException("Can only qualify a \"super\" constructor invocation.", position()); } if (!superType.isClass() || !superType.toClass().isInnerClass() || superType.toClass().inStaticContext()) { - throw new SemanticException("The class \"" + superType + "\"" + - " is not an inner class, or was declared in a static " + - "context; a qualified constructor invocation cannot " + - "be used.", position()); + throw new SemanticException("A qualified constructor invocation can be used only for non-static inner classes.", position()); } Type qt = qualifier.type(); if (! qt.isClass() || !qt.isSubtype(superType.toClass().outer(), c)) { - throw new SemanticException("The type of the qualifier " + - "\"" + qt + "\" does not match the immediately enclosing " + - "class of the super class \"" + - superType.toClass().outer() + "\".", qualifier.position()); + throw new SemanticException("The type of the qualifier \"" + qt + "\" does not match the immediately enclosing class of the super class \"" +superType.toClass().outer() + "\".", qualifier.position()); } } if (kind == SUPER) { if (! superType.isClass()) { - throw new SemanticException("Super type of " + ct + - " is not a class.", position()); + throw new SemanticException("Super type of " + ct +" is not a class.", position()); } Expr q = qualifier; @@ -200,13 +191,10 @@ } if (e == null) { - throw new SemanticException(ct + " must have an enclosing instance" + - " that is a subtype of " + superContainer, position()); + throw new SemanticException(ct + " must have an enclosing instance that is a subtype of " + superContainer, position()); } if (e == ct) { - throw new SemanticException(ct + " is a subtype of " + superContainer + - "; an enclosing instance that is a subtype of " + superContainer + - " must be specified in the super constructor call.", position()); + throw new SemanticException(ct + " is a subtype of " + superContainer + "; an enclosing instance that is a subtype of " + superContainer +" must be specified in the super constructor call.", position()); } } Modified: trunk/x10.compiler/src/polyglot/ast/ConstructorDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/ConstructorDecl_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/ConstructorDecl_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -224,22 +224,18 @@ if (ct.flags().isInterface()) { Errors.issue(tc.job(), - new SemanticException("Cannot declare a constructor inside an interface.", - position())); + new SemanticException("Cannot declare a constructor inside an interface.",position())); } if (ct.isAnonymous()) { Errors.issue(tc.job(), - new SemanticException("Cannot declare a constructor inside an anonymous class.", - position())); + new SemanticException("Cannot declare a constructor inside an anonymous class.",position())); } Name ctName = ct.name(); if (! ctName.equals(name.id())) { - Errors.issue(tc.job(),new SemanticException("Constructor name \"" + name + - "\" does not match name of containing class \"" + - ctName + "\".", position())); + Errors.issue(tc.job(),new SemanticException("Constructor name \"" + name +"\" does not match name of containing class \"" + ctName + "\".", position())); } Flags flags = flags().flags(); Modified: trunk/x10.compiler/src/polyglot/ast/Do_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Do_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Do_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -82,9 +82,7 @@ TypeSystem ts = tc.typeSystem(); if (! ts.typeEquals(cond.type(), ts.Boolean(), tc.context())) { - throw new SemanticException( - "Condition of do statement must have boolean type.", - cond.position()); + throw new SemanticException("Condition of do statement must have boolean type.",cond.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/FieldDecl_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -305,12 +305,7 @@ ! ts.typeEquals(init.type(), type.type(), tc.context()) && ! ts.numericConversionValid(type.type(), init.constantValue(), tc.context())) { - throw new SemanticException("The type of the variable " + - "initializer \"" + init.type() + - "\" does not match that of " + - "the declaration \"" + - type.type() + "\".", - init.position()); + throw new SemanticException("The type of the variable initializer \"" + init.type() +"\" does not match that of the declaration \"" +type.type() + "\".",init.position()); } } } @@ -350,9 +345,7 @@ container.isInnerClass()) { // it's a static field in an inner class. if (!flags.isFinal() || init == null || !init.isConstant()) { - Errors.issue(tc.job(), new SemanticException("Inner classes cannot declare " + - "static fields, unless they are compile-time " + - "constant fields.", position())); + Errors.issue(tc.job(), new SemanticException("Inner classes cannot declare static fields, unless they are compile-time constant fields.", position())); } } } Modified: trunk/x10.compiler/src/polyglot/ast/For_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/For_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/For_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -138,9 +138,7 @@ if (cond != null && ! ts.isImplicitCastValid(cond.type(), ts.Boolean(), tc.context())) { - throw new SemanticException( - "The condition of a for statement must have boolean type.", - cond.position()); + throw new SemanticException("The condition of a for statement must have boolean type.",cond.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Formal_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Formal_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Formal_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -158,10 +158,7 @@ } if (outerLocal != null && ! li.equals(outerLocal.def()) && c.isLocal(li.name())) { - throw new SemanticException( - "Local variable \"" + name + "\" multiply defined. " - + "Previous definition at " + outerLocal.position() + ".", - position()); + throw new SemanticException("Local variable \"" + name + "\" multiply defined. Previous definition at " + outerLocal.position() + ".",position()); } TypeSystem ts = tc.typeSystem(); Modified: trunk/x10.compiler/src/polyglot/ast/If_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/If_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/If_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -100,9 +100,7 @@ TypeSystem ts = tc.typeSystem(); if (! ts.typeEquals(cond.type(), ts.Boolean(), tc.context())) { - throw new SemanticException( - "Condition of if statement must have boolean type.", - cond.position()); + throw new SemanticException("Condition of if statement must have boolean type.",cond.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Initializer_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Initializer_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Initializer_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -191,8 +191,7 @@ if (flags.isStatic() && initializerDef().container().get().toClass().isInnerClass()) { // it's a static initializer in an inner class. - throw new SemanticException("Inner classes cannot declare " + - "static initializers.", this.position()); + throw new SemanticException("Inner classes cannot declare static initializers.", this.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Instanceof_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -84,15 +84,11 @@ TypeSystem ts = tc.typeSystem(); if (! compareType.type().isReference()) { - throw new SemanticException( - "Type operand " + compareType.type() + " must be a reference type.", - compareType.position()); + throw new SemanticException("Type operand " + compareType.type() + " must be a reference type.",compareType.position()); } if (! ts.isCastValid(expr.type(), compareType.type(), tc.context())) { - throw new SemanticException( - "Expression operand type " + expr.type() + " incompatible with type operand " + compareType.type() + ".", - expr.position()); + throw new SemanticException("Expression operand type " + expr.type() + " incompatible with type operand " + compareType.type() + ".",expr.position()); } return type(ts.Boolean()); Modified: trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/LocalDecl_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -185,10 +185,7 @@ } if (outerLocal != null && c.isLocal(li.name())) { - throw new SemanticException( - "Local variable \"" + name + "\" multiply defined. " - + "Previous definition at " + outerLocal.position() + ".", - position()); + throw new SemanticException("Local variable \"" + name + "\" multiply defined. Previous definition at " + outerLocal.position() + ".", position()); } return super.typeCheckEnter(tc); @@ -213,12 +210,7 @@ if (! ts.isImplicitCastValid(init.type(), type.type(), tc.context()) && ! ts.typeEquals(init.type(), type.type(), tc.context()) && ! ts.numericConversionValid(type.type(), init.constantValue(), tc.context())) { - throw new SemanticException("The type of the variable " + - "initializer \"" + init.type() + - "\" does not match that of " + - "the declaration \"" + - type.type() + "\".", - init.position()); + throw new SemanticException("The type of the variable initializer \"" + init.type() + "\" does not match that of the declaration \"" + type.type() + "\".", init.position()); } } } Modified: trunk/x10.compiler/src/polyglot/ast/Local_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Local_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Local_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -104,10 +104,7 @@ if (!c.isLocal(li.name())) { // this local is defined in an outer class if (!li.flags().isFinal()) { - throw new SemanticException("Local variable \"" + li.name() + - "\" is accessed from an inner class, and must be declared " + - "final.", - this.position()); + throw new SemanticException("Local variable \"" + li.name() + "\" is accessed from an inner class, and must be declared final.",this.position()); } } Modified: trunk/x10.compiler/src/polyglot/ast/NewArray_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/NewArray_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/NewArray_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -123,8 +123,7 @@ for (Expr expr : dims) { if (! ts.isImplicitCastValid(expr.type(), ts.Int(), tc.context())) { - throw new SemanticException("Array dimension must be an integer.", - expr.position()); + throw new SemanticException("Array dimension must be an integer.", expr.position()); } } Modified: trunk/x10.compiler/src/polyglot/ast/New_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/New_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/New_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -346,8 +346,7 @@ } if (outer == null) { - throw new SemanticException("Could not find non-static member class \"" + - name + "\".", position()); + throw new SemanticException("Could not find non-static member class \"" + name + "\".", position()); } // Create the qualifier. @@ -411,9 +410,7 @@ Type qt = qualifier.type(); if (! qt.isClass()) { - throw new SemanticException( - "Cannot instantiate member class of a non-class type.", - qualifier.position()); + throw new SemanticException("Cannot instantiate member class of a non-class type.", qualifier.position()); } // Disambiguate the type node as a member of the qualifier type. @@ -423,9 +420,7 @@ // instantiated must be inner. if (! ct.isInnerClass()) { if (!(qualifier instanceof Special)) // Yoav added "this" qualifier for non-static anonymous classes - throw new SemanticException( - "Cannot provide a containing instance for non-inner class " + - ct.fullName() + ".", qualifier.position()); + throw new SemanticException("Cannot provide a containing instance for non-inner class " + ct.fullName() + ".", qualifier.position()); } } else { @@ -434,9 +429,7 @@ if (ct.isMember()) { for (ClassType t = ct; t.isMember(); t = t.outer()) { if (! t.flags().isStatic()) { - throw new SemanticException( - "Cannot allocate non-static member class \"" + - t + "\".", position()); + throw new SemanticException("Cannot allocate non-static member class \"" +t + "\".", position()); } } } @@ -448,27 +441,20 @@ if (this.body == null) { if (ct.flags().isInterface()) { - throw new SemanticException( - "Cannot instantiate an interface.", position()); + throw new SemanticException("Cannot instantiate an interface.", position()); } if (ct.flags().isAbstract()) { - throw new SemanticException( - "Cannot instantiate an abstract class.", position()); + throw new SemanticException("Cannot instantiate an abstract class.", position()); } } else { if (ct.flags().isFinal()) { - throw new SemanticException( - "Cannot create an anonymous subclass of a final class.", - position()); + throw new SemanticException("Cannot create an anonymous subclass of a final class.", position()); } if (ct.flags().isInterface() && ! arguments.isEmpty()) { - throw new SemanticException( - "Cannot pass arguments to an anonymous class that " + - "implements an interface.", - arguments.get(0).position()); + throw new SemanticException("Cannot pass arguments to an anonymous class that implements an interface.",arguments.get(0).position()); } } } Modified: trunk/x10.compiler/src/polyglot/ast/Return_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Return_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Return_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -67,15 +67,12 @@ CodeDef ci = c.currentCode(); if (ci instanceof InitializerDef) { - throw new SemanticException( - "Cannot return from an initializer block.", position()); + throw new SemanticException("Cannot return from an initializer block.", position()); } if (ci instanceof ConstructorDef) { if (expr != null) { - throw new SemanticException( - "Cannot return a value from " + ci + ".", - position()); + throw new SemanticException("Cannot return a value from " + ci + ".",position()); } return this; @@ -95,16 +92,14 @@ if (returnType.isVoid()) { if (expr != null) { - throw new SemanticException("Cannot return a value from " + - fi + ".", position()); + throw new SemanticException("Cannot return a value from " + fi + ".", position()); } else { return this; } } else if (expr == null) { - throw new SemanticException("Must return a value from " + - fi + ".", position()); + throw new SemanticException("Must return a value from " + fi + ".", position()); } if (ts.isImplicitCastValid(expr.type(), returnType, c)) { @@ -115,8 +110,7 @@ return this; } - throw new SemanticException("Cannot return expression of type " + - expr.type() + " from " + fi + ".", expr.position()); + throw new SemanticException("Cannot return expression of type " +expr.type() + " from " + fi + ".", expr.position()); } throw new SemanticException("Cannot return from this context.", position()); Modified: trunk/x10.compiler/src/polyglot/ast/SourceFile_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/SourceFile_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/SourceFile_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -176,8 +176,7 @@ Name s = d.name().id(); if (names.contains(s)) { - throw new SemanticException("Duplicate declaration: \"" + s + - "\".", d.position()); + throw new SemanticException("Duplicate declaration: \"" + s + "\".", d.position()); } names.add(s); Modified: trunk/x10.compiler/src/polyglot/ast/Special_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Special_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Special_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -95,10 +95,7 @@ t = qualifier.type().toClass(); if (!c.currentClass().hasEnclosingInstance(t)) { - throw new SemanticException("The nested class \"" + - c.currentClass() + "\" does not have " + - "an enclosing instance of type \"" + - t + "\".", qualifier.position()); + throw new SemanticException("The nested class \"" + c.currentClass() + "\" does not have an enclosing instance of type \"" +t + "\".", qualifier.position()); } } else { @@ -108,9 +105,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 " + - "member or refer to \"this\" or \"super\" " + - "from a static context.", this.position()); + throw new SemanticException("Cannot access a non-static member or refer to \"this\" or \"super\" from a static context.", this.position()); } if (kind == THIS) { Modified: trunk/x10.compiler/src/polyglot/ast/Switch_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Switch_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Switch_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -87,8 +87,7 @@ Context context = tc.context(); if (! ts.isImplicitCastValid(expr.type(), ts.Int(), context) && ! ts.isImplicitCastValid(expr.type(), ts.Char(), context)) { - throw new SemanticException("Switch index must be an integer.", - position()); + throw new SemanticException("Switch index must be an integer.", position()); } return this; @@ -119,8 +118,7 @@ } if (labels.contains(key)) { - throw new SemanticException("Duplicate case label: " + - str + ".", c.position()); + throw new SemanticException("Duplicate case label: " +str + ".", c.position()); } labels.add(key); Modified: trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Synchronized_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -80,9 +80,7 @@ TypeSystem ts = tc.typeSystem(); if (! ts.isSubtype(expr.type(), ts.Object(), tc.context()) ) { - throw new SemanticException( - "Cannot synchronize on an expression of type \"" + - expr.type() + "\".", expr.position()); + throw new SemanticException("Cannot synchronize on an expression of type \"" + expr.type() + "\".", expr.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Throw_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Throw_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Throw_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -62,9 +62,7 @@ /** Type check the statement. */ public Node typeCheck(ContextVisitor tc) throws SemanticException { if (! expr.type().isThrowable()) { - throw new SemanticException( - "Can only throw subclasses of \"" + - tc.typeSystem().Throwable() + "\".", expr.position()); + throw new SemanticException("Can only throw subclasses of \"" +tc.typeSystem().Throwable() + "\".", expr.position()); } return this; Modified: trunk/x10.compiler/src/polyglot/ast/Try_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Try_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Try_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -150,9 +150,7 @@ // Check if the exception has already been caught. if (caught.contains(catchType)) { - throw new SemanticException("The exception \"" + - catchType + "\" has been caught by an earlier catch block.", - cb.position()); + throw new SemanticException("The exception \"" +catchType + "\" has been caught by an earlier catch block.",cb.position()); } caught.add(catchType); Modified: trunk/x10.compiler/src/polyglot/ast/Unary_c.java =================================================================== --- trunk/x10.compiler/src/polyglot/ast/Unary_c.java 2010-10-01 22:54:42 UTC (rev 16871) +++ trunk/x10.compiler/src/polyglot/ast/Unary_c.java 2010-10-01 23:22:06 UTC (rev 16872) @@ -82,19 +82,15 @@ op == PRE_INC || op == PRE_DEC) { if (! expr.type().isNumeric()) { - throw new SemanticException("Operand of " + op + - " operator must be numeric.", expr.position()); + throw new SemanticException("Operand must be numeric.", expr.position()); } if (! (expr instanceof Variable)) { - throw new SemanticException("Operand of " + op + - " operator must be a variable.", expr.position()); + throw new SemanticException("Operand must be a variable.", expr.position()); } if (((Variable) expr).flags().isFinal()) { -... [truncated message content] |
From: <dgr...@us...> - 2010-10-02 18:01:48
|
Revision: 16883 http://x10.svn.sourceforge.net/x10/?rev=16883&view=rev Author: dgrove-oss Date: 2010-10-02 18:01:42 +0000 (Sat, 02 Oct 2010) Log Message: ----------- WIP on 2.1 at variable access semantics for C++ backend. AtAndBack, AtAndBack2, and AtAndBackWithObject now all pass. May have to do a little more template/operator trickery to handle variables of non-built in struct types. Will write test cases to check, and fix as needed. NOTE: Codegen is assuming that the front-end will enforce static locality of variable accesses. If a read/write to a local var happens in an improper place, the generated code will happily dereference an invalid pointer from another place's address space and either fail immediately with a SIGSEGV (good) or silently corrupt the current place's memory (less good). Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-02 17:47:50 UTC (rev 16882) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-02 18:01:42 UTC (rev 16883) @@ -928,9 +928,11 @@ VarInstance<?> var = vars.get(i); VarDef def = var.def(); Type t = var.type(); - String type = translateType(t, true); + String type; if ((writable && !var.name().toString().equals(THIS)) || refs.contains(var)) { - type = make_boxed_ref(type); + type = make_boxed_ref(translateType(t, false)); + } else { + type = translateType(t, true); } String name = var.name().toString(); if (saved_this_mechanism && name.equals(THIS)) { Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-02 17:47:50 UTC (rev 16882) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-02 18:01:42 UTC (rev 16883) @@ -4112,7 +4112,7 @@ name = SAVED_THIS; else name = mangled_non_method_name(name); if (refs.contains(var)) { - inc.write(make_boxed_ref(Emitter.translateType(var.type(), true)) + " " + name); + inc.write(make_boxed_ref(Emitter.translateType(var.type(), false)) + " " + name); } else { inc.write(Emitter.translateType(var.type(), true) + " " + name); } @@ -4242,8 +4242,11 @@ for (VarInstance<?> var : c.variables) { VarDef def = var.def(); - if ((def instanceof X10LocalDef) && ((X10LocalDef)def).isAsyncInit()) { - refs.add(var); + if ((def instanceof X10LocalDef)) { + X10LocalDef ld = ((X10LocalDef)def); + if (ld.isAsyncInit() || !ld.flags().isFinal()) { + refs.add(var); + } } } return refs; @@ -4277,9 +4280,11 @@ for (int i = 0; i < c.variables.size(); i++) { VarInstance<?> var = (VarInstance<?>) c.variables.get(i); Type t = var.type(); - String type = Emitter.translateType(t, true); + String type; if (refs.contains(var)) { - type = make_boxed_ref(type); + type = make_boxed_ref(Emitter.translateType(t, false)); + } else { + type = Emitter.translateType(t, true); } String name = var.name().toString(); if (name.equals(THIS)) { Modified: trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h 2010-10-02 17:47:50 UTC (rev 16882) +++ trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h 2010-10-02 18:01:42 UTC (rev 16883) @@ -30,9 +30,17 @@ * back to the 64 bit machine and accessing it. Therefore we * can't store it is a simple reference value, but have to wrap * it up in an x10_long (64 bits on all platforms). + * + * The interplay of boxed_ref and ref is somewhat odd. + * We don't want boxed_ref<ref<T>> or ref<boxed_ref<T>> + * to ever exist, so we end up doing some off looking operations + * in the constructors and operator= of boxed_ref to prevent + * that from happening. + * */ template<class T> class boxed_ref { - protected: +// protected: + public: // Actually contains a T*, but always stored as 64 bits even on 32 bit machines x10_long _val; public: @@ -44,6 +52,8 @@ GPUSAFE boxed_ref(T const *val) : _val((x10_long)(size_t)(void*)val) { } + GPUSAFE boxed_ref(ref<T> const *val) : _val((x10_long)(size_t)(void*)val) { } + GPUSAFE const boxed_ref<T>& operator=(const boxed_ref<T>& _ref) { _val = _ref._val; return *this; @@ -54,10 +64,38 @@ return val; } - operator T() { + T* operator=(const ref<T> &ref) { + T* value = ref.operator->(); + *((T**)(size_t)_val) = value; + return value; + } + + // &<boxed_ref<T> can simply be the thing itself. + // Of dubious taste, but lets us avoid trying to + // special case codegen of closures to detect when + // the closure is the "first" to capture a variable + // vs. when it is re-capturing something that has already + // been captured. + boxed_ref<T> operator&() { + return *this; + } + + GPUSAFE operator T() { return *((T*)(size_t)_val); } + GPUSAFE operator ref<T>() { + return ref<T>(*(T**)(size_t)_val); + } + + T& GPUSAFE operator*() const { + return *(T*)_val; + } + + T* GPUSAFE operator->() const { + return *((T**)(size_t)_val); + } + x10_long capturedAddress() { return _val; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-03 02:27:48
|
Revision: 16886 http://x10.svn.sourceforge.net/x10/?rev=16886&view=rev Author: dgrove-oss Date: 2010-10-03 02:27:41 +0000 (Sun, 03 Oct 2010) Log Message: ----------- Finished implementation of captured lvals for ats. AtAndBack, AtAndBack2, AtAndBackWithObject and AtAndBackWithStruct all pass with the C++ backend. Key change was to introduce separate classes to hold captured struct and captured ref lvals. The issue is that with refs, a ref<C> really contains a C*, not a C. So a captured_lval<C> needs to contain a C**, but a captured_lval<S> where S is a struct must contain an S*. Attempting to jam both a T* and a T** into the same container class was just not a good idea, so now we have distinct containers for the two different cases. Modified Paths: -------------- trunk/x10.compiler/src/x10cpp/visit/Emitter.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java trunk/x10.runtime/src-cpp/x10aux/serialization.h trunk/x10.runtime/src-cpp/x10rt.h Added Paths: ----------- trunk/x10.runtime/src-cpp/x10aux/captured_lval.h Removed Paths: ------------- trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h Modified: trunk/x10.compiler/src/x10cpp/visit/Emitter.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.compiler/src/x10cpp/visit/Emitter.java 2010-10-03 02:27:41 UTC (rev 16886) @@ -27,7 +27,7 @@ import static x10cpp.visit.SharedVarsMethods.THIS; import static x10cpp.visit.SharedVarsMethods.chevrons; import static x10cpp.visit.SharedVarsMethods.make_ref; -import static x10cpp.visit.SharedVarsMethods.make_boxed_ref; +import static x10cpp.visit.SharedVarsMethods.make_captured_lval; import java.util.ArrayList; import java.util.Iterator; @@ -930,7 +930,7 @@ Type t = var.type(); String type; if ((writable && !var.name().toString().equals(THIS)) || refs.contains(var)) { - type = make_boxed_ref(translateType(t, false)); + type = make_captured_lval(t); } else { type = translateType(t, true); } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-03 02:27:41 UTC (rev 16886) @@ -45,7 +45,7 @@ import static x10cpp.visit.SharedVarsMethods.getId; import static x10cpp.visit.SharedVarsMethods.getUniqueId_; import static x10cpp.visit.SharedVarsMethods.make_ref; -import static x10cpp.visit.SharedVarsMethods.make_boxed_ref; +import static x10cpp.visit.SharedVarsMethods.make_captured_lval; import static x10cpp.visit.SharedVarsMethods.refsAsPointers; import java.util.ArrayList; @@ -4112,7 +4112,7 @@ name = SAVED_THIS; else name = mangled_non_method_name(name); if (refs.contains(var)) { - inc.write(make_boxed_ref(Emitter.translateType(var.type(), false)) + " " + name); + inc.write(make_captured_lval(var.type()) + " " + name); } else { inc.write(Emitter.translateType(var.type(), true) + " " + name); } @@ -4282,7 +4282,7 @@ Type t = var.type(); String type; if (refs.contains(var)) { - type = make_boxed_ref(Emitter.translateType(t, false)); + type = make_captured_lval(t); } else { type = Emitter.translateType(t, true); } Modified: trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.compiler/src/x10cpp/visit/SharedVarsMethods.java 2010-10-03 02:27:41 UTC (rev 16886) @@ -29,6 +29,7 @@ import polyglot.types.TypeSystem; import polyglot.types.VarInstance; import x10.ast.ConstantDistMaker_c; +import x10.types.X10ClassType; import x10.types.X10MethodInstance; import x10.types.X10ParsedClassType; import x10.types.X10TypeSystem; @@ -112,8 +113,12 @@ return "x10aux::ref"+chevrons(type); } - public static String make_boxed_ref(String type) { - return "x10aux::boxed_ref"+chevrons(type); + public static String make_captured_lval(Type type) { + if (type.isClass() && !((X10ClassType)type.toClass()).isX10Struct()) { + return "x10aux::captured_ref_lval"+chevrons(Emitter.translateType(type, false)); + } else { + return "x10aux::captured_struct_lval"+chevrons(Emitter.translateType(type, false)); + } } static String closure_name(String prefix, int id) { Deleted: trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h 2010-10-03 02:27:41 UTC (rev 16886) @@ -1,111 +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. - */ - -#ifndef X10BOXEDREF_H -#define X10BOXEDREF_H - -#include <cstdlib> -#include <cassert> - -#include <x10aux/config.h> - -namespace x10aux { - - /** - * This class lets us wrap the address of a captured stack - * location from a lexically enclosing scope in a way that lets - * uses of the boxed_ref from the body of the closure apply - * still refer to it as if it was a simple stack variable. - * The main reason this requires some machination is that we have - * to be able to support captuing an address on a 64-bit machine, - * transfering it to a 32 bit machine, and then transfering it - * back to the 64 bit machine and accessing it. Therefore we - * can't store it is a simple reference value, but have to wrap - * it up in an x10_long (64 bits on all platforms). - * - * The interplay of boxed_ref and ref is somewhat odd. - * We don't want boxed_ref<ref<T>> or ref<boxed_ref<T>> - * to ever exist, so we end up doing some off looking operations - * in the constructors and operator= of boxed_ref to prevent - * that from happening. - * - */ - template<class T> class boxed_ref { -// protected: - public: - // Actually contains a T*, but always stored as 64 bits even on 32 bit machines - x10_long _val; - public: - GPUSAFE boxed_ref() { } // ok to not initialize; compiler will ensure we never read unitialized boxed_ref - - GPUSAFE boxed_ref(const boxed_ref<T>& _ref) : _val(_ref._val) { } - - GPUSAFE boxed_ref(T const &val) : _val((x10_long)(size_t)(void*)&val) { } - - GPUSAFE boxed_ref(T const *val) : _val((x10_long)(size_t)(void*)val) { } - - GPUSAFE boxed_ref(ref<T> const *val) : _val((x10_long)(size_t)(void*)val) { } - - GPUSAFE const boxed_ref<T>& operator=(const boxed_ref<T>& _ref) { - _val = _ref._val; - return *this; - } - - T operator=(const T &val) { - *((T*)(size_t)_val) = val; - return val; - } - - T* operator=(const ref<T> &ref) { - T* value = ref.operator->(); - *((T**)(size_t)_val) = value; - return value; - } - - // &<boxed_ref<T> can simply be the thing itself. - // Of dubious taste, but lets us avoid trying to - // special case codegen of closures to detect when - // the closure is the "first" to capture a variable - // vs. when it is re-capturing something that has already - // been captured. - boxed_ref<T> operator&() { - return *this; - } - - GPUSAFE operator T() { - return *((T*)(size_t)_val); - } - - GPUSAFE operator ref<T>() { - return ref<T>(*(T**)(size_t)_val); - } - - T& GPUSAFE operator*() const { - return *(T*)_val; - } - - T* GPUSAFE operator->() const { - return *((T**)(size_t)_val); - } - - x10_long capturedAddress() { - return _val; - } - - void setCapturedAddress(x10_long addr) { - _val = addr; - } - }; -} - -// vim:tabstop=4:shiftwidth=4:expandtab - -#endif Copied: trunk/x10.runtime/src-cpp/x10aux/captured_lval.h (from rev 16883, trunk/x10.runtime/src-cpp/x10aux/boxed_ref.h) =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/captured_lval.h (rev 0) +++ trunk/x10.runtime/src-cpp/x10aux/captured_lval.h 2010-10-03 02:27:41 UTC (rev 16886) @@ -0,0 +1,142 @@ +/* + * 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. + */ + +#ifndef X10CAPTURED_LVAL_H +#define X10CAPTURED_LVAL_H + +#include <cstdlib> +#include <cassert> + +#include <x10aux/config.h> + +namespace x10 { namespace lang { class Reference; } } + +namespace x10aux { + + /** + * This class lets us wrap the address of a captured stack + * location from a lexically enclosing scope in a way that lets + * uses of the captured_lval from the body of the closure apply + * still refer to it as if it was a simple stack variable. + * The main reason this requires some machination is that we have + * to be able to support captuing an address on a 64-bit machine, + * transfering it to a 32 bit machine, and then transfering it + * back to the 64 bit machine and accessing it. Therefore we + * can't store it is a simple reference value, but have to wrap + * it up in an x10_long (64 bits on all platforms). + */ + class captured_lval { + protected: + // Contains either a T* (captured_struct_lval) or T**(captured_ref_lval) + x10_long _val; + public: + GPUSAFE captured_lval() { } // ok to not initialize; compiler will ensure we never read unitialized captured_lval + + GPUSAFE captured_lval(x10_long v) : _val(v) {} + + x10_long capturedAddress() { + return _val; + } + + void setCapturedAddress(x10_long addr) { + _val = addr; + } + }; + + template <class T> class captured_struct_lval : public captured_lval { + public: + GPUSAFE captured_struct_lval() { } // ok to not initialize; compiler will ensure we never read unitialized captured_lval + + GPUSAFE captured_struct_lval(const captured_struct_lval<T>& _ref) : captured_lval(_ref._val) { } + + GPUSAFE captured_struct_lval(T const &val) : captured_lval((x10_long)(size_t)(void*)&val) { } + + GPUSAFE captured_struct_lval(T const *val) : captured_lval((x10_long)(size_t)(void*)val) { } + + GPUSAFE const captured_struct_lval<T>& operator=(const captured_struct_lval<T>& _ref) { + _val = _ref._val; + return *this; + } + + T operator=(const T &val) { + *((T*)(size_t)_val) = val; + return val; + } + + // &<captured_struct_lval<T> can simply be the thing itself. + // Of dubious taste, but lets us avoid trying to + // special case codegen of closures to detect when + // the closure is the "first" to capture a variable + // vs. when it is re-capturing something that has already + // been captured. + captured_struct_lval<T> operator&() { + return *this; + } + + GPUSAFE operator T() { + return *((T*)(size_t)_val); + } + + T& GPUSAFE operator*() const { + return *((T*)_val); + } + + T* GPUSAFE operator->() const { + return (T*)(size_t)_val; + } + }; + + template <class T> class captured_ref_lval : public captured_lval { + public: + GPUSAFE captured_ref_lval() { } // ok to not initialize; compiler will ensure we never read unitialized captured_lval + + GPUSAFE captured_ref_lval(const captured_ref_lval<T>& _ref) : captured_lval(_ref._val) { } + + GPUSAFE captured_ref_lval(ref<T> const *val) : captured_lval((x10_long)(size_t)(void*)val) { } + + GPUSAFE const captured_ref_lval<T>& operator=(const captured_ref_lval<T>& _ref) { + _val = _ref._val; + return *this; + } + + T* operator=(const ref<T> &ref) { + T* value = ref.operator->(); + *((T**)(size_t)_val) = value; + return value; + } + + // &<captured_ref_lval<T> can simply be the thing itself. + // Of dubious taste, but lets us avoid trying to + // special case codegen of closures to detect when + // the closure is the "first" to capture a variable + // vs. when it is re-capturing something that has already + // been captured. + captured_ref_lval<T> operator&() { + return *this; + } + + GPUSAFE operator ref<T>() { + return ref<T>(*(T**)(size_t)_val); + } + + T& GPUSAFE operator*() const { + return *((T**)_val); + } + + T* GPUSAFE operator->() const { + return *((T**)(size_t)_val); + } + }; +} + +// vim:tabstop=4:shiftwidth=4:expandtab + +#endif /* X10CAPTURED_LVAL_H */ Modified: trunk/x10.runtime/src-cpp/x10aux/serialization.h =================================================================== --- trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.runtime/src-cpp/x10aux/serialization.h 2010-10-03 02:27:41 UTC (rev 16886) @@ -16,7 +16,7 @@ #include <x10aux/config.h> #include <x10aux/ref.h> -#include <x10aux/boxed_ref.h> +#include <x10aux/captured_lval.h> #include <x10aux/alloc.h> #include <x10aux/deserialization_dispatcher.h> @@ -226,7 +226,8 @@ // Default case for primitives and other things that never contain pointers template<class T> struct Write; template<class T> struct Write<ref<T> >; - template<class T> struct Write<boxed_ref<T> >; + template<class T> struct Write<captured_ref_lval<T> >; + template<class T> struct Write<captured_struct_lval<T> >; template<typename T> void write(const T &val); // So it can access the addr_map @@ -319,18 +320,29 @@ T::_serialize(val,buf); } - // Case for captured stack variables e.g. boxed_ref<T>, - template<class T> struct serialization_buffer::Write<boxed_ref<T> > { - static void _(serialization_buffer &buf, boxed_ref<T> val); + // Case for captured stack variables e.g. captured_ref_lval<T> and captured_struct_lval<T>. + template<class T> struct serialization_buffer::Write<captured_ref_lval<T> > { + static void _(serialization_buffer &buf, captured_ref_lval<T> val); }; - template<class T> void serialization_buffer::Write<boxed_ref<T> >::_(serialization_buffer &buf, - boxed_ref<T> val) { + template<class T> void serialization_buffer::Write<captured_ref_lval<T> >::_(serialization_buffer &buf, + captured_ref_lval<T> val) { + _S_("Serializing a stack variable of type ref<"<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<"> into buf: "<<&buf); + x10_long capturedAddress = val.capturedAddress(); + _S_("\tCaptured address is "<<((void*)capturedAddress)); + buf.write(capturedAddress); + } + template<class T> struct serialization_buffer::Write<captured_struct_lval<T> > { + static void _(serialization_buffer &buf, captured_struct_lval<T> val); + }; + template<class T> void serialization_buffer::Write<captured_struct_lval<T> >::_(serialization_buffer &buf, + captured_struct_lval<T> val) { _S_("Serializing a stack variable of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" into buf: "<<&buf); x10_long capturedAddress = val.capturedAddress(); _S_("\tCaptured address is "<<((void*)capturedAddress)); buf.write(capturedAddress); } + template<typename T> void serialization_buffer::write(const T &val) { Write<T>::_(*this,val); } @@ -456,15 +468,26 @@ return T::template _deserialize<T>(buf); } - // Case for captured stack addresses, boxed_ref<T> - template<class T> struct deserialization_buffer::Read<boxed_ref<T> > { - GPUSAFE static boxed_ref<T> _(deserialization_buffer &buf); + // Case for captured stack addresses, captured_ref_lval<T> and captured_struct_lval<T> + template<class T> struct deserialization_buffer::Read<captured_ref_lval<T> > { + GPUSAFE static captured_ref_lval<T> _(deserialization_buffer &buf); }; - template<class T> boxed_ref<T> deserialization_buffer::Read<boxed_ref<T> >::_(deserialization_buffer &buf) { + template<class T> captured_ref_lval<T> deserialization_buffer::Read<captured_ref_lval<T> >::_(deserialization_buffer &buf) { + _S_("Deserializing a stack variable of type ref<"<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<"> from buf: "<<&buf); + x10_long addr = buf.read<x10_long>(); + _S_("\tCaptured address is "<<((void*)addr)); + x10aux::captured_ref_lval<T> result; + result.setCapturedAddress(addr); + return result; + } + template<class T> struct deserialization_buffer::Read<captured_struct_lval<T> > { + GPUSAFE static captured_struct_lval<T> _(deserialization_buffer &buf); + }; + template<class T> captured_struct_lval<T> deserialization_buffer::Read<captured_struct_lval<T> >::_(deserialization_buffer &buf) { _S_("Deserializing a stack variable of type "<<ANSI_SER<<ANSI_BOLD<<TYPENAME(T)<<ANSI_RESET<<" from buf: "<<&buf); x10_long addr = buf.read<x10_long>(); _S_("\tCaptured address is "<<((void*)addr)); - x10aux::boxed_ref<T> result; + x10aux::captured_struct_lval<T> result; result.setCapturedAddress(addr); return result; } Modified: trunk/x10.runtime/src-cpp/x10rt.h =================================================================== --- trunk/x10.runtime/src-cpp/x10rt.h 2010-10-02 19:50:31 UTC (rev 16885) +++ trunk/x10.runtime/src-cpp/x10rt.h 2010-10-03 02:27:41 UTC (rev 16886) @@ -10,7 +10,7 @@ #include <x10aux/class_cast.h> #include <x10aux/ref.h> -#include <x10aux/boxed_ref.h> +#include <x10aux/captured_lval.h> #include <x10aux/reference_logger.h> #include <x10aux/alloc.h> #include <x10aux/serialization.h> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <vj...@us...> - 2010-10-04 01:13:58
|
Revision: 16898 http://x10.svn.sourceforge.net/x10/?rev=16898&view=rev Author: vj0 Date: 2010-10-04 01:13:49 +0000 (Mon, 04 Oct 2010) Log Message: ----------- Added support for Array Literals. Now the parser recognizes tuple syntax: [ 1] [1, 0, 3, 2] as well as explicitly typed tuples: new Array[Int][1] new Array[Int{self !=0}][1,2,3,4] The Java backend works fine. Still needed is support in the C++ backend. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/Tuple_c.java 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/X10Parser.java trunk/x10.compiler/src/x10/parser/X10Parserprs.java trunk/x10.compiler/src/x10/parser/x10.g trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/types/X10TypeSystem_c.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.runtime/src-x10/x10/array/Array.x10 trunk/x10.runtime/src-x10/x10/array/BaseDist.x10 trunk/x10.runtime/src-x10/x10/array/BlockWorldDist.x10 trunk/x10.runtime/src-x10/x10/array/Dist.x10 trunk/x10.runtime/src-x10/x10/array/DistArray.x10 trunk/x10.runtime/src-x10/x10/array/UniqueDist.x10 trunk/x10.runtime/src-x10/x10/array/WrappedDistPlaceRestricted.x10 trunk/x10.runtime/src-x10/x10/array/WrappedDistRegionRestricted.x10 trunk/x10.runtime/src-x10/x10/lang/Place.x10 trunk/x10.runtime/src-x10/x10/lang/PlaceLocalHandle.x10 trunk/x10.runtime/src-x10/x10/lang/ULong.x10 trunk/x10.runtime/src-x10/x10/util/ArrayList.x10 Added Paths: ----------- trunk/x10.compiler/src/x10/ast/ArrayLiteral.java trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest.x10 Added: trunk/x10.compiler/src/x10/ast/ArrayLiteral.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -0,0 +1,16 @@ +package x10.ast; + +import polyglot.ast.Expr; +import polyglot.ast.TypeNode; + +/** + * The interface implemented by an array literal. An array literal is simply a tuple with a + * user-specified return type. + * @author vj + * + */ +public interface ArrayLiteral extends Expr { + Tuple_c tuple(); + TypeNode indexType(); + +} Property changes on: trunk/x10.compiler/src/x10/ast/ArrayLiteral.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java (rev 0) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -0,0 +1,128 @@ +/** + * + */ +package x10.ast; + +import java.util.List; + +import polyglot.ast.Expr; +import polyglot.ast.Expr_c; +import polyglot.ast.Node; +import polyglot.ast.Term; +import polyglot.ast.TypeNode; +import polyglot.types.Context; +import polyglot.types.SemanticException; +import polyglot.types.Type; +import polyglot.types.TypeSystem; +import polyglot.util.CodeWriter; +import polyglot.util.Position; +import polyglot.visit.AscriptionVisitor; +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.X10ParsedClassType; +import x10.types.X10TypeMixin; +import x10.types.X10TypeSystem; +import x10.types.checker.PlaceChecker; + +/** + * A representation of the syntactic form new Array[T]{ e1,..., en}. + * Each ei must be of type T. The type of this expression is Array[T](0..n-1). + * + * From an implementation point of view, an ArrayLiteral_c is simply a Tuple with + * a user-specified type. It is translated in the Desugarer into a Tuple, to be + * implemented by backends as appropriate. + * @author vj + * + */ +public class ArrayLiteral_c extends Expr_c implements ArrayLiteral { + + TypeNode array; + TypeNode indexType; + Tuple_c tuple; + /** + * @param pos + */ + public ArrayLiteral_c(Position pos, TypeNode array, TypeNode indexType, Tuple_c tuple) { + super(pos); + this.array=array; + this.indexType = indexType; + this.tuple = tuple; + } + + public Tuple_c tuple() { + return tuple; + } + /* (non-Javadoc) + * @see polyglot.ast.Term#firstChild() + */ + public Term firstChild() { + return indexType; + } + + public TypeNode indexType() { + return indexType; + } + + /* (non-Javadoc) + * @see polyglot.ast.Term_c#acceptCFG(polyglot.visit.CFGBuilder, java.util.List) + * Visit this term in evaluation order. + */ + @Override + public <S> List<S> acceptCFG(CFGBuilder v, List<S> succs) { + v.visitCFG(indexType, tuple, ENTRY); + v.visitCFG(tuple, this, EXIT); + return succs; + } + public Node visitChildren( NodeVisitor v ) { + TypeNode atn = (TypeNode) visitChild(this.array, v); + TypeNode tn = (TypeNode) visitChild( this.indexType, v ); + Tuple_c t = (Tuple_c) visitChild(this.tuple, v); + if (atn != array || t != tuple || tn != indexType) { + ArrayLiteral_c n = (ArrayLiteral_c) copy(); + n.array = atn; + n.tuple = t; + n.indexType = tn; + return n; + } + return this; + } + public Node typeCheck(ContextVisitor tc) throws SemanticException { + ArrayLiteral_c n = (ArrayLiteral_c) super.typeCheck(tc); + Type type = tuple.type(); + Type iType = indexType.type(); + X10TypeSystem ts = (X10TypeSystem) tc.typeSystem(); + + String arrayTypeName = array.type().toString(); + if (! (arrayTypeName.equals("x10.array.Array") || arrayTypeName.equals("Array"))) + Errors.issue(tc.job(), + new Errors.ArrayLiteralMustBeOfArrayType(array.type().toString(), n.position())); + + Type aType = X10TypeMixin.typeArg(type,0); + if (! ts.isSubtype(aType, iType, tc.context())) + Errors.issue(tc.job(), + new Errors.ArrayLiteralTypeMismatch(type, iType, n.position())); + Type resultType = X10TypeMixin.makeArrayRailOf(iType, n.tuple().arguments().size(), n.position()); + + return n.type(resultType); + } + + public String toString() { + return "new Array[" + indexType + "]{ " + tuple.stringValue() + "}"; + } + + /** Write the expression to an output file. */ + + public void prettyPrint(CodeWriter w, PrettyPrinter tr) { + w.write("new Array["); + printBlock(indexType, w, tr); + w.write("]"); + tuple.prettyPrint(w,tr); + + } + + +} Property changes on: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: trunk/x10.compiler/src/x10/ast/Tuple_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-10-03 19:44:40 UTC (rev 16897) +++ trunk/x10.compiler/src/x10/ast/Tuple_c.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -36,6 +36,7 @@ import polyglot.visit.Translator; import x10.constraint.XFailure; import x10.constraint.XLit; +import x10.constraint.XTerms; import x10.constraint.XVar; import x10.types.X10ClassType; import x10.types.X10TypeMixin; @@ -44,8 +45,10 @@ import x10.types.constraints.CConstraint; /** - * An immutable representation of the X10 rail constructor [e1, ..., ek]. - * This behaves like a Java array initializer except that the type is NativeValRail[T], not T[]. + * An immutable representation of the list of elements in an X10 array constructor + * new Array[T]{ e1,..., ek}. + * + * There is no surface syntax for a Tuple_c. Rather it is access */ public class Tuple_c extends Expr_c implements Tuple { @@ -121,7 +124,7 @@ X10TypeSystem ts = (X10TypeSystem) av.typeSystem(); - if (! ts.isValRail(t)) { + if (! ts.isArray(t)) { return child.type(); // Don't complain when we have implicit coercions! // throw new InternalCompilerError("Type of rail constructor must be a " + ts.ValRail() + ", not " + t + ".", position()); @@ -171,22 +174,7 @@ type = ts.Any(); // should be bottom type, not top } - Type r = ts.ValRail(); - Type t = (X10ClassType) X10TypeMixin.instantiate(r, type); - CConstraint c = new CConstraint(); - FieldInstance lengthField = ((X10ClassType) t).fieldNamed(Name.make("length")); - if (lengthField == null) - throw new InternalCompilerError("Could not find length field of " + t, position()); - try { - XVar selfLength = ts.xtypeTranslator().trans(c, c.self(), lengthField); - XLit sizeLiteral = ts.xtypeTranslator().trans(elements.size()); - c.addBinding(selfLength, sizeLiteral); - c.toString(); - t = X10TypeMixin.xclause(t, c); - } - catch (XFailure e) { - throw new SemanticException(e); - } + Type t = X10TypeMixin.makeArrayRailOf(type, elements.size(), position()); return type(t); } @@ -209,7 +197,7 @@ @Override public void prettyPrint(CodeWriter w, PrettyPrinter tr) { - w.write("["); + w.write("{"); for (Iterator<Expr> i = elements.iterator(); i.hasNext(); ) { Expr e = i.next(); @@ -222,7 +210,7 @@ } } - w.write("]"); + w.write("}"); } @Override Modified: trunk/x10.compiler/src/x10/ast/X10NodeFactory.java =================================================================== --- trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-03 19:44:40 UTC (rev 16897) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -64,6 +64,7 @@ AtStmt AtStmt(Position pos, Expr place, Stmt body); AtExpr AtExpr(Position pos, Expr place, TypeNode returnType, Block body); + ArrayLiteral ArrayLiteral(Position pos, TypeNode array, TypeNode indexType, Tuple values); 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-10-03 19:44:40 UTC (rev 16897) +++ trunk/x10.compiler/src/x10/ast/X10NodeFactory_c.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -410,6 +410,12 @@ public New New(Position pos, Expr qualifier, TypeNode objectType, List<Expr> arguments, ClassBody body) { return X10New(pos, qualifier, objectType, Collections.<TypeNode>emptyList(), arguments, body); } + + public ArrayLiteral ArrayLiteral(Position pos, TypeNode arrayType, TypeNode argType, Tuple values) { + ArrayLiteral n = new ArrayLiteral_c(pos, arrayType, argType, (Tuple_c) values); + n = (ArrayLiteral) n.ext(extFactory().extExpr()); + return (ArrayLiteral) n.del(delFactory().delExpr()); + } // Wrap the body in a block to facilitate code transformations public AtEach AtEach(Position pos, Formal formal, Expr domain, Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-10-03 19:44:40 UTC (rev 16897) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -691,4 +691,18 @@ + "\n\t desired Type:" + returnType, pos); } } + public static class ArrayLiteralMustBeOfArrayType extends EqualByTypeAndPosException { + private static final long serialVersionUID = 3059270665285777371L; + public ArrayLiteralMustBeOfArrayType(String typeName, Position pos) { + super("An array literal must start with 'new Array...'.", pos); + } + } + public static class ArrayLiteralTypeMismatch extends EqualByTypeAndPosException { + private static final long serialVersionUID = -8344153029213631407L; + public ArrayLiteralTypeMismatch(Type atype, Type itype, Position pos) { + super("The computed type of element literals is not a subtype of the given type" + + "\n\t: computed type: " + atype + + "\n\t: given type: " + itype, pos); + } + } } Modified: trunk/x10.compiler/src/x10/parser/X10Parser.java =================================================================== --- trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-03 19:44:40 UTC (rev 16897) +++ trunk/x10.compiler/src/x10/parser/X10Parser.java 2010-10-04 01:13:49 UTC (rev 16898) @@ -2345,26 +2345,43 @@ //#line 1684 "lpg.generator/templates/java/btParserTemplateF.gi" if (ClassBodyopt == null) setResult(nf.X10New(pos(), TypeName.toType(), TypeArgumentsopt, ArgumentListopt)); - else setResult(nf.X10New(pos(), TypeName.toType(), TypeArgumentsopt, ArgumentListopt, ClassBodyopt)); + else setResult(nf.X10New(pos(), TypeName.toType(), TypeArgumentsopt, ArgumentListopt, ClassBodyopt)) ; break; } // - // Rule 56: ClassInstanceCreationExpression ::= Primary . new Identifier TypeArgumentsopt ( ArgumentListopt ) ClassBodyopt + // Rule 56: ClassInstanceCreationExpression ::= new TypeName [ Type ] [ ArgumentListopt ] // case 56: { //#line 1691 "lpg.generator/templates/java/btParserTemplateF.gi" //#line 1689 "x10/parser/x10.g" + ParsedName TypeName = (ParsedName) getRhsSym(2); + //#line 1689 "x10/parser/x10.g" + TypeNode Type = (TypeNode) getRhsSym(4); + //#line 1689 "x10/parser/x10.g" + List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(7); + //#line 1691 "lpg.generator/templates/java/btParserTemplateF.gi" + TypeNode array = TypeName.toType(); + setResult(nf.ArrayLiteral(pos(), TypeName.toType(), Type, nf.Tuple(pos(), ArgumentListopt))); + break; + } + + // + // Rule 57: ClassInstanceCreationExpression ::= Primary . new Identifier TypeArgumentsopt ( ArgumentListopt ) ClassBodyopt + // + case 57: { + //#line 1697 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1695 "x10/parser/x10.g" Expr Primary = (Expr) getRhsSym(1); - //#line 1689 "x10/parser/x10.g" + //#line 1695 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(4); - //#line 1689 "x10/parser/x10.g" + //#line 1695 "x10/parser/x10.g" List<TypeNode> TypeArgumentsopt = (List<TypeNode>) getRhsSym(5); - //#line 1689 "x10/parser/x10.g" + //#line 1695 "x10/parser/x10.g" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(7); - //#line 1689 "x10/parser/x10.g" + //#line 1695 "x10/parser/x10.g" ClassBody ClassBodyopt = (ClassBody) getRhsSym(9); - //#line 1691 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1697 "lpg.generator/templates/java/btParserTemplateF.gi" ParsedName b = new X10ParsedName(nf, ts, pos(), Identifier); if (ClassBodyopt == null) setResult(nf.X10New(pos(), Primary, b.toType(), TypeArgumentsopt, ArgumentListopt)); @@ -2373,21 +2390,21 @@ } // - // Rule 57: ClassInstanceCreationExpression ::= AmbiguousName . new Identifier TypeArgumentsopt ( ArgumentListopt ) ClassBodyopt + // Rule 58: ClassInstanceCreationExpression ::= AmbiguousName . new Identifier TypeArgumentsopt ( ArgumentListopt ) ClassBodyopt // - case 57: { - //#line 1699 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1697 "x10/parser/x10.g" + case 58: { + //#line 1705 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1703 "x10/parser/x10.g" ParsedName AmbiguousName = (ParsedName) getRhsSym(1); - //#line 1697 "x10/parser/x10.g" + //#line 1703 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(4); - //#line 1697 "x10/parser/x10.g" + //#line 1703 "x10/parser/x10.g" List<TypeNode> TypeArgumentsopt = (List<TypeNode>) getRhsSym(5); - //#line 1697 "x10/parser/x10.g" + //#line 1703 "x10/parser/x10.g" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(7); - //#line 1697 "x10/parser/x10.g" + //#line 1703 "x10/parser/x10.g" ClassBody ClassBodyopt = (ClassBody) getRhsSym(9); - //#line 1699 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1705 "lpg.generator/templates/java/btParserTemplateF.gi" ParsedName b = new X10ParsedName(nf, ts, pos(), Identifier); if (ClassBodyopt == null) setResult(nf.X10New(pos(), AmbiguousName.toExpr(), b.toType(), TypeArgumentsopt, ArgumentListopt)); @@ -2396,49 +2413,49 @@ } // - // Rule 58: AssignPropertyCall ::= property TypeArgumentsopt ( ArgumentListopt ) ; + // Rule 59: AssignPropertyCall ::= property TypeArgumentsopt ( ArgumentListopt ) ; // - case 58: { - //#line 1708 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1706 "x10/parser/x10.g" + case 59: { + //#line 1714 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1712 "x10/parser/x10.g" List<TypeNode> TypeArgumentsopt = (List<TypeNode>) getRhsSym(2); - //#line 1706 "x10/parser/x10.g" + //#line 1712 "x10/parser/x10.g" List<Expr> ArgumentListopt = (List<Expr>) getRhsSym(4); - //#line 1708 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1714 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.AssignPropertyCall(pos(), TypeArgumentsopt, ArgumentListopt)); break; } // - // Rule 61: FunctionType ::= TypeParametersopt ( FormalParameterListopt ) WhereClauseopt Offersopt => Type + // Rule 62: FunctionType ::= TypeParametersopt ( FormalParameterListopt ) WhereClauseopt Offersopt => Type // - case 61: { - //#line 1718 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1716 "x10/parser/x10.g" + case 62: { + //#line 1724 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1722 "x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(1); - //#line 1716 "x10/parser/x10.g" + //#line 1722 "x10/parser/x10.g" List<Formal> FormalParameterListopt = (List<Formal>) getRhsSym(3); - //#line 1716 "x10/parser/x10.g" + //#line 1722 "x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(5); - //#line 1716 "x10/parser/x10.g" + //#line 1722 "x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(6); - //#line 1716 "x10/parser/x10.g" + //#line 1722 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(8); - //#line 1718 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1724 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.FunctionTypeNode(pos(), TypeParametersopt, FormalParameterListopt, WhereClauseopt, Type, Offersopt)); break; } // - // Rule 63: AnnotatedType ::= Type Annotations + // Rule 64: AnnotatedType ::= Type Annotations // - case 63: { - //#line 1731 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1729 "x10/parser/x10.g" + case 64: { + //#line 1737 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1735 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(1); - //#line 1729 "x10/parser/x10.g" + //#line 1735 "x10/parser/x10.g" List<AnnotationNode> Annotations = (List<AnnotationNode>) getRhsSym(2); - //#line 1731 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1737 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode tn = Type; tn = (TypeNode) ((X10Ext) tn.ext()).annotations((List<AnnotationNode>) Annotations); setResult(tn.position(pos())); @@ -2446,67 +2463,67 @@ } // - // Rule 66: ConstrainedType ::= ( Type ) + // Rule 67: ConstrainedType ::= ( Type ) // - case 66: { - //#line 1741 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1739 "x10/parser/x10.g" + case 67: { + //#line 1747 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1745 "x10/parser/x10.g" TypeNode Type = (TypeNode) getRhsSym(2); - //#line 1741 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1747 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(Type); break; } // - // Rule 68: SimpleNamedType ::= TypeName + // Rule 69: SimpleNamedType ::= TypeName // - case 68: { - //#line 1755 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1753 "x10/parser/x10.g" + case 69: { + //#line 1761 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1759 "x10/parser/x10.g" ParsedName TypeName = (ParsedName) getRhsSym(1); - //#line 1755 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1761 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(TypeName.toType()); break; } // - // Rule 69: SimpleNamedType ::= Primary . Identifier + // Rule 70: SimpleNamedType ::= Primary . Identifier // - case 69: { - //#line 1760 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1758 "x10/parser/x10.g" + case 70: { + //#line 1766 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1764 "x10/parser/x10.g" Expr Primary = (Expr) getRhsSym(1); - //#line 1758 "x10/parser/x10.g" + //#line 1764 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1760 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1766 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.AmbTypeNode(pos(), Primary, Identifier)); break; } // - // Rule 70: SimpleNamedType ::= DepNamedType . Identifier + // Rule 71: SimpleNamedType ::= DepNamedType . Identifier // - case 70: { - //#line 1765 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1763 "x10/parser/x10.g" + case 71: { + //#line 1771 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1769 "x10/parser/x10.g" TypeNode DepNamedType = (TypeNode) getRhsSym(1); - //#line 1763 "x10/parser/x10.g" + //#line 1769 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1765 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1771 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.AmbTypeNode(pos(), DepNamedType, Identifier)); break; } // - // Rule 71: DepNamedType ::= SimpleNamedType DepParameters + // Rule 72: DepNamedType ::= SimpleNamedType DepParameters // - case 71: { - //#line 1771 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1769 "x10/parser/x10.g" + case 72: { + //#line 1777 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1775 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1769 "x10/parser/x10.g" + //#line 1775 "x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(2); - //#line 1771 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1777 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), new TypedList<TypeNode>(new LinkedList<TypeNode>(), TypeNode.class, false), new TypedList<Expr>(new LinkedList<Expr>(), Expr.class, false), @@ -2516,15 +2533,15 @@ } // - // Rule 72: DepNamedType ::= SimpleNamedType Arguments + // Rule 73: DepNamedType ::= SimpleNamedType Arguments // - case 72: { - //#line 1780 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1778 "x10/parser/x10.g" + case 73: { + //#line 1786 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1784 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1778 "x10/parser/x10.g" + //#line 1784 "x10/parser/x10.g" List<Expr> Arguments = (List<Expr>) getRhsSym(2); - //#line 1780 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1786 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), new TypedList<TypeNode>(new LinkedList<TypeNode>(), TypeNode.class, false), Arguments, @@ -2534,17 +2551,17 @@ } // - // Rule 73: DepNamedType ::= SimpleNamedType Arguments DepParameters + // Rule 74: DepNamedType ::= SimpleNamedType Arguments DepParameters // - case 73: { - //#line 1789 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1787 "x10/parser/x10.g" + case 74: { + //#line 1795 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1793 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1787 "x10/parser/x10.g" + //#line 1793 "x10/parser/x10.g" List<Expr> Arguments = (List<Expr>) getRhsSym(2); - //#line 1787 "x10/parser/x10.g" + //#line 1793 "x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(3); - //#line 1789 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1795 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), new TypedList<TypeNode>(new LinkedList<TypeNode>(), TypeNode.class, false), Arguments, @@ -2554,15 +2571,15 @@ } // - // Rule 74: DepNamedType ::= SimpleNamedType TypeArguments + // Rule 75: DepNamedType ::= SimpleNamedType TypeArguments // - case 74: { - //#line 1798 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1796 "x10/parser/x10.g" + case 75: { + //#line 1804 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1802 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1796 "x10/parser/x10.g" + //#line 1802 "x10/parser/x10.g" List<TypeNode> TypeArguments = (List<TypeNode>) getRhsSym(2); - //#line 1798 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1804 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), TypeArguments, new TypedList<Expr>(new LinkedList<Expr>(), Expr.class, false), @@ -2572,17 +2589,17 @@ } // - // Rule 75: DepNamedType ::= SimpleNamedType TypeArguments DepParameters + // Rule 76: DepNamedType ::= SimpleNamedType TypeArguments DepParameters // - case 75: { - //#line 1807 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1805 "x10/parser/x10.g" + case 76: { + //#line 1813 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1811 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1805 "x10/parser/x10.g" + //#line 1811 "x10/parser/x10.g" List<TypeNode> TypeArguments = (List<TypeNode>) getRhsSym(2); - //#line 1805 "x10/parser/x10.g" + //#line 1811 "x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(3); - //#line 1807 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1813 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), TypeArguments, new TypedList<Expr>(new LinkedList<Expr>(), Expr.class, false), @@ -2592,17 +2609,17 @@ } // - // Rule 76: DepNamedType ::= SimpleNamedType TypeArguments Arguments + // Rule 77: DepNamedType ::= SimpleNamedType TypeArguments Arguments // - case 76: { - //#line 1816 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1814 "x10/parser/x10.g" + case 77: { + //#line 1822 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1820 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1814 "x10/parser/x10.g" + //#line 1820 "x10/parser/x10.g" List<TypeNode> TypeArguments = (List<TypeNode>) getRhsSym(2); - //#line 1814 "x10/parser/x10.g" + //#line 1820 "x10/parser/x10.g" List<Expr> Arguments = (List<Expr>) getRhsSym(3); - //#line 1816 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1822 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), TypeArguments, Arguments, @@ -2612,19 +2629,19 @@ } // - // Rule 77: DepNamedType ::= SimpleNamedType TypeArguments Arguments DepParameters + // Rule 78: DepNamedType ::= SimpleNamedType TypeArguments Arguments DepParameters // - case 77: { - //#line 1825 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1823 "x10/parser/x10.g" + case 78: { + //#line 1831 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1829 "x10/parser/x10.g" TypeNode SimpleNamedType = (TypeNode) getRhsSym(1); - //#line 1823 "x10/parser/x10.g" + //#line 1829 "x10/parser/x10.g" List<TypeNode> TypeArguments = (List<TypeNode>) getRhsSym(2); - //#line 1823 "x10/parser/x10.g" + //#line 1829 "x10/parser/x10.g" List<Expr> Arguments = (List<Expr>) getRhsSym(3); - //#line 1823 "x10/parser/x10.g" + //#line 1829 "x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(4); - //#line 1825 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1831 "lpg.generator/templates/java/btParserTemplateF.gi" TypeNode type = nf.AmbDepTypeNode(pos(), ((AmbTypeNode) SimpleNamedType).prefix(), ((AmbTypeNode) SimpleNamedType).name(), TypeArguments, Arguments, @@ -2634,120 +2651,120 @@ } // - // Rule 80: DepParameters ::= { ExistentialListopt Conjunctionopt } + // Rule 81: DepParameters ::= { ExistentialListopt Conjunctionopt } // - case 80: { - //#line 1838 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1836 "x10/parser/x10.g" + case 81: { + //#line 1844 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1842 "x10/parser/x10.g" List<Formal> ExistentialListopt = (List<Formal>) getRhsSym(2); - //#line 1836 "x10/parser/x10.g" + //#line 1842 "x10/parser/x10.g" List<Expr> Conjunctionopt = (List<Expr>) getRhsSym(3); - //#line 1838 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1844 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.DepParameterExpr(pos(), ExistentialListopt, Conjunctionopt)); break; } // - // Rule 81: DepParameters ::= ! PlaceType + // Rule 82: DepParameters ::= ! PlaceType // - case 81: { - //#line 1843 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1841 "x10/parser/x10.g" + case 82: { + //#line 1849 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1847 "x10/parser/x10.g" Expr PlaceType = (Expr) getRhsSym(2); - //#line 1843 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1849 "lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); break; } // - // Rule 82: DepParameters ::= ! + // Rule 83: DepParameters ::= ! // - case 82: { - //#line 1849 "lpg.generator/templates/java/btParserTemplateF.gi" + case 83: { + //#line 1855 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1849 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1855 "lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); setResult(nf.DepParameterExpr(pos(), null, Collections.singletonList(placeClause))); break; } // - // Rule 83: DepParameters ::= ! PlaceType { ExistentialListopt Conjunction } + // Rule 84: DepParameters ::= ! PlaceType { ExistentialListopt Conjunction } // - case 83: { - //#line 1855 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1853 "x10/parser/x10.g" + case 84: { + //#line 1861 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1859 "x10/parser/x10.g" Expr PlaceType = (Expr) getRhsSym(2); - //#line 1853 "x10/parser/x10.g" + //#line 1859 "x10/parser/x10.g" List<Formal> ExistentialListopt = (List<Formal>) getRhsSym(4); - //#line 1853 "x10/parser/x10.g" + //#line 1859 "x10/parser/x10.g" List<Expr> Conjunction = (List<Expr>) getRhsSym(5); - //#line 1855 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1861 "lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), PlaceType); setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); break; } // - // Rule 84: DepParameters ::= ! { ExistentialListopt Conjunction } + // Rule 85: DepParameters ::= ! { ExistentialListopt Conjunction } // - case 84: { - //#line 1861 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1859 "x10/parser/x10.g" + case 85: { + //#line 1867 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1865 "x10/parser/x10.g" List<Formal> ExistentialListopt = (List<Formal>) getRhsSym(3); - //#line 1859 "x10/parser/x10.g" + //#line 1865 "x10/parser/x10.g" List<Expr> Conjunction = (List<Expr>) getRhsSym(4); - //#line 1861 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1867 "lpg.generator/templates/java/btParserTemplateF.gi" Expr placeClause = nf.Call(pos(), nf.Self(pos()), nf.Id(pos(), "at"), nf.AmbHereThis(pos())); setResult(nf.DepParameterExpr(pos(), ExistentialListopt, CollectionUtil.append(Conjunction, Collections.singletonList(placeClause)))); break; } // - // Rule 85: TypeParamsWithVariance ::= [ TypeParamWithVarianceList ] + // Rule 86: TypeParamsWithVariance ::= [ TypeParamWithVarianceList ] // - case 85: { - //#line 1869 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1867 "x10/parser/x10.g" + case 86: { + //#line 1875 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1873 "x10/parser/x10.g" List<TypeParamNode> TypeParamWithVarianceList = (List<TypeParamNode>) getRhsSym(2); - //#line 1869 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1875 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(TypeParamWithVarianceList); break; } // - // Rule 86: TypeParameters ::= [ TypeParameterList ] + // Rule 87: TypeParameters ::= [ TypeParameterList ] // - case 86: { - //#line 1875 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1873 "x10/parser/x10.g" + case 87: { + //#line 1881 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1879 "x10/parser/x10.g" List<TypeParamNode> TypeParameterList = (List<TypeParamNode>) getRhsSym(2); - //#line 1875 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1881 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(TypeParameterList); break; } // - // Rule 87: FormalParameters ::= ( FormalParameterListopt ) + // Rule 88: FormalParameters ::= ( FormalParameterListopt ) // - case 87: { - //#line 1881 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1879 "x10/parser/x10.g" + case 88: { + //#line 1887 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1885 "x10/parser/x10.g" List<Formal> FormalParameterListopt = (List<Formal>) getRhsSym(2); - //#line 1881 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1887 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(FormalParameterListopt); break; } // - // Rule 88: Conjunction ::= Expression + // Rule 89: Conjunction ::= Expression // - case 88: { - //#line 1887 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1885 "x10/parser/x10.g" + case 89: { + //#line 1893 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1891 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(1); - //#line 1887 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1893 "lpg.generator/templates/java/btParserTemplateF.gi" List<Expr> l = new ArrayList<Expr>(); l.add(Expression); setResult(l); @@ -2755,114 +2772,114 @@ } // - // Rule 89: Conjunction ::= Conjunction , Expression + // Rule 90: Conjunction ::= Conjunction , Expression // - case 89: { - //#line 1894 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1892 "x10/parser/x10.g" + case 90: { + //#line 1900 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1898 "x10/parser/x10.g" List<Expr> Conjunction = (List<Expr>) getRhsSym(1); - //#line 1892 "x10/parser/x10.g" + //#line 1898 "x10/parser/x10.g" Expr Expression = (Expr) getRhsSym(3); - //#line 1894 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1900 "lpg.generator/templates/java/btParserTemplateF.gi" Conjunction.add(Expression); break; } // - // Rule 90: SubtypeConstraint ::= Type$t1 <: Type$t2 + // Rule 91: SubtypeConstraint ::= Type$t1 <: Type$t2 // - case 90: { - //#line 1900 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1898 "x10/parser/x10.g" + case 91: { + //#line 1906 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1904 "x10/parser/x10.g" TypeNode t1 = (TypeNode) getRhsSym(1); - //#line 1898 "x10/parser/x10.g" + //#line 1904 "x10/parser/x10.g" TypeNode t2 = (TypeNode) getRhsSym(3); - //#line 1900 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1906 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.SubtypeTest(pos(), t1, t2, false)); break; } // - // Rule 91: SubtypeConstraint ::= Type$t1 :> Type$t2 + // Rule 92: SubtypeConstraint ::= Type$t1 :> Type$t2 // - case 91: { - //#line 1905 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1903 "x10/parser/x10.g" + case 92: { + //#line 1911 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1909 "x10/parser/x10.g" TypeNode t1 = (TypeNode) getRhsSym(1); - //#line 1903 "x10/parser/x10.g" + //#line 1909 "x10/parser/x10.g" TypeNode t2 = (TypeNode) getRhsSym(3); - //#line 1905 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1911 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(nf.SubtypeTest(pos(), t2, t1, false)); break; } // - // Rule 92: WhereClause ::= DepParameters + // Rule 93: WhereClause ::= DepParameters // - case 92: { - //#line 1911 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1909 "x10/parser/x10.g" + case 93: { + //#line 1917 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1915 "x10/parser/x10.g" DepParameterExpr DepParameters = (DepParameterExpr) getRhsSym(1); - //#line 1911 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1917 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(DepParameters); break; } // - // Rule 93: Conjunctionopt ::= $Empty + // Rule 94: Conjunctionopt ::= $Empty // - case 93: { - //#line 1917 "lpg.generator/templates/java/btParserTemplateF.gi" + case 94: { + //#line 1923 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1917 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1923 "lpg.generator/templates/java/btParserTemplateF.gi" List<Expr> l = new ArrayList<Expr>(); setResult(l); break; } // - // Rule 94: Conjunctionopt ::= Conjunction + // Rule 95: Conjunctionopt ::= Conjunction // - case 94: { - //#line 1923 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1921 "x10/parser/x10.g" + case 95: { + //#line 1929 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1927 "x10/parser/x10.g" List<Expr> Conjunction = (List<Expr>) getRhsSym(1); - //#line 1923 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1929 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(Conjunction); break; } // - // Rule 95: ExistentialListopt ::= $Empty + // Rule 96: ExistentialListopt ::= $Empty // - case 95: { - //#line 1929 "lpg.generator/templates/java/btParserTemplateF.gi" + case 96: { + //#line 1935 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1929 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1935 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(new ArrayList<Formal>()); break; } // - // Rule 96: ExistentialListopt ::= ExistentialList ; + // Rule 97: ExistentialListopt ::= ExistentialList ; // - case 96: { - //#line 1934 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1932 "x10/parser/x10.g" + case 97: { + //#line 1940 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1938 "x10/parser/x10.g" List<Formal> ExistentialList = (List<Formal>) getRhsSym(1); - //#line 1934 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1940 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(ExistentialList); break; } // - // Rule 97: ExistentialList ::= FormalParameter + // Rule 98: ExistentialList ::= FormalParameter // - case 97: { - //#line 1940 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1938 "x10/parser/x10.g" + case 98: { + //#line 1946 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1944 "x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(1); - //#line 1940 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1946 "lpg.generator/templates/java/btParserTemplateF.gi" List<Formal> l = new TypedList<Formal>(new LinkedList<Formal>(), Formal.class, false); l.add(FormalParameter.flags(nf.FlagsNode(X10NodeFactory_c.compilerGenerated(FormalParameter), Flags.FINAL))); setResult(l); @@ -2870,41 +2887,41 @@ } // - // Rule 98: ExistentialList ::= ExistentialList ; FormalParameter + // Rule 99: ExistentialList ::= ExistentialList ; FormalParameter // - case 98: { - //#line 1947 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1945 "x10/parser/x10.g" + case 99: { + //#line 1953 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1951 "x10/parser/x10.g" List<Formal> ExistentialList = (List<Formal>) getRhsSym(1); - //#line 1945 "x10/parser/x10.g" + //#line 1951 "x10/parser/x10.g" X10Formal FormalParameter = (X10Formal) getRhsSym(3); - //#line 1947 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1953 "lpg.generator/templates/java/btParserTemplateF.gi" ExistentialList.add(FormalParameter.flags(nf.FlagsNode(X10NodeFactory_c.compilerGenerated(FormalParameter), Flags.FINAL))); break; } // - // Rule 101: NormalClassDeclaration ::= Modifiersopt class Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody + // Rule 102: NormalClassDeclaration ::= Modifiersopt class Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Superopt Interfacesopt ClassBody // - case 101: { - //#line 1958 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1956 "x10/parser/x10.g" + case 102: { + //#line 1964 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1962 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" List<TypeParamNode> TypeParamsWithVarianceopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" List<PropertyDecl> Propertiesopt = (List<PropertyDecl>) getRhsSym(5); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" TypeNode Superopt = (TypeNode) getRhsSym(7); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" List<TypeNode> Interfacesopt = (List<TypeNode>) getRhsSym(8); - //#line 1956 "x10/parser/x10.g" + //#line 1962 "x10/parser/x10.g" ClassBody ClassBody = (ClassBody) getRhsSym(9); - //#line 1958 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1964 "lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkClassModifiers(Modifiersopt); checkTypeName(Identifier); List<TypeParamNode> TypeParametersopt = TypeParamsWithVarianceopt; @@ -2921,25 +2938,25 @@ } // - // Rule 102: StructDeclaration ::= Modifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Interfacesopt ClassBody + // Rule 103: StructDeclaration ::= Modifiersopt struct Identifier TypeParamsWithVarianceopt Propertiesopt WhereClauseopt Interfacesopt ClassBody // - case 102: { - //#line 1976 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1974 "x10/parser/x10.g" + case 103: { + //#line 1982 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1980 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" Id Identifier = (Id) getRhsSym(3); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" List<TypeParamNode> TypeParamsWithVarianceopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" List<PropertyDecl> Propertiesopt = (List<PropertyDecl>) getRhsSym(5); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" List<TypeNode> Interfacesopt = (List<TypeNode>) getRhsSym(7); - //#line 1974 "x10/parser/x10.g" + //#line 1980 "x10/parser/x10.g" ClassBody ClassBody = (ClassBody) getRhsSym(8); - //#line 1976 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1982 "lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkClassModifiers(Modifiersopt); checkTypeName(Identifier); List<TypeParamNode> TypeParametersopt = TypeParamsWithVarianceopt; @@ -2954,25 +2971,25 @@ } // - // Rule 103: ConstructorDeclaration ::= Modifiersopt def this TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt ConstructorBody + // Rule 104: ConstructorDeclaration ::= Modifiersopt def this TypeParametersopt FormalParameters WhereClauseopt HasResultTypeopt Offersopt ConstructorBody // - case 103: { - //#line 1991 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 1989 "x10/parser/x10.g" + case 104: { + //#line 1997 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1995 "x10/parser/x10.g" List<Modifier> Modifiersopt = (List<Modifier>) getRhsSym(1); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" List<TypeParamNode> TypeParametersopt = (List<TypeParamNode>) getRhsSym(4); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" List<Formal> FormalParameters = (List<Formal>) getRhsSym(5); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" DepParameterExpr WhereClauseopt = (DepParameterExpr) getRhsSym(6); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" TypeNode HasResultTypeopt = (TypeNode) getRhsSym(7); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" TypeNode Offersopt = (TypeNode) getRhsSym(8); - //#line 1989 "x10/parser/x10.g" + //#line 1995 "x10/parser/x10.g" Block ConstructorBody = (Block) getRhsSym(9); - //#line 1991 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 1997 "lpg.generator/templates/java/btParserTemplateF.gi" List<Node> modifiers = checkConstructorModifiers(Modifiersopt); ConstructorDecl cd = nf.X10ConstructorDecl(pos(), extractFlags(modifiers), @@ -2990,73 +3007,73 @@ } // - // Rule 104: Super ::= extends ClassType + // Rule 105: Super ::= extends ClassType // - case 104: { - //#line 2009 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2007 "x10/parser/x10.g" + case 105: { + //#line 2015 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 2013 "x10/parser/x10.g" TypeNode ClassType = (TypeNode) getRhsSym(2); - //#line 2009 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 2015 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(ClassType); break; } // - // Rule 105: FieldKeyword ::= val + // Rule 106: FieldKeyword ::= val // - case 105: { - //#line 2015 "lpg.generator/templates/java/btParserTemplateF.gi" + case 106: { + //#line 2021 "lpg.generator/templates/java/btParserTemplateF.gi" - //#line 2015 "lpg.generator/templates/java/btParserTemplateF.gi" + //#line 2021 "lpg.generator/templates/java/btParserTemplateF.gi" setResult(Collections.singletonList(nf.FlagsNode(pos(), Flags.FINAL))); break; } // - // Rule 106: FieldKeyword ::= var + // Rule 107: FieldKeyword ::= var ... [truncated message content] |
From: <vj...@us...> - 2010-10-04 01:32:49
|
Revision: 16899 http://x10.svn.sourceforge.net/x10/?rev=16899&view=rev Author: vj0 Date: 2010-10-04 01:32:43 +0000 (Mon, 04 Oct 2010) Log Message: ----------- Improve type-checking. Go back to the original plan of simply checking that each literal is of the given type. This is the desired semantics. The short cut of checking that the lub of the literal types is a subtype of the given type is not correct. Modified Paths: -------------- trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java trunk/x10.compiler/src/x10/errors/Errors.java Added Paths: ----------- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 Modified: trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java =================================================================== --- trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-04 01:13:49 UTC (rev 16898) +++ trunk/x10.compiler/src/x10/ast/ArrayLiteral_c.java 2010-10-04 01:32:43 UTC (rev 16899) @@ -102,9 +102,13 @@ new Errors.ArrayLiteralMustBeOfArrayType(array.type().toString(), n.position())); Type aType = X10TypeMixin.typeArg(type,0); - if (! ts.isSubtype(aType, iType, tc.context())) - Errors.issue(tc.job(), - new Errors.ArrayLiteralTypeMismatch(type, iType, n.position())); + List<Expr> vals = tuple.arguments(); + for (Expr e : vals) { + Type t = e.type(); + if (! ts.isSubtype(t, iType, tc.context())) + Errors.issue(tc.job(), + new Errors.ArrayLiteralTypeMismatch(e, iType)); + } Type resultType = X10TypeMixin.makeArrayRailOf(iType, n.tuple().arguments().size(), n.position()); return n.type(resultType); Modified: trunk/x10.compiler/src/x10/errors/Errors.java =================================================================== --- trunk/x10.compiler/src/x10/errors/Errors.java 2010-10-04 01:13:49 UTC (rev 16898) +++ trunk/x10.compiler/src/x10/errors/Errors.java 2010-10-04 01:32:43 UTC (rev 16899) @@ -699,10 +699,11 @@ } public static class ArrayLiteralTypeMismatch extends EqualByTypeAndPosException { private static final long serialVersionUID = -8344153029213631407L; - public ArrayLiteralTypeMismatch(Type atype, Type itype, Position pos) { - super("The computed type of element literals is not a subtype of the given type" - + "\n\t: computed type: " + atype - + "\n\t: given type: " + itype, pos); + public ArrayLiteralTypeMismatch(Expr e, Type itype) { + super("The literal is not of the given type" + + "\n\t expr:" + e + + "\n\t type: " + e.type() + + "\n\t desired type: " + itype, e.position()); } } } Added: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1.x10 2010-10-04 01:32:43 UTC (rev 16899) @@ -0,0 +1,34 @@ +/* + * 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; + +/** + * Array Literal test. Same as ArrayLiteralTest except that the declared type of the array is more precise. + */ + +public class ArrayLiteralTest1 extends x10Test { + + public def run(): boolean = { + + val e = 0..9; + val r = [1, 2, 3]; + val a = new Array[Int{self!=0}][1,2,3]; + var sumr:int=0, suma:int=0; + for (i in a.items()) suma += i; + for (i in r.items()) sumr +=i; + return suma==6 && sumr==6; + } + + public static def main(Array[String](1)): Void = { + new ArrayLiteralTest1().execute(); + } +} Added: trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 (rev 0) +++ trunk/x10.tests/examples/Constructs/Array/ArrayLiteralTest1_MustFailCompile.x10 2010-10-04 01:32:43 UTC (rev 16899) @@ -0,0 +1,36 @@ +/* + * 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; + +/** + * Array Literal test. Same as ArrayLiteralTest except that the declared type of the array is more precise. + */ + +public class ArrayLiteralTest1_MustFailCompile extends x10Test { + + public def run(): boolean = { + + val e = 0..9; + val r = [1, 2, 3]; + val a = new Array[Int{self!=0}][ + 0, // this should give a compilation error. + 1,2,3]; + var sumr:int=0, suma:int=0; + for (i in a.items()) suma += i; + for (i in r.items()) sumr +=i; + return suma==6 && sumr==6; + } + + public static def main(Array[String](1)): Void = { + new ArrayLiteralTest1_MustFailCompile().execute(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dgr...@us...> - 2010-10-04 02:21:10
|
Revision: 16900 http://x10.svn.sourceforge.net/x10/?rev=16900&view=rev Author: dgrove-oss Date: 2010-10-04 02:21:03 +0000 (Mon, 04 Oct 2010) Log Message: ----------- C++ backend for tuples as array literals. More efficient Java backend support for same (avoids creating ValRail in the middle). Modified Paths: -------------- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java trunk/x10.runtime/src-java/x10/core/RailFactory.java Modified: trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java =================================================================== --- trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-10-04 01:32:43 UTC (rev 16899) +++ trunk/x10.compiler/src/x10/visit/X10PrettyPrinterVisitor.java 2010-10-04 02:21:03 UTC (rev 16900) @@ -1659,16 +1659,11 @@ public void visit(Tuple_c c) { Type t = X10TypeMixin.getParameterType(c.type(), 0); - w.write("x10.array.Array.<"); - new TypeExpander(er, t, true, true, false).expand(); - w.write(">"); - w.write("make_0_$_x10$array$Array_T_$("); - new RuntimeTypeExpander(er, t).expand(); - w.write(", "); + w.write("x10.core.RailFactory.<"); new TypeExpander(er, t, true, true, false).expand(); w.write(">"); - w.write("makeValRailFromJavaArray("); + w.write("makeArrayFromJavaArray("); new RuntimeTypeExpander(er, t).expand(); w.write(", "); if (X10TypeMixin.baseType(t) instanceof ParameterType) { @@ -1684,7 +1679,6 @@ w.write("}"); } w.write(")"); - w.write(")"); } Modified: trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java =================================================================== --- trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-04 01:32:43 UTC (rev 16899) +++ trunk/x10.compiler/src/x10cpp/visit/MessagePassingCodeGenerator.java 2010-10-04 02:21:03 UTC (rev 16900) @@ -1020,7 +1020,7 @@ // (h,cc) pairing for non-generic classes. // TODO: sort by namespace and combine things in the same namespace - X10SearchVisitor<Node> xTypes = new X10SearchVisitor<Node>(X10CanonicalTypeNode_c.class, Closure_c.class); + X10SearchVisitor<Node> xTypes = new X10SearchVisitor<Node>(X10CanonicalTypeNode_c.class, Closure_c.class, Tuple_c.class); n.visit(xTypes); ArrayList<ClassType> types = new ArrayList<ClassType>(); Set<ClassType> dupes = new HashSet<ClassType>(); @@ -1036,6 +1036,8 @@ ClassType c = t.type().toClass(); assert (c.interfaces().size() == 1); extractAllClassTypes(c.interfaces().get(0), types, dupes); + } else if (tn instanceof Tuple_c) { + extractAllClassTypes(((Tuple_c) tn).type(), types, dupes); } } } @@ -4825,36 +4827,28 @@ return (t.isBoolean() || t.isByte() || t.isShort() || t.isInt() || t.isLong() || t.isFloat() || t.isDouble()); } - private static final int NON_POD_LIMIT = 6; public void visit(Tuple_c c) { X10TypeSystem_c xts = (X10TypeSystem_c) tr.typeSystem(); Context context = tr.context(); - // Handles Rails initializer. + // Handles Array initializer. Type T = X10TypeMixin.getParameterType(c.type(), 0); String type = Emitter.translateType(c.type()); - boolean needsInitLoop = !isPODType(T) && c.arguments().size() > NON_POD_LIMIT; String tmp = getId(); // [DC] this cast is needed to ensure everything has a ref type // otherwise overloads don't seem to work properly sw.write("("+make_ref(type)+")"); - if (needsInitLoop) { - sw.write("(__extension__ ({"); - sw.newline(4); sw.begin(0); - sw.write(type+"* "+tmp+" = "); - } - sw.write("x10aux::alloc_rail<"); - sw.write(Emitter.translateType(T, true)); - sw.write(","); - sw.allowBreak(0, " "); - sw.write(type); - sw.write(" >("+c.arguments().size()); + + sw.write("(__extension__ ({"); + sw.newline(4); sw.begin(0); + sw.write(make_ref(type)+" "+tmp+"("); + + sw.write("x10::array::Array"+chevrons(Emitter.translateType(T, true))); + sw.writeln("::_make("+c.arguments().size()+"));"); int count = 0; for (Expr e : c.arguments()) { - if (needsInitLoop && ++count > NON_POD_LIMIT) - break; - sw.write(","); + sw.write(tmp+"->set("); boolean rhsNeedsCast = !xts.typeDeepBaseEquals(T, e.type(), context); if (rhsNeedsCast) { // Cast is needed to ensure conversion/autoboxing. @@ -4864,35 +4858,11 @@ c.printSubExpr(e, false, sw, tr); if (rhsNeedsCast) sw.write(")"); + sw.writeln(", "+(count++)+");"); } - sw.write(")"); - if (needsInitLoop) { - sw.write(";"); - sw.newline(); - String raw = getId(); - sw.write(Emitter.translateType(T, true)+"* "+raw+" = "+tmp+"->raw();"); - sw.newline(); - count = 0; - for (Expr e : c.arguments()) { - if (++count <= NON_POD_LIMIT) - continue; - sw.write(raw+"["+(count-1)+"] = "); - boolean rhsNeedsCast = !xts.typeDeepBaseEquals(T, e.type(), context); - if (rhsNeedsCast) { - // Cast is needed to ensure conversion/autoboxing. - // However, it is statically correct to do the assignment, therefore it can be unchecked. - sw.write("x10aux::class_cast_unchecked" + chevrons(Emitter.translateType(T, true)) + "("); - } - c.printSubExpr(e, false, sw, tr); - if (rhsNeedsCast) - sw.write(")"); - sw.write(";"); - sw.newline(); - } - sw.write(tmp+";"); - sw.end(); sw.newline(); - sw.write("}))"); - } + sw.write(tmp+";"); + sw.end(); sw.newline(); + sw.write("}))"); } public void visit(When_c n) { Modified: trunk/x10.runtime/src-java/x10/core/RailFactory.java =================================================================== --- trunk/x10.runtime/src-java/x10/core/RailFactory.java 2010-10-04 01:32:43 UTC (rev 16899) +++ trunk/x10.runtime/src-java/x10/core/RailFactory.java 2010-10-04 02:21:03 UTC (rev 16900) @@ -92,10 +92,17 @@ // return new ValRail<T>(r.type, r.length, r.value); // } + public static <T> x10.array.Array<T> makeArrayFromJavaArray(Type type, Object array) { + int len = type.arrayLength(array); + x10.array.Array<T> arr = new x10.array.Array(type, len); + System.arraycopy(array, 0, arr.raw, 0, len); + return arr; + } + public static <T> Rail<T> makeRailFromJavaArray(Type type, Object array) { return new Rail<T>(type, type.arrayLength(array) , array); } - + public static <T> ValRail<T> makeValRailFromJavaArray(Type type, Object array) { return new ValRail<T>(type, type.arrayLength(array), array); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-10-04 19:19:41
|
Revision: 16928 http://x10.svn.sourceforge.net/x10/?rev=16928&view=rev Author: tardieu Date: 2010-10-04 19:19:35 +0000 (Mon, 04 Oct 2010) Log Message: ----------- fixed issues with desugaring of clocked code: - undefined var in c++ codegen - use of valrails (replaced by Array[Clock]{rail}) added helper method in X10TypeMixin to create the Array[T]{rail} type updated array litteral syntax in various clock tests (many clock tests still fail with the c++ backend due to issues with anonymous classes) Modified Paths: -------------- trunk/x10.compiler/src/x10/types/X10TypeMixin.java trunk/x10.compiler/src/x10/visit/Desugarer.java trunk/x10.runtime/src-x10/x10/lang/Activity.x10 trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest16a.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest18.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 Modified: trunk/x10.compiler/src/x10/types/X10TypeMixin.java =================================================================== --- trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.compiler/src/x10/types/X10TypeMixin.java 2010-10-04 19:19:35 UTC (rev 16928) @@ -130,6 +130,48 @@ } return t; } + /** + * Return the type Array[type]{self.region.rank==1,self.region.rect==true,self.region.zeroBased==true}. + * @param type + * @param pos + * @return + */ + public static Type makeArrayRailOf(Type type, Position pos) { + X10TypeSystem ts = (X10TypeSystem) type.typeSystem(); + Type r = ts.Array(); + Type t = (X10ClassType) X10TypeMixin.instantiate(r, type); + CConstraint c = new CConstraint(); + FieldInstance regionField = ((X10ClassType) t).fieldNamed(Name.make("region")); + if (regionField == null) + throw new InternalCompilerError("Could not find region field of " + t, pos); + FieldInstance rankField = ((X10ClassType) ts.Region()).fieldNamed(Name.make("rank")); + if (rankField == null) + throw new InternalCompilerError("Could not find rank field of " + ts.Region(), pos); + FieldInstance rectField = ((X10ClassType) ts.Region()).fieldNamed(Name.make("rect")); + if (rectField == null) + throw new InternalCompilerError("Could not find rectField field of " + ts.Region(), pos); + FieldInstance zeroBasedField = ((X10ClassType) ts.Region()).fieldNamed(Name.make("zeroBased")); + if (zeroBasedField == null) + throw new InternalCompilerError("Could not find zeroBased field of " + ts.Region(), pos); + try { + + XVar selfRegion = ts.xtypeTranslator().trans(c, c.self(), regionField); + XVar selfRegionRank = ts.xtypeTranslator().trans(c, selfRegion, rankField); + XVar selfRegionRect = ts.xtypeTranslator().trans(c, selfRegion, rectField); + XVar selfRegionZeroBased = ts.xtypeTranslator().trans(c, selfRegion, zeroBasedField); + + XLit rankLiteral = XTerms.makeLit(1); + c.addBinding(selfRegionRank, rankLiteral); + c.addBinding(selfRegionRect, XTerms.TRUE); + c.addBinding(selfRegionZeroBased, XTerms.TRUE); + c.toString(); + t = X10TypeMixin.xclause(t, c); + + } catch (XFailure z) { + throw new InternalCompilerError("Could not create Array[T]{self.region.rank==1,self.region.rect==true,self.region.zeroBased==true}"); + } + return t; + } public static Type typeArg(Type t, int i) { if (t instanceof X10ParsedClassType) { X10ParsedClassType ct = (X10ParsedClassType) t; Modified: trunk/x10.compiler/src/x10/visit/Desugarer.java =================================================================== --- trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.compiler/src/x10/visit/Desugarer.java 2010-10-04 19:19:35 UTC (rev 16928) @@ -220,7 +220,7 @@ final Name outerVarName = xc.getNewVarName(); final LocalDef outerLi = xts.localDef(pos, flags, Types.ref(type), outerVarName); final Id outerVarId = xnf.Id(pos, outerVarName); - final Local outerLdRef = (Local) xnf.Local(pos, outerVarId).localInstance(li.asInstance()).type(type); + final Local outerLdRef = (Local) xnf.Local(pos, outerVarId).localInstance(outerLi.asInstance()).type(type); try { Expr clock = synth.makeStaticCall(pos, type, Name.make("make"), type, xc); @@ -594,7 +594,7 @@ } if (clocks.size() == 0) return async(pos, body, place, annotations); - Type clockRailType = xts.ValRail(xts.Clock()); + Type clockRailType = X10TypeMixin.makeArrayRailOf(xts.Clock(), pos); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { place, clockRail })), @@ -613,7 +613,7 @@ private Stmt async(Position pos, Stmt body, List<Expr> clocks, List<X10ClassType> annotations) throws SemanticException { if (clocks.size() == 0) return async(pos, body, annotations); - Type clockRailType = xts.ValRail(xts.Clock()); + Type clockRailType = X10TypeMixin.makeArrayRailOf(xts.Clock(), pos); Tuple clockRail = (Tuple) xnf.Tuple(pos, clocks).type(clockRailType); return makeAsyncBody(pos, new ArrayList<Expr>(Arrays.asList(new Expr[] { clockRail })), new ArrayList<Type>(Arrays.asList(new Type[] { clockRailType})), body, annotations); Modified: trunk/x10.runtime/src-x10/x10/lang/Activity.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Activity.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.runtime/src-x10/x10/lang/Activity.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -83,7 +83,7 @@ /** * Create clocked activity. */ - def this(body:()=>Void, finishState:Runtime.FinishState, clocks:ValRail[Clock], phases:ValRail[Int]) { + def this(body:()=>Void, finishState:Runtime.FinishState, clocks:Array[Clock]{rail}, phases:Array[Int]{rail}) { this(body, finishState, false); clockPhases = Runtime.ClockPhases.make(clocks, phases); } Modified: trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.runtime/src-x10/x10/lang/Runtime.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -173,15 +173,15 @@ static class ClockPhases extends HashMap[Clock,Int] { - static def make(clocks:ValRail[Clock], phases:ValRail[Int]):ClockPhases { + static def make(clocks:Array[Clock]{rail}, phases:Array[Int]{rail}):ClockPhases { val clockPhases = new ClockPhases(); - for(var i:Int = 0; i < clocks.length; i++) + for(var i:Int = 0; i < clocks.size; i++) clockPhases.put(clocks(i), phases(i)); return clockPhases; } - def register(clocks:ValRail[Clock]) { - return ValRail.make[Int](clocks.length, (i:Int)=>clocks(i).register()); + def register(clocks:Array[Clock]{rail}) { + return new Array[Int](clocks.size, (i:Int)=>clocks(i).register()); } def next() { @@ -1566,7 +1566,7 @@ /** * Run async */ - public static def runAsync(place:Place, clocks:ValRail[Clock], body:()=>void):void { + public static def runAsync(place:Place, clocks:Array[Clock]{rail}, body:()=>void):void { // Do this before anything else activity().ensureNotInAtomic(); @@ -1603,7 +1603,7 @@ } } - public static def runAsync(clocks:ValRail[Clock], body:()=>void):void { + public static def runAsync(clocks:Array[Clock]{rail}, body:()=>void):void { // Do this before anything else activity().ensureNotInAtomic(); Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest16a.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest16a.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest16a.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -47,7 +47,7 @@ finish async { val c0 = Clock.make(); val c1 = Clock.make(); - val ca: Rail[Clock] = Rail.make([c0,c1]); + val ca = [c0,c1]; (ca(0)).drop(); // Question: @@ -90,7 +90,7 @@ } }; - val fooArray = Rail.make([f0 as foo,f1 as foo]); + val fooArray = [f0 as foo,f1 as foo]; // Compiler: MAYBE, actual: NO // must have a compiler error @@ -164,7 +164,7 @@ * for a typical compiler */ static class X { - public val z = Rail.make[int]([1,0]); + public val z = [1,0]; def zero(): int = { return z(z(z(1))); } def one(): int = { return z(z(z(0))); } def modify(): void = { z(0) += 1; } Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest17_MustFailTimeout.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -69,7 +69,7 @@ } }; - val fooArray: Rail[foo] = Rail.make([f0 as foo ,f1 as foo]); + val fooArray = [f0 as foo ,f1 as foo]; // This is invoking Y.test(f0) but not clear to a compiler Y.test(fooArray(x.zero())); @@ -126,7 +126,7 @@ * for a typical compiler */ static class X { - public val z:Rail[Int] = Rail.make([1,0]); + public val z = [1,0]; def zero(): int = { return z(z(z(1))); } def one(): int = { return z(z(z(0))); } def modify(): void = { z(0) += 1; } Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest18.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest18.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest18.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -51,7 +51,7 @@ } }; - var fooArray: Rail[foo] = Rail.make([f0,f1]); + val fooArray = [f0,f1]; x10.io.Console.OUT.println("#A0 before resume"); c0.resume(); x10.io.Console.OUT.println("#A0 before spawning A3"); @@ -104,7 +104,7 @@ * for a typical compiler */ static class X { - public val z = Rail.make[int]([1,0]); + public val z = [1,0]; def zero(): int = { return z(z(z(1))); /* that is a 0 */ } def one(): int = { return z(z(z(0))); /* that is a 1 */ } def modify(): void = { z(0) += 1; } Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 2010-10-04 19:10:42 UTC (rev 16927) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 2010-10-04 19:19:35 UTC (rev 16928) @@ -42,7 +42,7 @@ try { finish async { var bc: BoxedClock = new BoxedClock(Clock.make()); - var ca: Rail[Clock] = Rail.make([Clock.make(), bc.val ]); + val ca = [Clock.make(), bc.val ]; val c1: Clock = ca(1); val c2: Clock = c1; //aliased clocks c2 and c1 val c3: Clock = ca(0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ta...@us...> - 2010-10-05 01:22:13
|
Revision: 16970 http://x10.svn.sourceforge.net/x10/?rev=16970&view=rev Author: tardieu Date: 2010-10-05 01:22:07 +0000 (Tue, 05 Oct 2010) Log Message: ----------- fixed two MultipleException regressions Modified Paths: -------------- trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 Modified: trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 =================================================================== --- trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2010-10-05 00:47:05 UTC (rev 16969) +++ trunk/x10.runtime/src-x10/x10/lang/MultipleExceptions.x10 2010-10-05 01:22:07 UTC (rev 16970) @@ -19,7 +19,7 @@ * @author Christian Grothoff * @author tardieu */ -public class MultipleExceptions(exceptions:Array[Throwable]) extends RuntimeException { +public class MultipleExceptions(exceptions:Array[Throwable]{rail}) extends RuntimeException { public def this(stack:Stack[Throwable]) { val s = new Stack[Throwable](); Modified: trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 =================================================================== --- trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 2010-10-05 00:47:05 UTC (rev 16969) +++ trunk/x10.tests/examples/Constructs/Clock/ClockTest8.x10 2010-10-05 01:22:07 UTC (rev 16970) @@ -57,7 +57,7 @@ } } catch (e: MultipleExceptions) { x10.io.Console.OUT.println("MultipleExceptions"); - return e.exceptions.length == 1 && e.exceptions(0) instanceof ClockUseException; + return e.exceptions.size == 1 && e.exceptions(0) instanceof ClockUseException; } catch (e: ClockUseException) { x10.io.Console.OUT.println("ClockUseException"); return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |