Changeset 2022
- Timestamp:
- 06/19/08 18:16:57 (5 months ago)
- Files:
-
- trunk/ProjectFortress/astgen/Fortress.ast (modified) (1 diff)
- trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java (modified) (2 diffs)
- trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (11 diffs)
- trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java (modified) (3 diffs)
- trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java (modified) (2 diffs)
- trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSToLValue.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/ProjectFortress/astgen/Fortress.ast
r2019 r2022 1120 1120 FieldRef(Id field); 1121 1121 /** 1122 * A field selection, for sure1123 * (though its implementation might be a getter/setter)1124 * Names of "field" must be unqualified.1125 *1126 * field reference rewritten by interpreter.evaluator.LHSToLValue1127 */1128 FieldRefForSure(Id field);1129 /**1130 1122 * A rewritten field ref (not a getter/setter) 1131 1123 * also used to disambiguate lexical references to self/parent trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java
r1895 r2022 728 728 // } 729 729 // 730 // public Node forFieldRefForSureOnly(FieldRefForSure that, Expr obj_result, Id field_result) {731 // if (that.getObj() == obj_result && that.getField() == field_result) return that;732 // else return new FieldRefForSure(that.getSpan(), that.isParenthesized(), obj_result, field_result);733 // }734 //735 730 // public Node for_RewriteFieldRefOnly(_RewriteFieldRef that, Expr obj_result, Name field_result) { 736 731 // if (that.getObj() == obj_result && that.getField() == field_result) return that; … … 1931 1926 // } 1932 1927 // 1933 // public Node forFieldRefForSure(FieldRefForSure that) {1934 // Expr obj_result = (Expr) that.getObj().accept(this);1935 // Id field_result = (Id) that.getField().accept(this);1936 // return forFieldRefForSureOnly(that, obj_result, field_result);1937 // }1938 //1939 1928 // public Node for_RewriteFieldRef(_RewriteFieldRef that) { 1940 1929 // Expr obj_result = (Expr) that.getObj().accept(this); trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r2019 r2022 1725 1725 } 1726 1726 @Override 1727 public Option<? extends IdOrOpOrAnonymousName> forFieldRefForSure(1728 FieldRefForSure that) {1729 return Option.some(that.getField());1730 }1731 @Override1732 1727 public Option<? extends IdOrOpOrAnonymousName> forLValueBind( 1733 1728 LValueBind that) { … … 2273 2268 subtypeChecker, function_result, argument_result, result); 2274 2269 } 2275 2270 2276 2271 @Override 2277 2272 public TypeCheckerResult for_RewriteObjectRefOnly(_RewriteObjectRef that, 2278 2273 TypeCheckerResult obj_result, 2279 2274 List<TypeCheckerResult> staticArgs_result) { 2280 2275 2281 2276 if( obj_result.type().isNone() ) { 2282 2277 return TypeCheckerResult.compose(that, subtypeChecker, obj_result, … … 2293 2288 if( match ) { 2294 2289 // make a trait type that is GenericType instantiated 2295 Type t = NodeFactory.makeTraitType(uninstantiated_t.getSpan(), 2290 Type t = NodeFactory.makeTraitType(uninstantiated_t.getSpan(), 2296 2291 uninstantiated_t.isParenthesized(), uninstantiated_t.getName(), that.getStaticArgs()); 2297 2292 return TypeCheckerResult.compose(that, t, subtypeChecker, obj_result, 2298 TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 2293 TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 2299 2294 } 2300 2295 else { … … 2303 2298 TypeCheckerResult e_result = new TypeCheckerResult(that, TypeError.make(err, that)); 2304 2299 return TypeCheckerResult.compose(that, subtypeChecker, obj_result, e_result, 2305 TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 2300 TypeCheckerResult.compose(that, subtypeChecker, staticArgs_result)); 2306 2301 } 2307 2302 } … … 2310 2305 } 2311 2306 } 2312 2307 2313 2308 // Checks the chunk given, and returns the result and a new expression. 2314 2309 // Requires that all TypeCheckerResults passed in actually have a type. … … 2317 2312 assert(!chunk.isEmpty()); 2318 2313 // The non-functions in each chunk, if any, are replaced by a single element consisting of the non-functions grouped 2319 // left-associatively into binary juxtapositions. 2314 // left-associatively into binary juxtapositions. 2320 2315 Option<Expr> last_non_fn = Option.none(); 2321 2316 List<Expr> fns = new LinkedList<Expr>(); … … 2342 2337 } 2343 2338 // We are done. result_expr must be some or this method wasn't implemented correctly. 2344 TypeCheckerResult result = TypeCheckerResult.compose(result_expr.unwrap(), subtypeChecker, 2339 TypeCheckerResult result = TypeCheckerResult.compose(result_expr.unwrap(), subtypeChecker, 2345 2340 IterUtil.asList(IterUtil.pairFirsts(chunk))); 2346 2341 return Pair.make(result, result_expr.unwrap()); 2347 2342 } 2348 2343 2349 2344 @Override 2350 2345 public TypeCheckerResult forLooseJuxtOnly(LooseJuxt that, … … 2355 2350 // the ordering of association is different. 2356 2351 // Notice also that tightJuxt has to be recursive, but loose juxt is not, due to specification. 2357 2352 2358 2353 // Did any subexpressions fail to typecheck? 2359 2354 for( TypeCheckerResult r : exprs_result ) { 2360 2355 if( r.type().isNone()) 2361 return TypeCheckerResult.compose(that, subtypeChecker, exprs_result); 2362 } 2363 2356 return TypeCheckerResult.compose(that, subtypeChecker, exprs_result); 2357 } 2358 2364 2359 if( that.getExprs().size() != exprs_result.size() ) { 2365 2360 bug("Number of types don't match number of sub-expressions"); … … 2371 2366 Iterator<Expr> expr_iter = that.getExprs().iterator(); 2372 2367 boolean seen_non_fn = false; 2373 // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed 2374 // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of 2375 // functions followed by some number (possibly zero) of non-functions. 2368 // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed 2369 // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of 2370 // functions followed by some number (possibly zero) of non-functions. 2376 2371 for( TypeCheckerResult r : exprs_result ) { 2377 boolean is_arrow = TypesUtil.isArrows(r.type().unwrap()); 2372 boolean is_arrow = TypesUtil.isArrows(r.type().unwrap()); 2378 2373 if( is_arrow && seen_non_fn ) { 2379 2374 // finished last chunk … … 2399 2394 List<Expr> new_juxt_exprs = IterUtil.asList(IterUtil.pairSeconds(checked_chunks)); 2400 2395 List<TypeCheckerResult> new_juxt_results = IterUtil.asList(IterUtil.pairFirsts(checked_chunks)); 2401 2396 2402 2397 if( checked_chunks.size() == 1 ) { 2403 2398 Expr expr = IterUtil.first(new_juxt_exprs); … … 2408 2403 // (1) If any element that remains has type String, then it is a static error if any two adjacent elements are not of type String. 2409 2404 // TODO: Separate pass? 2410 // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply: 2405 // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply: 2411 2406 OpExpr multi_op_expr = new OpExpr(that.getSpan(), that.getMultiJuxt(), new_juxt_exprs); 2412 2407 TypeCheckerResult multi_op_result = multi_op_expr.accept(this); trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java
r2019 r2022 92 92 import com.sun.fortress.nodes.ExtentRange; 93 93 import com.sun.fortress.nodes.FieldRef; 94 import com.sun.fortress.nodes.FieldRefForSure;95 94 import com.sun.fortress.nodes.Link; 96 95 import com.sun.fortress.nodes.MethodInvocation; … … 805 804 } 806 805 807 @Override808 public FValue forFieldRefForSure(FieldRefForSure x) {809 return forFieldRefCommon(x, x.getField());810 }811 812 806 private FValue forFieldRefCommon(AbstractFieldRef x, Name fld) throws FortressException, 813 807 ProgramError { … … 1361 1355 return ((FieldRef)arf).getField(); 1362 1356 } 1363 if (arf instanceof FieldRefForSure) {1364 return ((FieldRefForSure)arf).getField();1365 1366 }1367 1357 if (arf instanceof _RewriteFieldRef) { 1368 1358 return ((_RewriteFieldRef)arf).getField(); trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java
r1895 r2022 45 45 import com.sun.fortress.interpreter.glue.WellKnownNames; 46 46 import com.sun.fortress.nodes.AbstractFieldRef; 47 import com.sun.fortress.nodes.FieldRefForSure;48 47 import com.sun.fortress.nodes.Name; 49 48 import com.sun.fortress.nodes.NodeAbstractVisitor; … … 127 126 } 128 127 129 @Override130 public Voidoid forFieldRefForSure(FieldRefForSure x) {131 return forFieldRefCommon(x, x.getField());132 }133 134 135 136 128 LHSEvaluator(Evaluator evaluator, FValue value) { 137 129 this.evaluator = evaluator; this.value = value; trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSToLValue.java
r1983 r2022 24 24 import com.sun.fortress.interpreter.evaluator.values.FObject; 25 25 import com.sun.fortress.interpreter.evaluator.values.FValue; 26 import com.sun.fortress.nodes.FieldRefForSure;27 26 import com.sun.fortress.nodes.NodeAbstractVisitor; 28 27 import com.sun.fortress.nodes.Expr; … … 115 114 116 115 @Override 117 public LHS forFieldRefForSure(FieldRefForSure x) {118 Expr from = wrapEval(x.getObj(), "Non-object in field selection");119 // TODO need to generalize to dotted names.120 return new FieldRefForSure(x.getSpan(), false, from, x.getField());121 }122 123 124 @Override125 116 public LHS for_RewriteFieldRef(_RewriteFieldRef x) { 126 117 Expr from = wrapEval(x.getObj(), "Non-object in field selection");
