Changeset 3101
- Timestamp:
- 11/25/08 10:43:53 (12 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 6 modified
-
astgen/Fortress.ast (modified) (4 diffs)
-
src/com/sun/fortress/compiler/OverloadRewriteVisitor.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (27 diffs)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (1 diff)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3100 r3101 693 693 * AssignOp ::= := | Op= 694 694 * e.g.) x += 1 695 * /696 Assignment(List<Lhs> lhs, Option<OpRef> opr, Expr rhs);697 /**698 * An assignment that has passed typechecking, and uses an operator.699 * Because different static args can be inferred for each Lhs assignment700 * opr, this node gives a separate OpRef for each Lhs.701 */702 _RewriteAssignment(List<OpRef> opsForLhs);695 * 696 * <opsForLhs> 697 * An assignment that has passed typechecking, and uses an operator. 698 * Because different static args can be inferred for each Lhs assignment 699 * opr, this node gives a separate OpRef for each Lhs. 700 */ 701 Assignment(List<Lhs> lhs, Option<OpRef> opr, Expr rhs, 702 Option<List<OpRef>> opsForLhs = Option.<List<OpRef>>none()); 703 703 /** 704 704 * sequence of block elements implicitly enclosed by do/end … … 1087 1087 * Primary ::= Id[\StaticArgList\] 1088 1088 * e.g.) identity[\String\] 1089 * 1090 * <overloadings> 1091 * A list of FnRefs used for infering static arguments. Used only between the two 1092 * passes of the typechecker. Indicates that one of these FnRefs, which each have 1093 * different instantiations of static arguments, should be the correct instantiation. 1089 1094 */ 1090 1095 FnRef(Id originalName, 1091 List<Id> fns = Collections.<Id>singletonList(in_originalName)); 1092 /** 1093 * A list of FnRefs used for infering static arguments. Used only between the two 1094 * passes of the typechecker. Indicates that one of these FnRefs, which each have 1095 * different instantiations of static arguments, should be the correct instantiation. 1096 */ 1097 _RewriteInstantiatedFnRefs(List<_RewriteFnRefOverloading> overloadings 1098 = Collections.<_RewriteFnRefOverloading>emptyList()); 1096 List<Id> fns = Collections.<Id>singletonList(in_originalName), 1097 Option<List<_RewriteFnRefOverloading>> overloadings 1098 = Option.<List<_RewriteFnRefOverloading>>none()); 1099 1099 /** 1100 1100 * operator name with (inferred) static instantiations … … 1102 1102 * Primary ::= Op[\StaticArgList\] 1103 1103 * e.g.) +[\String\] 1104 * 1105 * <overloadings> 1106 * Similar to FnRef, this node is used for inferring static 1107 * arguments to an Op call. This node only exists between the first and second 1108 * passes of the typechecker. Holds several different instantiations of static args, 1109 * one of which may be the correct insantiation. 1104 1110 */ 1105 1111 OpRef(OpName originalName, 1106 List<OpName> ops = Collections.<OpName>singletonList(in_originalName)); 1107 /** 1108 * Similar to _RewriteInstantiatedFnRefs, this node is used for inferring static 1109 * arguments to an Op call. This node only exists between the first and second 1110 * passes of the typechecker. Holds several different instantiations of static args, 1111 * one of which may be the correct insantiation. 1112 */ 1113 _RewriteInstantiatedOpRefs(List<_RewriteOpRefOverloading> overloadings = Collections.<_RewriteOpRefOverloading>emptyList()); 1112 List<OpName> ops = Collections.<OpName>singletonList(in_originalName), 1113 Option<List<_RewriteOpRefOverloading>> overloadings 1114 = Option.<List<_RewriteOpRefOverloading>>none()); 1114 1115 /** 1115 1116 * juxtaposition of expressions … … 1978 1979 * CaseClause ::= Expr => BlockElems 1979 1980 * e.g.) { Jupiter, Saturn, Uranus, Neptune } => "outer" 1980 * /1981 CaseClause(Expr match, Block body);1982 /**1983 * A rewritten case clause that includes the operator that is used for this1984 * particular case. Created in typechecking, because different ops can be1985 * chosen for different clauses.1986 */1987 _RewriteCaseClause(OpRef op);1981 * 1982 * <op> 1983 * the operator that is used for this particular case. 1984 * Created in typechecking, 1985 * because different ops can be chosen for different clauses. 1986 */ 1987 CaseClause(Expr match, Block body, 1988 Option<OpRef> op = Option.<OpRef>none()); 1988 1989 /** 1989 1990 * catch clause used in try expressions -
trunk/ProjectFortress/src/com/sun/fortress/compiler/OverloadRewriteVisitor.java
r3092 r3101 37 37 @Override 38 38 public Node forFnRefOnly(FnRef that, Option<Type> exprType_result, 39 List<StaticArg> staticArgs, Id originalName, List<Id> fns) { 39 List<StaticArg> staticArgs, Id originalName, List<Id> fns, 40 Option<List<_RewriteFnRefOverloading>> overloadings) { 40 41 if (fns.size() > 1) { 41 42 Collections.<Id>sort(fns, NodeComparator.idComparer); … … 57 58 fns = Collections.unmodifiableList(Collections.singletonList(overloadingId)); 58 59 } 59 return super.forFnRefOnly(that, exprType_result, staticArgs , originalName, fns); 60 return super.forFnRefOnly(that, exprType_result, staticArgs , originalName, fns, 61 overloadings); 60 62 } 61 63 … … 63 65 @Override 64 66 public Node forOpRefOnly(OpRef that, Option<Type> exprType_result, 65 List<StaticArg> staticArgs, OpName originalName, List<OpName> ops) { 67 List<StaticArg> staticArgs, OpName originalName, List<OpName> ops, 68 Option<List<_RewriteOpRefOverloading>> overloadings) { 66 69 if (ops.size() > 1) { 67 70 Collections.<OpName>sort(ops, NodeComparator.opNameComparer); … … 83 86 ops = Collections.unmodifiableList(Collections.singletonList(overloadingOpName)); 84 87 } 85 return super.forOpRefOnly(that, exprType_result, staticArgs, originalName, ops); 88 return super.forOpRefOnly(that, exprType_result, staticArgs, originalName, ops, 89 overloadings); 86 90 } 87 91 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java
r3098 r3101 518 518 public Node forFnRefOnly(FnRef that, Option<Type> exprType_result, 519 519 List<StaticArg> staticArgs_result, 520 Id fnResult, List<Id> fns_result) { 520 Id fnResult, List<Id> fns_result, 521 Option<List<_RewriteFnRefOverloading>> overloadings_result) { 521 522 // After disambiguation, the Id in a FnRef should have an empty API. 522 523 assert(fnResult.getApi().isNone()); … … 530 531 return ExprFactory.makeFnRef(that, exprType_result, 531 532 mangleName(fnResult), newFns, 532 staticArgs_result );533 staticArgs_result, overloadings_result); 533 534 } else { 534 535 return that; -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3099 r3101 861 861 TypeCheckerResult arg_result = recur(that.getArgument()); 862 862 863 if( postInference && that.getFunction() instanceof _RewriteInstantiatedFnRefs ) { 863 if( postInference && that.getFunction() instanceof FnRef && 864 ((FnRef)that.getFunction()).getOverloadings().isSome() ) { 865 FnRef fns = (FnRef)that.getFunction(); 864 866 // if we have finished typechecking, and we have encountered a reference to an overloaded function 865 _RewriteInstantiatedFnRefs fns = (_RewriteInstantiatedFnRefs)that.getFunction();866 867 867 868 if( !arg_result.isSuccessful() ) { … … 870 871 871 872 Type arg_type = arg_result.type().unwrap(); 872 TypeCheckerResult fn_result = findStaticallyMostApplicableFn(destructFnOverloadings(fns.getOverloadings()), arg_type, fns, fns.getOriginalName()); 873 TypeCheckerResult fn_result = findStaticallyMostApplicableFn(destructFnOverloadings(fns.getOverloadings().unwrap()), 874 arg_type, fns, fns.getOriginalName()); 873 875 // Now just check the rewritten expression by the normal means 874 876 return for_RewriteFnAppOnly(that,Option.<TypeCheckerResult>none(), fn_result, arg_result); … … 876 878 else { 877 879 // Add constraints from the arguments, since they may affect overloading choice 878 TypeCheckerResult fn_result = recur(that.getFunction());880 TypeCheckerResult fn_result = recur(that.getFunction()); 879 881 Iterable<ConstraintFormula> arg_constraint = Collections.singletonList(arg_result.getNodeConstraints()); 880 882 //debugging … … 1276 1278 @Override 1277 1279 public TypeCheckerResult forAssignment(Assignment that) { 1280 if ( that.getOpsForLhs().isSome() ) // postInference pass 1281 return for_Assignment( that ); 1282 1278 1283 Pair<List<Type>, TypeCheckerResult> tuple_types_ = requireTupleType(that.getRhs(), that.getLhs().size()); 1279 1284 … … 1303 1308 Assignment new_node; 1304 1309 if( that.getOpr().isSome() ) { 1305 // Create a _RewriteAssignment, with an OpRef for each LHS1306 new_node = new _RewriteAssignment(that.getSpan(),1307 that.isParenthesized(),1308 Option.<Type>some(Types.VOID),1309 (List<Lhs>)TypeCheckerResult.astFromResults(lhs_results),1310 that.getOpr(),1311 (Expr)rhs_result.ast(),1312 op_refs);1310 // Create a new Assignment, with an OpRef for each LHS 1311 new_node = new Assignment(that.getSpan(), 1312 that.isParenthesized(), 1313 Option.<Type>some(Types.VOID), 1314 (List<Lhs>)TypeCheckerResult.astFromResults(lhs_results), 1315 that.getOpr(), 1316 (Expr)rhs_result.ast(), 1317 Option.<List<OpRef>>some(op_refs)); 1313 1318 } 1314 1319 else { … … 1322 1327 } 1323 1328 // This case could not result in open constraints: If there is an OpRef, this must not be 1324 // the postInference pass, because _RewriteAssignmentNodes should exist instead. If there is1329 // the postInference pass, because AssignmentNodes should exist instead. If there is 1325 1330 // no OpRef, then no open constraints can be created. 1326 1331 return TypeCheckerResult.compose(new_node, Types.VOID, subtypeChecker, rhs_result, … … 1328 1333 } 1329 1334 1330 1331 @Override 1332 public TypeCheckerResult for_RewriteAssignment(_RewriteAssignment that) { 1335 private TypeCheckerResult for_Assignment(Assignment that) { 1333 1336 Pair<List<Type>, TypeCheckerResult> tuple_types_ = requireTupleType(that.getRhs(), that.getLhs().size()); 1334 1337 … … 1356 1359 }; 1357 1360 1358 // Create a _RewriteAssignment, with an OpRef for each LHS1359 Assignment new_node = new _RewriteAssignment(that.getSpan(),1360 that.isParenthesized(),1361 Option.<Type>some(Types.VOID),1362 (List<Lhs>)TypeCheckerResult.astFromResults(lhs_results),1363 that.getOpr(),1364 (Expr)rhs_result.ast(),1365 op_refs);1361 // Create a Assignment, with an OpRef for each LHS 1362 Assignment new_node = new Assignment(that.getSpan(), 1363 that.isParenthesized(), 1364 Option.<Type>some(Types.VOID), 1365 (List<Lhs>)TypeCheckerResult.astFromResults(lhs_results), 1366 that.getOpr(), 1367 (Expr)rhs_result.ast(), 1368 Option.<List<OpRef>>some(op_refs)); 1366 1369 1367 1370 TypeCheckerResult result = TypeCheckerResult.compose(new_node, Types.VOID, subtypeChecker, rhs_result, … … 1372 1375 if( postInference && TypesUtil.containsInferenceVarTypes(new_node) ) { 1373 1376 Pair<Boolean,Node> temp = TypesUtil.closeConstraints(new_node, result); 1374 new_node = ( _RewriteAssignment)temp.second();1377 new_node = (Assignment)temp.second(); 1375 1378 if(!temp.first()){ 1376 1379 String err = "No overloading for " + that.getOpr().unwrap(); … … 1515 1518 // Find the arrow type of the opr, if it is some 1516 1519 Option<TypeCheckerResult> opr_type = (new NodeDepthFirstVisitor<TypeCheckerResult>() { 1517 @Override public TypeCheckerResult for_RewriteInstantiatedOpRefs(_RewriteInstantiatedOpRefs that) { 1520 @Override public TypeCheckerResult forOpRef(OpRef that) { 1521 if ( that.getOverloadings().isSome() ) { 1518 1522 Type args_type = NodeFactory.makeTupleType(Useful.list(arg_type, rhs_type)); 1519 return findStaticallyMostApplicableFn(TypeChecker.destructOpOverLoading(that.getOverloadings() ), args_type, that, that.getOriginalName());1520 }1521 @Override public TypeCheckerResult forOpRef(OpRef that) { 1523 return findStaticallyMostApplicableFn(TypeChecker.destructOpOverLoading(that.getOverloadings().unwrap()), args_type, that, that.getOriginalName()); 1524 } 1525 1522 1526 TypeCheckerResult op_result = TypeChecker.this.recur(that); 1523 1527 if( !op_result.isSuccessful() ) return op_result; … … 1648 1652 TypeCheckerResult match_result = that.getMatch().accept(TypeChecker.this); 1649 1653 TypeCheckerResult body_result = that.getBody().accept(TypeChecker.this); 1650 CaseClause new_node = new CaseClause(that.getSpan(), (Expr)match_result.ast(), (Block)body_result.ast()); 1651 return Triple.make(new_node, match_result, body_result); 1652 } 1653 1654 @Override 1655 public Triple<CaseClause, TypeCheckerResult, TypeCheckerResult> for_RewriteCaseClause(_RewriteCaseClause that) { 1656 TypeCheckerResult match_result = that.getMatch().accept(TypeChecker.this); 1657 TypeCheckerResult body_result = that.getBody().accept(TypeChecker.this); 1658 _RewriteCaseClause new_node = new _RewriteCaseClause(that.getSpan(), (Expr)match_result.ast(), (Block)body_result.ast(), that.getOp()); 1654 CaseClause new_node = new CaseClause(that.getSpan(), (Expr)match_result.ast(), (Block)body_result.ast(), 1655 that.getOp()); 1659 1656 return Triple.<CaseClause,TypeCheckerResult,TypeCheckerResult>make(new_node, match_result, body_result); 1660 1657 } … … 1722 1719 1723 1720 if( postInference ) { 1724 // after inference, the case clause had better be a _RewriteCaseClause.1725 if( !(clause instanceof _RewriteCaseClause) ) return bug("All case clauses should be rewritten to reflect the chosen compare op."); 1726 1727 _RewriteCaseClause rclause = (_RewriteCaseClause)clause; 1728 Pair<Type, TypeCheckerResult> p = for_ RewriteCaseClauseGetType(rclause, param_result_);1721 // after inference, the case clause had better have the op field set 1722 if( clause.getOp().isNone() ) 1723 return bug("All case clauses should be rewritten to reflect the chosen compare op."); 1724 1725 Pair<Type, TypeCheckerResult> p = for_CaseClauseGetType(clause, param_result_); 1729 1726 clause_results.add(p.second()); 1730 1727 clause_types.add(p.first()); … … 1732 1729 else { 1733 1730 // during inference, we'll try to apply the given compare op (if there is one) and otherwise try 1734 // equals and in. We will remake the CaseClasue as a _RewriteCaseClause,with a chosen opr.1731 // equals and in. We will set the op field with a chosen opr. 1735 1732 Pair<Type, TypeCheckerResult> p = forCaseClauseRewriteAndGetType(clause, param_result_, compare_result_, equals_result, in_result); 1736 1733 clause_results.add(p.second()); … … 1775 1772 /** 1776 1773 * Typecheck the clause, using one of the ops (compare, equals, or in), return the type of the right-hand side block, and 1777 * rewrite the CaseClause as a _RewriteCaseClause. All TypeCheckerResults must contain types, and must contain the AST type1774 * rewrite the CaseClause to set the op field. All TypeCheckerResults must contain types, and must contain the AST type 1778 1775 * that is reflected by their name. 1779 1776 */ … … 1831 1828 } 1832 1829 else { 1833 _RewriteCaseClause new_node = new _RewriteCaseClause(clause.getSpan(),1834 (Expr)match_result.ast(),1835 (Block)block_result.ast(),1836 chosen_op);1830 CaseClause new_node = new CaseClause(clause.getSpan(), 1831 (Expr)match_result.ast(), 1832 (Block)block_result.ast(), 1833 Option.<OpRef>some(chosen_op)); 1837 1834 TypeCheckerResult app_result = new TypeCheckerResult(new_node, application_result.unwrap().second()); 1838 1835 Type app_type = application_result.unwrap().first(); … … 1844 1841 } 1845 1842 /** 1843 * pointInference pass 1846 1844 * Typecheck the clause AND return the type of the right-hand side. 1847 1845 */ 1848 private Pair<Type, TypeCheckerResult> for_RewriteCaseClauseGetType(_RewriteCaseClause clause, Option<TypeCheckerResult> param_result_) { 1846 private Pair<Type, TypeCheckerResult> for_CaseClauseGetType(CaseClause clause, Option<TypeCheckerResult> param_result_) { 1847 // after inference, the case clause had better have the op field set 1848 if( clause.getOp().isNone() ) 1849 return bug("All case clauses should be rewritten to reflect the chosen compare op."); 1850 1851 OpRef op = clause.getOp().unwrap(); 1852 1849 1853 TypeCheckerResult match_result = recur(clause.getMatch()); 1850 1854 TypeCheckerResult block_result = recur(clause.getBody()); … … 1858 1862 Type param_type = param_result_.unwrap().type().unwrap(); 1859 1863 1860 if( clause.getOp() instanceof _RewriteInstantiatedOpRefs) {1864 if( op.getOverloadings().isSome() ) { 1861 1865 // Our operator is an overloading, so we should find the statically most applicable one and rewrite 1862 _RewriteInstantiatedOpRefs overloadings = (_RewriteInstantiatedOpRefs)clause.getOp();1863 1866 Type arg_type = NodeFactory.makeTupleType(Useful.list(param_type, match_type)); 1864 1867 TypeCheckerResult app_result_1 = 1865 findStaticallyMostApplicableFn(destructOpOverLoading(overloadings.getOverloadings()), arg_type, overloadings, overloadings.getOriginalName()); 1868 findStaticallyMostApplicableFn(destructOpOverLoading(op.getOverloadings().unwrap()), 1869 arg_type, op, op.getOriginalName()); 1866 1870 1867 1871 if( app_result_1.isSuccessful() ) { … … 1871 1875 1872 1876 if( app_result_2.isSome() ) { 1873 _RewriteCaseClause new_node = new _RewriteCaseClause(clause.getSpan(),1874 (Expr)match_result.ast(),1875 (Block)block_result.ast(),1876 (OpRef)app_result_1.ast());1877 CaseClause new_node = new CaseClause(clause.getSpan(), 1878 (Expr)match_result.ast(), 1879 (Block)block_result.ast(), 1880 Option.<OpRef>some((OpRef)app_result_1.ast())); 1877 1881 TypeCheckerResult app_result_3 = new TypeCheckerResult(new_node, app_result_2.unwrap().second()); 1878 1882 Type app_type = app_result_2.unwrap().first(); 1879 1883 // We still must ensure the type of the application is a Boolean 1880 1884 TypeCheckerResult bool_result = checkSubtype(app_type, Types.BOOLEAN, new_node, 1881 "Result of application of " + clause.getOp()+ " to param and match expression must have type boolean, but had type " + app_type + ".");1885 "Result of application of " + op + " to param and match expression must have type boolean, but had type " + app_type + "."); 1882 1886 return Pair.make(block_type, TypeCheckerResult.compose(new_node, subtypeChecker, bool_result, app_result_3, match_result, block_result)); 1883 1887 } … … 1893 1897 else { 1894 1898 // no overloading, so just do the normal thing 1895 TypeCheckerResult op_result = recur(clause.getOp());1899 TypeCheckerResult op_result = recur(op); 1896 1900 if( !op_result.isSuccessful() ) return Pair.make(block_type, TypeCheckerResult.compose(clause, subtypeChecker, op_result)); 1897 1901 Option<Pair<Type, ConstraintFormula>> app_result_1 = 1898 1902 TypesUtil.applicationType(subtypeChecker, op_result.type().unwrap(), new ArgList(param_type, match_type), downwardConstraint); 1899 1903 if( app_result_1.isSome() ) { 1900 _RewriteCaseClause new_node = new _RewriteCaseClause(clause.getSpan(),1901 (Expr)match_result.ast(),1902 (Block)block_result.ast(),1903 (OpRef)op_result.ast());1904 CaseClause new_node = new CaseClause(clause.getSpan(), 1905 (Expr)match_result.ast(), 1906 (Block)block_result.ast(), 1907 Option.<OpRef>some((OpRef)op_result.ast())); 1904 1908 TypeCheckerResult app_result_2 = new TypeCheckerResult(new_node, app_result_1.unwrap().second()); 1905 1909 Type app_type = app_result_1.unwrap().first(); 1906 1910 // We still must ensure the type of the application is a Boolean 1907 1911 TypeCheckerResult bool_result = checkSubtype(app_type, Types.BOOLEAN, new_node, 1908 "Result of application of " + clause.getOp()+ " to param and match expression must have type boolean, but had type " + app_type + ".");1912 "Result of application of " + op + " to param and match expression must have type boolean, but had type " + app_type + "."); 1909 1913 return Pair.make(block_type, TypeCheckerResult.compose(new_node, subtypeChecker, bool_result, app_result_2, match_result, block_result)); 1910 1914 } 1911 1915 else { 1912 1916 // error 1913 String err = "No overloading of the operator " + clause.getOp()+ " could be found for arguments of type " +1917 String err = "No overloading of the operator " + op + " could be found for arguments of type " + 1914 1918 param_type + " (Param Type) and " + match_type + " (Match Type)."; 1915 1919 TypeCheckerResult e_r = new TypeCheckerResult(clause, TypeError.make(err, clause)); … … 2445 2449 @Override 2446 2450 public TypeCheckerResult forFnRefOnly(final FnRef that, Option<TypeCheckerResult> exprType_result, 2447 List<TypeCheckerResult> staticArgs_result, 2448 TypeCheckerResult originalName_result, 2449 List<TypeCheckerResult> fns_result) { 2451 List<TypeCheckerResult> staticArgs_result, 2452 TypeCheckerResult originalName_result, 2453 List<TypeCheckerResult> fns_result, 2454 Option<List<TypeCheckerResult>> overloadings_result) { 2450 2455 2451 2456 // Could we give a type to each of our fns? … … 2464 2469 2465 2470 // if no static args are provided, and we have several overloadings, we 2466 // will create a _RewriteInstantiatedFnRef2471 // will create a FnRef with the overloadings field set 2467 2472 if( that.getStaticArgs().isEmpty() && TypesUtil.overloadingRequiresStaticArgs(overloaded_types) ) { 2468 2473 // if there is an overloading that requires static args, and we don't have any, we'll … … 2519 2524 Option.<Type>some(new IntersectionType(NodeFactory.makeSetSpan("impossible", arrow_types), arrow_types)); 2520 2525 constraints = accumulated_constraints; 2521 new_node = new _RewriteInstantiatedFnRefs(that.getSpan(),2522 that.isParenthesized(),2523 type,2524 that.getStaticArgs(),2525 that.getLexicalDepth(),2526 that.getOriginalName(),2527 that.getFns(),2528 fn_overloadings);2526 new_node = new FnRef(that.getSpan(), 2527 that.isParenthesized(), 2528 type, 2529 that.getStaticArgs(), 2530 that.getLexicalDepth(), 2531 that.getOriginalName(), 2532 that.getFns(), 2533 Option.<List<_RewriteFnRefOverloading>>some(fn_overloadings)); 2529 2534 } 2530 2535 else { … … 3562 3567 List<TypeCheckerResult> args_result = recurOnListOfExpr(that.getArgs()); 3563 3568 3564 if( postInference && that.getOp() instanceof _RewriteInstantiatedOpRefs ) { 3569 OpRef ops = that.getOp(); 3570 3571 if( postInference && ops.getOverloadings().isSome() ) { 3565 3572 // if we have finished typechecking, and we have encountered a reference to an overloaded op 3566 _RewriteInstantiatedOpRefs ops = (_RewriteInstantiatedOpRefs)that.getOp();3567 3568 3573 3569 3574 for( TypeCheckerResult r : args_result ) { … … 3576 3581 })); 3577 3582 Type arg_type = NodeFactory.makeTupleType(that.getSpan(), arg_types); 3578 TypeCheckerResult op_result = findStaticallyMostApplicableFn(destructOpOverLoading(ops.getOverloadings()), arg_type,ops, ops.getOriginalName()); 3583 TypeCheckerResult op_result = findStaticallyMostApplicableFn(destructOpOverLoading(ops.getOverloadings().unwrap()), 3584 arg_type,ops, ops.getOriginalName()); 3579 3585 3580 3586 // Now just check the rewritten expression by the normal means … … 3659 3665 @Override 3660 3666 public TypeCheckerResult forOpRefOnly(final OpRef that, Option<TypeCheckerResult> exprType_result, 3661 List<TypeCheckerResult> staticArgs_result, 3662 TypeCheckerResult originalName_result, 3663 List<TypeCheckerResult> ops_result) { 3667 List<TypeCheckerResult> staticArgs_result, 3668 TypeCheckerResult originalName_result, 3669 List<TypeCheckerResult> ops_result, 3670 Option<List<TypeCheckerResult>> overloadings_result) { 3664 3671 // Did all ops typecheck? 3665 3672 for( TypeCheckerResult o_r : ops_result ) { … … 3677 3684 3678 3685 // If no static args are given, but overloadings require them, we'll create a 3679 // _RewriteInstantiatedOpRef.3686 // OpRef with the overloading field set. 3680 3687 if( that.getStaticArgs().isEmpty() && TypesUtil.overloadingRequiresStaticArgs(overloaded_types) ) { 3681 3688 List<_RewriteOpRefOverloading> overloadings = new ArrayList<_RewriteOpRefOverloading>(); … … 3730 3737 Option.<Type>none() : 3731 3738 Option.<Type>some(new IntersectionType(NodeFactory.makeSetSpan("impossible", arrow_types), arrow_types)); 3732 new_node = new _RewriteInstantiatedOpRefs(that.getSpan(),3733 that.isParenthesized(),3734 type,3735 that.getStaticArgs(),3736 that.getLexicalDepth(),3737 that.getOriginalName(),3738 that.getOps(),3739 overloadings);3739 new_node = new OpRef(that.getSpan(), 3740 that.isParenthesized(), 3741 type, 3742 that.getStaticArgs(), 3743 that.getLexicalDepth(), 3744 that.getOriginalName(), 3745 that.getOps(), 3746 Option.<List<_RewriteOpRefOverloading>>some(overloadings)); 3740 3747 constraints = accumulated_constraints; 3741 3748 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r3092 r3101 319 319 320 320 public static FnRef makeFnRef(FnRef that, Option<Type> ty, Id name, 321 List<Id> ids, List<StaticArg> sargs) { 321 List<Id> ids, List<StaticArg> sargs, 322 Option<List<_RewriteFnRefOverloading>> overloadings) { 322 323 return new FnRef(that.getSpan(), that.isParenthesized(), ty, 323 sargs, name, ids);324 sargs, name, ids, overloadings); 324 325 } 325 326 -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r3099 r3101 1104 1104 List<String> lhs_result, 1105 1105 Option<String> opr_result, 1106 String rhs_result) { 1106 String rhs_result, 1107 Option<List<String>> opsForLhs_result) { 1107 1108 StringBuilder s = new StringBuilder(); 1108 1109 … … 1117 1118 return handleParen( s.toString(), 1118 1119 that.isParenthesized() ); 1119 }1120 1121 @Override public String for_RewriteAssignmentOnly(_RewriteAssignment that,1122 Option<String> exprType_result,1123 List<String> lhs_result,1124 Option<String> opr_result,1125 String rhs_result,1126 List<String> opsForLhs_result) {1127 return forAssignmentOnly(that, exprType_result, lhs_result,1128 opr_result, rhs_result);1129 1120 } 1130 1121 … … 1697 1688 List<String> staticArgs_result, 1698 1689 String originalName_result, 1699 List<String> fns_result) { 1690 List<String> fns_result, 1691 Option<List<String>> overloadings_result) { 1700 1692 StringBuilder s = new StringBuilder(); 1701 1693 … … 1722 1714 List<String> staticArgs_result, 1723 1715 String originalName_result, 1724 List<String> ops_result) { 1716 List<String> ops_result, 1717 Option<List<String>> overloadings_result) { 1725 1718 return handleParen( canonicalOp(originalName_result), 1726 1719 that.isParenthesized() ); … … 1733 1726 _RewriteFnRefOverloading that, String fn_result, String ty_result) { 1734 1727 return "(* _RewriteFnRefOverloading *)"; 1735 }1736 1737 @Override1738 public String for_RewriteInstantiatedFnRefsOnly(1739 _RewriteInstantiatedFnRefs that, Option<String> exprType_result,1740 List<String> staticArgs_result,1741 String originalName_result, List<String> fns_result, List<String> overloadings_result) {1742 return "(* _RewriteInstantiatedFnRefs *)";1743 }1744 1745 @Override1746 public String for_RewriteInstantiatedOpRefsOnly(1747 _RewriteInstantiatedOpRefs that, Option<String> exprType_result,1748 List<String> staticArgs_result,1749 String originalName_result, List<String> ops_result, List<String> overloadings_result) {1750 return "(* _RewriteInstantiatedOpRefs *)";1751 1728 } 1752 1729 … … 2845 2822 @Override public String forCaseClauseOnly(CaseClause that, 2846 2823 String match_result, 2847 String body_result) { 2824 String body_result, 2825 Option<String> op_result) { 2848 2826 return match_result + " => " + body_result; 2849 }2850 2851 @Override public String for_RewriteCaseClauseOnly(_RewriteCaseClause that,2852 String match_result,2853 String body_result,2854 String op_result) {2855 return forCaseClauseOnly(that, match_result, body_result);2856 2827 } 2857 2828

