Changeset 3132
- Timestamp:
- 12/02/08 09:23:26 (12 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 43 modified
-
astgen/Fortress.ast (modified) (6 diffs)
-
src/com/sun/fortress/compiler/OverloadRewriteVisitor.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/OverloadRewriter.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/Types.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java (modified) (7 diffs)
-
src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/disambiguator/DelegatingNameEnv.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/disambiguator/DelegatingTypeNameEnv.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/disambiguator/LocalFnEnv.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/disambiguator/LocalStaticParamEnv.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/disambiguator/NameEnv.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/disambiguator/TopLevelEnv.java (modified) (9 diffs)
-
src/com/sun/fortress/compiler/disambiguator/TypeNameEnv.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/StaticParamTypeEnv.java (modified) (10 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (8 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeEnv.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/env/IndexedEnv.java (modified) (7 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BaseEnv.java (modified) (6 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BuildTopLevelEnvironments.java (modified) (4 diffs)
-
src/com/sun/fortress/interpreter/evaluator/Environment.java (modified) (12 diffs)
-
src/com/sun/fortress/interpreter/evaluator/Evaluator.java (modified) (8 diffs)
-
src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java (modified) (3 diffs)
-
src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/ErrorMsgMaker.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (8 diffs)
-
src/com/sun/fortress/nodes_util/NodeComparator.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (7 diffs)
-
src/com/sun/fortress/nodes_util/NodeUtil.java (modified) (4 diffs)
-
src/com/sun/fortress/nodes_util/OprUtil.java (modified) (8 diffs)
-
src/com/sun/fortress/parser/DelimitedExpr.rats (modified) (2 diffs)
-
src/com/sun/fortress/parser/Expression.rats (modified) (7 diffs)
-
src/com/sun/fortress/parser/Identifier.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/MethodParam.rats (modified) (2 diffs)
-
src/com/sun/fortress/parser/OtherDecl.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/Parameter.rats (modified) (2 diffs)
-
src/com/sun/fortress/parser/Symbol.rats (modified) (1 diff)
-
src/com/sun/fortress/parser/preparser/PreSymbol.rats (modified) (1 diff)
-
src/com/sun/fortress/parser_util/FortressUtil.java (modified) (2 diffs)
-
src/com/sun/fortress/parser_util/SyntaxChecker.java (modified) (1 diff)
-
src/com/sun/fortress/parser_util/precedence_resolver/ASTUtil.java (modified) (5 diffs)
-
src/com/sun/fortress/scala_src/nodes (modified) (1 prop)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3125 r3132 349 349 * Overloading specification 350 350 */ 351 _RewriteFnOverloadDecl(IdOrOp Name name, List<IdOrOpName> fns);351 _RewriteFnOverloadDecl(IdOrOp name, List<IdOrOp> fns); 352 352 /* the list of object expressions is a temporary hack to allow 353 353 progress towards earlier rewriting and caching of ASTs. -- DRC */ … … 841 841 * e.g.) PROD[i <- 1:n] i 842 842 */ 843 Accumulator(Op NameaccOp, List<GeneratorClause> gens, Expr body);843 Accumulator(Op accOp, List<GeneratorClause> gens, Expr body); 844 844 /** 845 845 * array comprehension … … 952 952 */ 953 953 SubscriptExpr(Expr obj, List<Expr> subs, 954 Option< Enclosing> op = Option.<Enclosing>none(),954 Option<Op> op = Option.<Op>none(), 955 955 List<StaticArg> staticArgs 956 956 = Collections.<StaticArg>emptyList()) … … 1084 1084 * one of which may be the correct insantiation. 1085 1085 */ 1086 OpRef(Op NameoriginalName,1087 List<Op Name> ops = Collections.<OpName>singletonList(in_originalName),1086 OpRef(Op originalName, 1087 List<Op> ops = Collections.<Op>singletonList(in_originalName), 1088 1088 Option<List<_RewriteOpRefOverloading>> overloadings 1089 1089 = Option.<List<_RewriteOpRefOverloading>>none()); … … 1881 1881 * identifier or operator name 1882 1882 */ 1883 abstract IdOrOp Name();1883 abstract IdOrOp(String text); 1884 1884 /** 1885 1885 * identifier name 1886 1886 * e.g.) hashCode 1887 1887 */ 1888 Id( String text);1888 Id(); 1889 1889 /** 1890 1890 * operator name 1891 */ 1892 abstract OpName(); 1893 /** 1894 * non-enclosing operator 1895 * e.g.) COMPOSE 1896 * e.g.) === 1897 */ 1898 Op(String text, Fixity fixity); 1899 /** 1900 * pair of enclosing operators 1901 * Opening and closing Ops must be unqualified. 1902 * EncloserPair ::= (LeftEncloser | Encloser) 1903 * (RightEncloser | Encloser) 1904 * e.g.) </ /> 1905 */ 1906 Enclosing(Op open, Op close); 1891 * 1892 * Opening and closing Ops must be unqualified. 1893 * EncloserPair ::= (LeftEncloser | Encloser) 1894 * (RightEncloser | Encloser) 1895 * e.g.) COMPOSE 1896 * e.g.) === 1897 * e.g.) </ /> 1898 */ 1899 Op(Fixity fixity, boolean enclosing); 1907 1900 /** 1908 1901 * anonymous name; used internally … … 2065 2058 * e.g.) [3, 4] 2066 2059 */ 2067 SubscriptingMI( Enclosingop, List<Expr> exprs,2060 SubscriptingMI(Op op, List<Expr> exprs, 2068 2061 List<StaticArg> staticArgs); 2069 2062 /** -
trunk/ProjectFortress/src/com/sun/fortress/compiler/OverloadRewriteVisitor.java
r3101 r3132 33 33 34 34 final private Map<String, List<Id>> overloadedFunctions = new HashMap<String, List<Id>>(); 35 final private Map<String, List<Op Name>> overloadedOperators = new HashMap<String, List<OpName>>();35 final private Map<String, List<Op>> overloadedOperators = new HashMap<String, List<Op>>(); 36 36 37 37 @Override … … 65 65 @Override 66 66 public Node forOpRefOnly(OpRef that, Option<Type> exprType_result, 67 List<StaticArg> staticArgs, Op Name originalName, List<OpName> ops,67 List<StaticArg> staticArgs, Op originalName, List<Op> ops, 68 68 Option<List<_RewriteOpRefOverloading>> overloadings) { 69 69 if (ops.size() > 1) { 70 Collections.<Op Name>sort(ops, NodeComparator.opNameComparer);70 Collections.<Op>sort(ops, NodeComparator.opNameComparer); 71 71 StringBuffer buffer = new StringBuffer(); 72 72 buffer.append(NodeUtil.nameString(originalName)); … … 83 83 overloadedOperators.put(overloadingName, ops); 84 84 } 85 Op Name overloadingOpName= NodeFactory.makeOp(NodeFactory.makeSpan(that), overloadingName);86 ops = Collections.unmodifiableList(Collections.singletonList(overloadingOp Name));85 Op overloadingOp = NodeFactory.makeOp(NodeFactory.makeSpan(that), overloadingName); 86 ops = Collections.unmodifiableList(Collections.singletonList(overloadingOp)); 87 87 } 88 88 return super.forOpRefOnly(that, exprType_result, staticArgs, originalName, ops, … … 95 95 } 96 96 97 public Map<String, List<Op Name>> getOverloadedOperators() {97 public Map<String, List<Op>> getOverloadedOperators() { 98 98 return overloadedOperators; 99 99 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/OverloadRewriter.java
r3071 r3132 29 29 import com.sun.fortress.nodes.Decl; 30 30 import com.sun.fortress.nodes.Id; 31 import com.sun.fortress.nodes.IdOrOp Name;32 import com.sun.fortress.nodes.Op Name;31 import com.sun.fortress.nodes.IdOrOp; 32 import com.sun.fortress.nodes.Op; 33 33 import com.sun.fortress.nodes._RewriteFnOverloadDecl; 34 34 import com.sun.fortress.nodes_util.NodeFactory; … … 77 77 Map<String, List<Id>> overloadedFunctions = visitor.getOverloadedFunctions(); 78 78 for (Map.Entry<String, List<Id>> overload : overloadedFunctions.entrySet()) { 79 List<IdOrOp Name> overloadings = new ArrayList<IdOrOpName>(overload.getValue());79 List<IdOrOp> overloadings = new ArrayList<IdOrOp>(overload.getValue()); 80 80 Id overloadingId = NodeFactory.makeId(overload.getKey()); 81 81 _RewriteFnOverloadDecl newDecl = new _RewriteFnOverloadDecl(span, overloadingId, overloadings); … … 84 84 85 85 // Add rewritten overloaded operators 86 Map<String, List<Op Name>> overloadedOperators = visitor.getOverloadedOperators();87 for (Map.Entry<String, List<Op Name>> overload : overloadedOperators.entrySet()) {88 List<IdOrOp Name> overloadings = new ArrayList<IdOrOpName>(overload.getValue());89 Op Name overloadingOpName= NodeFactory.makeOp(NodeFactory.makeSpan("impossible", overload.getValue()), overload.getKey());90 _RewriteFnOverloadDecl newDecl = new _RewriteFnOverloadDecl(span, overloadingOp Name, overloadings);86 Map<String, List<Op>> overloadedOperators = visitor.getOverloadedOperators(); 87 for (Map.Entry<String, List<Op>> overload : overloadedOperators.entrySet()) { 88 List<IdOrOp> overloadings = new ArrayList<IdOrOp>(overload.getValue()); 89 Op overloadingOp = NodeFactory.makeOp(NodeFactory.makeSpan("impossible", overload.getValue()), overload.getKey()); 90 _RewriteFnOverloadDecl newDecl = new _RewriteFnOverloadDecl(span, overloadingOp, overloadings); 91 91 decls.add(newDecl); 92 92 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/Types.java
r3123 r3132 325 325 * TotalOperatorOrder[\A,<,<=,>=,>,Op] 326 326 */ 327 public static Type makeTotalOperatorOrder(Type A, Op Nameop) {327 public static Type makeTotalOperatorOrder(Type A, Op op) { 328 328 // NodeFactory.makeTraitType(makeId("TotalOperater"), sargs) 329 329 // NodeFactory.makeOpArg("whoa"); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java
r3123 r3132 490 490 recurOnOptionOfType(that.getExprType()); 491 491 recur(that.getOriginalName()); 492 recurOnListOfOp Name(that.getOps());492 recurOnListOfOp(that.getOps()); 493 493 recurOnListOfStaticArg(that.getStaticArgs()); 494 494 495 Op Nameop = that.getOriginalName();495 Op op = that.getOriginalName(); 496 496 // Not handling 497 497 if( (op instanceof Op) == false && … … 698 698 } 699 699 700 private boolean isDeclaredInObjExpr(IdOrOp Namename) {700 private boolean isDeclaredInObjExpr(IdOrOp name) { 701 701 ObjectExpr innerMostObjExpr = objExprStack.peek(); 702 702 Span objExprSpan = innerMostObjExpr.getSpan(); … … 713 713 if(name instanceof Id) { 714 714 bindingOutside = objExprTypeEnv.binding((Id) name); 715 } else if(name instanceof Op Name) {716 bindingOutside = objExprTypeEnv.binding((Op Name)name);715 } else if(name instanceof Op) { 716 bindingOutside = objExprTypeEnv.binding((Op)name); 717 717 } else { 718 718 throw new DesugarerError("Querying binding from TypeEnv with" + … … 791 791 } */ 792 792 793 private boolean isDeclaredAtTopLevel(IdOrOp Name idOrOpName) {793 private boolean isDeclaredAtTopLevel(IdOrOp idOrOp) { 794 794 // The first node in this stack must be declared at a top level 795 795 // Its corresponding environment must be the top level environment … … 804 804 throw new DesugarerError("TypeEnv associated with " 805 805 + topLevelNode + " is not found when querying for " + 806 "type info for " + idOrOp Name);806 "type info for " + idOrOp); 807 807 } 808 808 … … 810 810 Option<StaticParam> staticParam = Option.<StaticParam>none(); 811 811 812 if(idOrOp Nameinstanceof Id) {813 binding = topLevelEnv.binding( (Id)idOrOp Name);814 staticParam = topLevelEnv.staticParam( (Id)idOrOp Name);815 } else if(idOrOp Name instanceof OpName) {816 binding = topLevelEnv.binding( (Op Name)idOrOpName);812 if(idOrOp instanceof Id) { 813 binding = topLevelEnv.binding( (Id)idOrOp ); 814 staticParam = topLevelEnv.staticParam( (Id)idOrOp ); 815 } else if(idOrOp instanceof Op) { 816 binding = topLevelEnv.binding( (Op)idOrOp ); 817 817 } else { 818 818 throw new DesugarerError("Querying binding from TypeEnv with" + 819 " type " + idOrOp Name.getClass().toString() +819 " type " + idOrOp.getClass().toString() + 820 820 " is not supported."); 821 821 } … … 823 823 if( binding.isNone() && staticParam.isNone() ) { 824 824 Debug.debug(Debug.Type.COMPILER, DEBUG_LEVEL, 825 idOrOp Name, " is NOT declared in top level env.");825 idOrOp, " is NOT declared in top level env."); 826 826 return false; 827 827 } 828 828 829 829 Debug.debug(Debug.Type.COMPILER, DEBUG_LEVEL, 830 idOrOp Name, " is declared in top level env.");830 idOrOp, " is declared in top level env."); 831 831 832 832 return true; 833 833 } 834 834 835 private boolean isShadowedInNode(Node enclosing, IdOrOp Name idOrOpName) {835 private boolean isShadowedInNode(Node enclosing, IdOrOp idOrOp) { 836 836 Id name = null; 837 if(idOrOp Nameinstanceof Id) {838 name = (Id) idOrOp Name;837 if(idOrOp instanceof Id) { 838 name = (Id) idOrOp; 839 839 } else { // FIXME: Need to support Op name later ... 840 840 throw new DesugarerError("isShadowedInNode does not support " + 841 841 "checking name shadowing where the name is not an Id type: " + 842 idOrOp Name);842 idOrOp); 843 843 } 844 844 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java
r3123 r3132 113 113 // If there is a colon at all, the operator is no longer ambiguous: 114 114 // It must be infix. 115 Op Nameop_name = IterUtil.first(that.getInfix_op().getOps());115 Op op_name = IterUtil.first(that.getInfix_op().getOps()); 116 116 boolean prefix = OprUtil.hasPrefixColon(op_name); 117 117 boolean suffix = OprUtil.hasSuffixColon(op_name); … … 152 152 153 153 if (args.size() <= 1) return opExp; 154 Op Nameqop = IterUtil.first(ref.getOps());154 Op qop = IterUtil.first(ref.getOps()); 155 155 156 156 if (OprUtil.isEnclosing(qop)) return opExp; … … 186 186 187 187 private Expr visitAccumulator(Span span, List<GeneratorClause> gens, 188 Op Nameop, Expr body,188 Op op, Expr body, 189 189 List<StaticArg> staticArgs) { 190 190 body = visitGenerators(span, gens, body); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/DelegatingNameEnv.java
r2503 r3132 23 23 24 24 import com.sun.fortress.nodes.Id; 25 import com.sun.fortress.nodes.IdOrOp Name;26 import com.sun.fortress.nodes.Op Name;25 import com.sun.fortress.nodes.IdOrOp; 26 import com.sun.fortress.nodes.Op; 27 27 import com.sun.fortress.nodes.APIName; 28 28 import com.sun.fortress.nodes.StaticParam; … … 40 40 } 41 41 42 public Option<StaticParam> hasTypeParam(IdOrOp Namename) {42 public Option<StaticParam> hasTypeParam(IdOrOp name) { 43 43 return _parent.hasTypeParam(name); 44 44 } … … 51 51 } 52 52 public List<Id> explicitVariableNames() { 53 return _parent.explicitVariableNames(); 53 return _parent.explicitVariableNames(); 54 54 } 55 55 public Set<Id> explicitFunctionNames(Id name) { 56 56 return _parent.explicitFunctionNames(name); 57 57 } 58 public Set<Op Name> explicitFunctionNames(OpNamename) {58 public Set<Op> explicitFunctionNames(Op name) { 59 59 return _parent.explicitFunctionNames(name); 60 60 } … … 69 69 return _parent.onDemandFunctionNames(name); 70 70 } 71 public Set<Op Name> onDemandFunctionNames(OpNamename) {71 public Set<Op> onDemandFunctionNames(Op name) { 72 72 return _parent.onDemandFunctionNames(name); 73 73 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/DelegatingTypeNameEnv.java
r2277 r3132 22 22 23 23 import com.sun.fortress.nodes.Id; 24 import com.sun.fortress.nodes.IdOrOp Name;25 import com.sun.fortress.nodes.Op Name;24 import com.sun.fortress.nodes.IdOrOp; 25 import com.sun.fortress.nodes.Op; 26 26 import com.sun.fortress.nodes.APIName; 27 27 import com.sun.fortress.nodes.StaticParam; … … 39 39 } 40 40 41 public Option<StaticParam> hasTypeParam(IdOrOp Namename) {41 public Option<StaticParam> hasTypeParam(IdOrOp name) { 42 42 return _parent.hasTypeParam(name); 43 43 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java
r3123 r3132 71 71 import com.sun.fortress.nodes.ObjectExpr; 72 72 import com.sun.fortress.nodes.OpExpr; 73 import com.sun.fortress.nodes.Op Name;73 import com.sun.fortress.nodes.Op; 74 74 import com.sun.fortress.nodes.OpRef; 75 75 import com.sun.fortress.nodes.Param; … … 850 850 return forAccumulatorOnly(that, type_result, 851 851 recurOnListOfStaticArg(that.getStaticArgs()), 852 (Op Name)that.getAccOp().accept(this),852 (Op)that.getAccOp().accept(this), 853 853 pair.first(), 854 854 (Expr)that.getBody().accept(extended_d)); … … 1118 1118 */ 1119 1119 private Option<OpRef> opRefHelper(OpRef that) { 1120 Op Nameop_name = IterUtil.first(that.getOps());1121 Set<Op Name> ops = _env.explicitFunctionNames(op_name);1120 Op op_name = IterUtil.first(that.getOps()); 1121 Set<Op> ops = _env.explicitFunctionNames(op_name); 1122 1122 if (ops.isEmpty()) { 1123 1123 ops = _env.onDemandFunctionNames(op_name); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/LocalFnEnv.java
r1598 r3132 24 24 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 25 25 import com.sun.fortress.nodes.Id; 26 import com.sun.fortress.nodes.Op Name;26 import com.sun.fortress.nodes.Op; 27 27 import com.sun.fortress.nodes_util.NodeFactory; 28 28 … … 44 44 } 45 45 46 @Override public Set<Op Name> explicitFunctionNames(OpNamename) {46 @Override public Set<Op> explicitFunctionNames(Op name) { 47 47 if (_fns.contains(name)) { 48 48 return Collections.singleton(name); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/LocalStaticParamEnv.java
r2277 r3132 37 37 } 38 38 39 public Option<StaticParam> hasTypeParam(IdOrOp Namename) {39 public Option<StaticParam> hasTypeParam(IdOrOp name) { 40 40 for (StaticParam typeVar : _staticParams) { 41 41 if (typeVar instanceof IdStaticParam && -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/NameEnv.java
r2609 r3132 22 22 23 23 import com.sun.fortress.nodes.Id; 24 import com.sun.fortress.nodes.Op Name;24 import com.sun.fortress.nodes.Op; 25 25 26 26 public abstract class NameEnv extends TypeNameEnv { … … 33 33 */ 34 34 public abstract Set<Id> explicitVariableNames(Id name); 35 /** 35 /** 36 36 * Produce the set of all unaliased expilcit variable names in this environment. 37 37 */ … … 48 48 * produces an empty set. 49 49 */ 50 public abstract Set<Op Name> explicitFunctionNames(OpNamename);50 public abstract Set<Op> explicitFunctionNames(Op name); 51 51 52 52 /** … … 68 68 * produces an empty set. 69 69 */ 70 public abstract Set<Op Name> onDemandFunctionNames(OpNamename);70 public abstract Set<Op> onDemandFunctionNames(Op name); 71 71 72 72 /** -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TopLevelEnv.java
r3123 r3132 45 45 import com.sun.fortress.nodes.Api; 46 46 import com.sun.fortress.nodes.Component; 47 import com.sun.fortress.nodes.Enclosing;48 47 import com.sun.fortress.nodes.Id; 49 import com.sun.fortress.nodes.IdOrOp Name;48 import com.sun.fortress.nodes.IdOrOp; 50 49 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 51 50 import com.sun.fortress.nodes.Import; … … 56 55 import com.sun.fortress.nodes.NodeDepthFirstVisitor; 57 56 import com.sun.fortress.nodes.Op; 58 import com.sun.fortress.nodes.Op Name;57 import com.sun.fortress.nodes.Op; 59 58 import com.sun.fortress.nodes.StaticParam; 60 59 import com.sun.fortress.nodes_util.NodeFactory; … … 87 86 private final Map<Id, Set<Id>> _onDemandVariableNames; 88 87 private final Map<Id, Set<Id>> _onDemandFunctionIdNames; 89 private final Map<Op Name, Set<OpName>> _onDemandFunctionOpNames;88 private final Map<Op, Set<Op>> _onDemandFunctionOps; 90 89 private final Map<String, Set<Id>> _onDemandGrammarNames; 91 90 … … 114 113 _onDemandTypeConsNames = Collections.unmodifiableMap(initializeOnDemandTypeConsNames(_onDemandImportedApis)); 115 114 _onDemandVariableNames = Collections.unmodifiableMap(initializeOnDemandVariableNames(_onDemandImportedApis)); 116 Pair<Map<Id, Set<Id>>, Map<Op Name, Set<OpName>>> functions_and_ops =115 Pair<Map<Id, Set<Id>>, Map<Op, Set<Op>>> functions_and_ops = 117 116 initializeOnDemandFunctionNames(_onDemandImportedApis); 118 117 _onDemandFunctionIdNames = functions_and_ops.first(); 119 _onDemandFunctionOp Names = functions_and_ops.second();118 _onDemandFunctionOps = functions_and_ops.second(); 120 119 _onDemandGrammarNames = Collections.unmodifiableMap(initializeOnDemandGrammarNames(_onDemandImportedApis)); 121 120 } … … 214 213 } 215 214 216 private static Op Name copyOpNameWithNewAPIName(OpNameop, final APIName api) {217 Op Nameresult =218 op.accept(new NodeDepthFirstVisitor<Op Name>(){215 private static Op copyOpWithNewAPIName(Op op, final APIName api) { 216 Op result = 217 op.accept(new NodeDepthFirstVisitor<Op>(){ 219 218 @Override 220 public Op NamedefaultCase(Node that) {221 return bug("Unexpected sub-type of Op Name.");219 public Op defaultCase(Node that) { 220 return bug("Unexpected sub-type of Op."); 222 221 } 223 222 @Override 224 public OpName forEnclosing(Enclosing that) { 225 return new Enclosing(that.getSpan(),Option.some(api),that.getOpen(),that.getClose()); 226 } 227 @Override 228 public OpName forOp(Op that) { 229 return new Op(that.getSpan(),Option.some(api),that.getText(),that.getFixity()); 223 public Op forOp(Op that) { 224 return new Op(that.getSpan(),Option.some(api),that.getText(),that.getFixity(), that.isEnclosing()); 230 225 }}); 231 226 return result; 232 227 } 233 228 234 private static Pair<Map<Id, Set<Id>>, Map<Op Name, Set<OpName>>> initializeOnDemandFunctionNames(Map<APIName, ApiIndex> imported_apis) {229 private static Pair<Map<Id, Set<Id>>, Map<Op, Set<Op>>> initializeOnDemandFunctionNames(Map<APIName, ApiIndex> imported_apis) { 235 230 Map<Id, Set<Id>> fun_result = new HashMap<Id, Set<Id>>(); 236 Map<Op Name, Set<OpName>> ops_result = new HashMap<OpName, Set<OpName>>();231 Map<Op, Set<Op>> ops_result = new HashMap<Op, Set<Op>>(); 237 232 238 233 for (Map.Entry<APIName, ApiIndex> apiEntry: imported_apis.entrySet()) { … … 253 248 } 254 249 } 255 else { // fnName instanceof Op Name256 Op Name _opName = (OpName)fnName;257 Op Name name = copyOpNameWithNewAPIName(_opName, apiEntry.getKey());258 // NEB: I put this code here because I don't see why we shouldn't qualify Op Names as well...250 else { // fnName instanceof Op 251 Op _opName = (Op)fnName; 252 Op name = copyOpWithNewAPIName(_opName, apiEntry.getKey()); 253 // NEB: I put this code here because I don't see why we shouldn't qualify Ops as well... 259 254 260 255 if (ops_result.containsKey(_opName)) { 261 256 ops_result.get(_opName).add(name); 262 257 } else { 263 Set<Op Name> matches = new HashSet<OpName>();258 Set<Op> matches = new HashSet<Op>(); 264 259 matches.add(name); 265 260 ops_result.put(_opName, matches); … … 300 295 301 296 @Override 302 public Option<StaticParam> hasTypeParam(IdOrOp Namename) {297 public Option<StaticParam> hasTypeParam(IdOrOp name) { 303 298 return Option.none(); 304 299 } … … 412 407 } 413 408 414 public Set<Op Name> explicitFunctionNames(OpNamename) {415 Set<Op Name> result = Collections.emptySet();409 public Set<Op> explicitFunctionNames(Op name) { 410 Set<Op> result = Collections.emptySet(); 416 411 417 412 // Add ops in this component 418 413 if( _current.functions().containsFirst(name)) { 419 414 // Only qualify name with an API if we are inside of an API 420 Op Nameresult_id;415 Op result_id; 421 416 if( _current instanceof ApiIndex ) 422 result_id = NodeFactory.makeOp Name(_current.ast().getName(), name);417 result_id = NodeFactory.makeOp(_current.ast().getName(), name); 423 418 else 424 419 result_id = name; … … 474 469 } 475 470 476 public Set<Op Name> onDemandFunctionNames(OpNamename) {477 if (_onDemandFunctionOp Names.containsKey(name)) {478 return _onDemandFunctionOp Names.get(name);471 public Set<Op> onDemandFunctionNames(Op name) { 472 if (_onDemandFunctionOps.containsKey(name)) { 473 return _onDemandFunctionOps.get(name); 479 474 } else { 480 return new HashSet<Op Name>();475 return new HashSet<Op>(); 481 476 } 482 477 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeNameEnv.java
r2593 r3132 25 25 import com.sun.fortress.nodes.Id; 26 26 import com.sun.fortress.nodes.APIName; 27 import com.sun.fortress.nodes.IdOrOp Name;27 import com.sun.fortress.nodes.IdOrOp; 28 28 import com.sun.fortress.nodes.StaticParam; 29 29 import com.sun.fortress.nodes_util.NodeFactory; … … 41 41 42 42 /** Determine whether a type parameter with the given name is defined. */ 43 public abstract Option<StaticParam> hasTypeParam(IdOrOp Namename);43 public abstract Option<StaticParam> hasTypeParam(IdOrOp name); 44 44 45 45 /** -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/StaticParamTypeEnv.java
r2466 r3132 26 26 import com.sun.fortress.nodes.BoolParam; 27 27 import com.sun.fortress.nodes.Id; 28 import com.sun.fortress.nodes.IdOrOp Name;28 import com.sun.fortress.nodes.IdOrOp; 29 29 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 30 30 import com.sun.fortress.nodes.IdStaticParam; … … 48 48 */ 49 49 public class StaticParamTypeEnv extends TypeEnv { 50 50 51 51 final static Type STATIC_INT_TYPE = Types.INT_LITERAL; 52 52 final static Type STATIC_NAT_TYPE = Types.INT_LITERAL; 53 53 final static Type STATIC_BOOL_TYPE = Types.BOOLEAN; 54 54 55 55 final List<StaticParam> entries; 56 56 final private TypeEnv parent; 57 57 58 58 public StaticParamTypeEnv(List<StaticParam> _static, TypeEnv _parent) { 59 59 entries=Collections.unmodifiableList(new ArrayList<StaticParam>(_static)); … … 63 63 private Option<Pair<StaticParam,Type>> findParam(Id _var) { 64 64 Id no_api_var = removeApi(_var); 65 for (StaticParam param : entries) { 66 IdOrOp Namename = nameFromStaticParam(param);65 for (StaticParam param : entries) { 66 IdOrOp name = nameFromStaticParam(param); 67 67 if(name.equals(no_api_var) || name.equals(_var) ){ 68 68 Option<Type> type_ = typeOfStaticParam(param); 69 69 70 70 if( type_.isSome() ) 71 71 return Option.some(Pair.make(param, type_.unwrap())); … … 74 74 return Option.none(); 75 75 } 76 76 77 77 @Override 78 78 public Option<BindingLookup> binding(IdOrOpOrAnonymousName var) { 79 79 if (!(var instanceof Id)) { return parent.binding(var); } 80 80 Id _var = (Id)var; 81 81 82 82 Option<Pair<StaticParam,Type>> p = findParam(_var); 83 83 84 84 if( p.isSome() ) { 85 85 Type type_ = p.unwrap().second(); … … 96 96 97 97 Id no_api_var = removeApi(_var); 98 for (StaticParam param : entries) { 99 IdOrOp Namename = nameFromStaticParam(param);98 for (StaticParam param : entries) { 99 IdOrOp name = nameFromStaticParam(param); 100 100 101 101 if(name.equals(no_api_var) || name.equals(_var) ){ … … 105 105 return parent.staticParam(id); 106 106 } 107 108 private static IdOrOp NamenameFromStaticParam(StaticParam param) {109 NodeAbstractVisitor<IdOrOp Name> get_name = new NodeAbstractVisitor<IdOrOpName>(){110 @Override public IdOrOp NameforIdStaticParam(IdStaticParam that) { return that.getName(); }111 @Override public IdOrOp NameforOpParam(OpParam that) { return that.getName(); }107 108 private static IdOrOp nameFromStaticParam(StaticParam param) { 109 NodeAbstractVisitor<IdOrOp> get_name = new NodeAbstractVisitor<IdOrOp>(){ 110 @Override public IdOrOp forIdStaticParam(IdStaticParam that) { return that.getName(); } 111 @Override public IdOrOp forOpParam(OpParam that) { return that.getName(); } 112 112 }; 113 114 IdOrOp Namename = param.accept(get_name);113 114 IdOrOp name = param.accept(get_name); 115 115 return name; 116 116 } … … 119 119 NodeAbstractVisitor<Option<Type>> get_type = new NodeAbstractVisitor<Option<Type>>(){ 120 120 121 @Override 121 @Override 122 122 public Option<Type> defaultCase(Node node) { 123 123 return Option.none(); 124 124 } 125 125 126 126 @Override 127 127 public Option<Type> forBoolParam(BoolParam that) { … … 147 147 public List<BindingLookup> contents() { 148 148 List<BindingLookup> result = new ArrayList<BindingLookup>(); 149 149 150 150 for( StaticParam param : entries ) { 151 151 Option<Type> type_ = typeOfStaticParam(param); … … 160 160 if (!(var instanceof Id)) { return parent.declarationSite(var); } 161 161 Id _var = (Id)var; 162 162 163 163 Option<Pair<StaticParam,Type>> p = findParam(_var); 164 164 if( p.isSome() ) … … 172 172 List<StaticParam> new_entries = new ArrayList<StaticParam>(entries.size()); 173 173 InferenceVarReplacer rep = new InferenceVarReplacer(ivars); 174 174 175 175 for( StaticParam entry : entries ) { 176 176 new_entries.add((StaticParam)entry.accept(rep)); 177 177 } 178 178 179 179 return new StaticParamTypeEnv(new_entries, parent.replaceAllIVars(ivars)); 180 180 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3123 r3132 794 794 * whose type is the statically most applicable to the given arg. 795 795 */ 796 private TypeCheckerResult findStaticallyMostApplicableFn(List<? extends Pair<? extends FunctionalRef, Type>> fns, Type arg_type, FunctionalRef ref, IdOrOp Namename) {796 private TypeCheckerResult findStaticallyMostApplicableFn(List<? extends Pair<? extends FunctionalRef, Type>> fns, Type arg_type, FunctionalRef ref, IdOrOp name) { 797 797 final List<Pair<FunctionalRef, Type>> pruned_fns = new ArrayList<Pair<FunctionalRef, Type>>(fns.size()); 798 798 // prune down the list of fns to just the ones that apply … … 2122 2122 2123 2123 @Override 2124 public TypeCheckerResult forEnclosing(Enclosing that) {2125 Option<APIName> api = that.getApiName();2126 TypeEnv env = api.isSome() ? returnTypeEnvForApi(api.unwrap()) : this.typeEnv;2127 2128 Option<BindingLookup> binding = env.binding(that);2129 if( binding.isSome() ) {2130 return new TypeCheckerResult(that, binding.unwrap().getType());2131 } else {2132 return new TypeCheckerResult(that,2133 TypeError.make(errorMsg("Enclosing operator not found: ",2134 that),2135 that));2136 }2137 }2138 2139 @Override2140 2124 public TypeCheckerResult forEnclosingFixity(EnclosingFixity that) { 2141 2125 return new TypeCheckerResult(that); … … 2729 2713 } else { 2730 2714 // Operators are never qualified in source code, so if 'name' is qualified and not 2731 // found, it must be a Id, not a Op Name.2715 // found, it must be a Id, not a Op. 2732 2716 StaticError error = TypeError.make(errorMsg("Attempt to reference unbound variable: ", name), 2733 2717 name); … … 3513 3497 Option<APIName> api = that.getApiName(); 3514 3498 3499 if ( that.isEnclosing() ) { 3500 TypeEnv env = api.isSome() ? returnTypeEnvForApi(api.unwrap()) : this.typeEnv; 3501 3502 Option<BindingLookup> binding = env.binding(that); 3503 if( binding.isSome() ) { 3504 return new TypeCheckerResult(that, binding.unwrap().getType()); 3505 } else { 3506 return new TypeCheckerResult(that, 3507 TypeError.make(errorMsg("Enclosing operator not found: ", 3508 that), 3509 that)); 3510 } 3511 } 3512 3515 3513 Option<BindingLookup> binding; 3516 3514 … … 3605 3603 // Guaranteed at least one operator because all the overloaded operators 3606 3604 // are created by disambiguation, not by the user. 3607 Op NameopName = IterUtil.first(that.getOp().getOps());3605 Op opName = IterUtil.first(that.getOp().getOps()); 3608 3606 return TypeCheckerResult.compose(that, subtypeChecker, 3609 3607 op_result, … … 3750 3748 that.getLexicalDepth(), 3751 3749 that.getOriginalName(), 3752 (List<Op Name>)TypeCheckerResult.astFromResults(ops_result));3750 (List<Op>)TypeCheckerResult.astFromResults(ops_result)); 3753 3751 } 3754 3752 … … 3808 3806 TypeCheckerResult obj_result = recur(that.getObj()); 3809 3807 List<TypeCheckerResult> subs_result = recurOnListOfExpr(that.getSubs()); 3810 Option<TypeCheckerResult> op_result = recurOnOptionOf Enclosing(that.getOp());3808 Option<TypeCheckerResult> op_result = recurOnOptionOfOp(that.getOp()); 3811 3809 List<TypeCheckerResult> staticArgs_result = recurOnListOfStaticArg(that.getStaticArgs()); 3812 3810 … … 4656 4654 } 4657 4655 4658 private TypeCheckerResult subscriptHelper(Node that, Option< Enclosing> op,4656 private TypeCheckerResult subscriptHelper(Node that, Option<Op> op, 4659 4657 Type obj_type, List<Type> subs_types, List<StaticArg> static_args) { 4660 4658 List<TraitType> traits = traitTypesCallable(obj_type); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeEnv.java
r3122 r3132 47 47 import com.sun.fortress.nodes.DimParam; 48 48 import com.sun.fortress.nodes.DimRef; 49 import com.sun.fortress.nodes.Enclosing;50 49 import com.sun.fortress.nodes.FnDecl; 51 50 import com.sun.fortress.nodes.Id; … … 221 220 } 222 221 223 static Enclosing removeApi(Enclosing id) {224 return NodeFactory.makeEnclosing(id.getSpan(), id.getOpen(), id.getClose());225 }226 227 222 static Op removeApi(Op id) { 228 return NodeFactory.makeOp(id.getSpan(), id.getText(), id.getFixity());223 return new Op(id.getSpan(), id.getText(), id.getFixity(), id.isEnclosing()); 229 224 } 230 225 231 226 static IdOrOpOrAnonymousName removeApi(IdOrOpOrAnonymousName id) { 232 227 return id.accept(new NodeDepthFirstVisitor<IdOrOpOrAnonymousName>(){ 233 @Override234 public IdOrOpOrAnonymousName forEnclosing(Enclosing that) {235 return NodeFactory.makeEnclosing(that.getSpan(), that.getOpen(), that.getClose());236 }237 228 @Override public IdOrOpOrAnonymousName forId(Id that) { return removeApi(that); } 238 229 @Override 239 230 public IdOrOpOrAnonymousName forOp(Op that) { 240 return NodeFactory.makeOp(that.getSpan(), that.getText(), that.getFixity());231 return new Op(that.getSpan(), that.getText(), that.getFixity(), that.isEnclosing()); 241 232 } 242 233 @Override -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/env/IndexedEnv.java
r3060 r3132 29 29 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 30 30 import com.sun.fortress.nodes.NamedType; 31 import com.sun.fortress.nodes.Op Name;31 import com.sun.fortress.nodes.Op; 32 32 import com.sun.fortress.nodes.OpRef; 33 33 import com.sun.fortress.nodes.TraitType; … … 46 46 public void assignValue(HasAt loc, String str, FValue f2) { 47 47 // TODO Auto-generated method stub 48 48 49 49 } 50 50 51 51 public void bless() { 52 52 // TODO Auto-generated method stub 53 53 54 54 } 55 55 56 56 public void debugPrint(String debugString) { 57 57 // TODO Auto-generated method stub 58 58 59 59 } 60 60 … … 234 234 } 235 235 236 public FValue getValue(Op Namename, int l) {236 public FValue getValue(Op name, int l) { 237 237 // TODO Auto-generated method stub 238 238 return null; … … 254 254 } 255 255 256 public FValue getValueNull(Op Namename, int l) {256 public FValue getValueNull(Op name, int l) { 257 257 // TODO Auto-generated method stub 258 258 return null; … … 296 296 public void noteName(String s) { 297 297 // TODO Auto-generated method stub 298 298 299 299 } 300 300 301 301 public void putApi(String apiName, Environment env) { 302 302 // TODO Auto-generated method stub 303 303 304 304 } 305 305 306 306 public void putBool(String str, Boolean f2) { 307 307 // TODO Auto-generated method stub 308 308 309 309 } 310 310 311 311 public void putBoolRaw(String str, Boolean f2) { 312 312 // TODO Auto-generated method stub 313 313 314 314 } 315 315 316 316 public void putFunctionalMethodInstance(String fndodname, FValue cl) { 317 317 // TODO Auto-generated method stub 318 318 319 319 } 320 320 321 321 public void putInt(String add_as, Number cnnf) { 322 322 // TODO Auto-generated method stub 323 323 324 324 } 325 325 326 326 public void putIntRaw(String str, Number f2) { 327 327 // TODO Auto-generated method stub 328 328 329 329 } 330 330 331 331 public void putNat(String str, Number f2) { 332 332 // TODO Auto-generated method stub 333 333 334 334 } 335 335 336 336 public void putNatRaw(String str, Number f2) { 337 337 // TODO Auto-generated method stub 338 338 339 339 } 340 340 341 341 public void putType(Id d, FType x) { 342 342 // TODO Auto-generated method stub 343 343 344 344 } 345 345 346 346 public void putType(String str, FType f2) { 347 347 // TODO Auto-generated method stub 348 348 349 349 } 350 350 351 351 public void putTypeRaw(String str, FType f2) { 352 352 // TODO Auto-generated method stub 353 353 354 354 } 355 355 356 356 public void putValue(FValue f1, FValue f2) { 357 357 // TODO Auto-generated method stub 358 358 359 359 } 360 360 361 361 public void putValue(Id d, FValue x) { 362 362 // TODO Auto-generated method stub 363 363 364 364 } 365 365 366 366 public void putValue(String str, FValue f2) { 367 367 // TODO Auto-generated method stub 368 368 369 369 } 370 370 371 371 public void putValueNoShadowFn(String fndodname, FValue cl) { 372 372 // TODO Auto-generated method stub 373 373 374 374 } 375 375 376 376 public void putValueRaw(String str, FValue f2) { 377 377 // TODO Auto-generated method stub 378 378 379 379 } 380 380 381 381 public void putValueRaw(String name, FValue value, FType ft) { 382 382 // TODO Auto-generated method stub 383 383 384 384 } 385 385 386 386 public void putVariable(String string, FType fvt) { 387 387 // TODO Auto-generated method stub 388 388 389 389 } 390 390 391 391 public void putVariable(String s, FValue value) { 392 392 // TODO Auto-generated method stub 393 393 394 394 } 395 395 396 396 public void putVariable(String str, FValue f2, FType ft) { 397 397 // TODO Auto-generated method stub 398 398 399 399 } 400 400 401 401 public void putVariablePlaceholder(String sname) { 402 402 // TODO Auto-generated method stub 403 403 404 404 } 405 405 406 406 public void removeType(String s) { 407 407 // TODO Auto-generated method stub 408 408 409 409 } 410 410 411 411 public void removeVar(String name) { 412 412 // TODO Auto-generated method stub 413 413 414 414 } 415 415 416 416 public void setTopLevel() { 417 417 // TODO Auto-generated method stub 418 418 419 419 } 420 420 421 421 public void storeType(HasAt x, String sname, FType ft) { 422 422 // TODO Auto-generated method stub 423 423 424 424 } 425 425 … … 428 428 Visitor2<String, Boolean> vb) { 429 429 // TODO Auto-generated method stub 430 430 431 431 } 432 432 433 433 public void visit(Visitor2<String, Object> nameCollector) { 434 434 // TODO Auto-generated method stub 435 435 436 436 } 437 437 … … 441 441 } 442 442 443 443 444 444 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BaseEnv.java
r3123 r3132 42 42 import com.sun.fortress.nodes.APIName; 43 43 import com.sun.fortress.nodes.Id; 44 import com.sun.fortress.nodes.IdOrOp Name;44 import com.sun.fortress.nodes.IdOrOp; 45 45 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 46 46 import com.sun.fortress.nodes.NamedType; 47 import com.sun.fortress.nodes.Op Name;47 import com.sun.fortress.nodes.Op; 48 48 import com.sun.fortress.nodes.OpRef; 49 49 import com.sun.fortress.nodes.TraitType; … … 520 520 521 521 final public FValue getValueNull(OpRef vr) { 522 Op Namename = vr.getOps().get(0);522 Op name = vr.getOps().get(0); 523 523 int l = vr.getLexicalDepth(); 524 524 return getValueNull(name, l); … … 532 532 } 533 533 534 final public FValue getValueNull(Op Namename, int l)534 final public FValue getValueNull(Op name, int l) 535 535 throws CircularDependenceError { 536 536 // String s = NodeUtil.nameString(name); … … 547 547 } 548 548 549 final public FValue getValue(Op Namename, int l)549 final public FValue getValue(Op name, int l) 550 550 throws CircularDependenceError { 551 551 // String s = NodeUtil.nameString(name); … … 555 555 556 556 } 557 private FValue getValueTail(IdOrOp Namename, int l, String local,557 private FValue getValueTail(IdOrOp name, int l, String local, 558 558 Option<APIName> opt_api) throws OptionUnwrapException, 559 559 CircularDependenceError { … … 566 566 } 567 567 568 private FValue getValueNullTail(IdOrOp Namename, int l, String local,568 private FValue getValueNullTail(IdOrOp name, int l, String local, 569 569 Option<APIName> opt_api) throws OptionUnwrapException, 570 570 CircularDependenceError { -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTopLevelEnvironments.java
r3123 r3132 35 35 import com.sun.fortress.nodes.Component; 36 36 import com.sun.fortress.nodes.Id; 37 import com.sun.fortress.nodes.IdOrOp Name;37 import com.sun.fortress.nodes.IdOrOp; 38 38 import com.sun.fortress.nodes.Import; 39 39 import com.sun.fortress.nodes.ImportApi; … … 42 42 import com.sun.fortress.nodes.Node; 43 43 import com.sun.fortress.nodes.NodeAbstractVisitor; 44 import com.sun.fortress.nodes.Op Name;44 import com.sun.fortress.nodes.Op; 45 45 import com.sun.fortress.nodes.StaticParam; 46 46 import com.sun.fortress.nodes.TraitDecl; … … 163 163 String s = x.getName().stringName(); 164 164 OverloadedFunction of = (OverloadedFunction) bindInto.getRootValue(s); 165 for (IdOrOp Namefn : x.getFns()) {165 for (IdOrOp fn : x.getFns()) { 166 166 Option<APIName> oapi = fn.getApiName(); 167 167 FValue oapi_val = null; … … 169 169 if (fn instanceof Id) { 170 170 oapi_val = bindInto.getValueNull((Id) fn, Environment.TOP_LEVEL); // top-level reference 171 } else if (fn instanceof Op Name) {172 oapi_val = bindInto.getValueNull((Op Name) fn, Environment.TOP_LEVEL); // top-level reference171 } else if (fn instanceof Op) { 172 oapi_val = bindInto.getValueNull((Op) fn, Environment.TOP_LEVEL); // top-level reference 173 173 } else { 174 174 bug("Unexpected change to AST node hierarchy"); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Environment.java
r3060 r3132 28 28 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 29 29 import com.sun.fortress.nodes.NamedType; 30 import com.sun.fortress.nodes.Op Name;30 import com.sun.fortress.nodes.Op; 31 31 import com.sun.fortress.nodes.OpRef; 32 32 import com.sun.fortress.nodes.TraitType; … … 92 92 public abstract FType getType(Id d); // 3 93 93 // BoolRef, IntRef, and the TL name of a (generic) trait. 94 94 95 95 public abstract FType getTypeNull(VarType q); // 2 96 96 public abstract FType getType(VarType q); // 2 97 97 // forTraitType, forVarType (these have lexical depth) 98 98 public abstract FType getType(TraitType q); // toplevel, possible api 99 99 100 100 public abstract FType getRootType(String str); // 10 refs 101 101 public abstract FType getLeafType(String str); // 4 refs … … 107 107 public abstract FType getRootTypeNull(String name); // 4 refs 108 108 public FType getTypeNull(String name); // 3 refs -- keep this name because of compiled code. 109 109 110 110 /** 111 111 * Level-tagged version of getTypeNull 112 * 112 * 113 113 * @param name 114 114 * @param level … … 116 116 */ 117 117 public FType getTypeNull(String name, int level); 118 118 119 119 //public abstract FValue getValue(FValue f1); 120 120 … … 134 134 */ 135 135 public abstract FValue getLeafValue(String str); // 25 refs 136 136 137 137 /** 138 138 * Get a value from top-level environment. … … 148 148 public abstract FValue getLeafValueNull(String s); // 6 refs 149 149 public abstract FValue getRootValueNull(String s); // 5 refs 150 150 151 151 /** 152 152 * Similar to the string version, but able to deal with 153 153 * depth information on the VarRef. 154 * 154 * 155 155 * @param vr 156 156 * @return 157 157 */ 158 158 public abstract FValue getValueNull(VarRef vr); // 2 refs 159 159 160 160 public abstract FValue getValueNull(OpRef vr); // 2 refs 161 161 162 162 public abstract FValue getValueNull(Id name, int l); // 3 refs 163 164 public abstract FValue getValueNull(Op Namename, int l); // 2 refs165 163 164 public abstract FValue getValueNull(Op name, int l); // 2 refs 165 166 166 public abstract FValue getValue(Id name, int l); // 0 refs 167 168 public abstract FValue getValue(Op Namename, int l); // 1 ref169 167 168 public abstract FValue getValue(Op name, int l); // 1 ref 169 170 170 public abstract FValue getValue(VarRef vr); // 0 refs 171 171 172 172 public abstract FValue getValue(OpRef vr); // 2 refs 173 173 … … 177 177 178 178 public abstract FType getVarTypeNull(String str); // 2 refs 179 // Leaf in baseenv, 179 // Leaf in baseenv, 180 180 // Can be level-indexed in LHSEvaluator 181 181 182 182 public abstract Environment installPrimitives(); 183 183 184 184 public boolean isTopLevel(); 185 185 186 186 // A notable name -- for overloading later, I think. 187 187 public abstract void noteName(String s); … … 190 190 191 191 public void putBoolRaw(String str, Boolean f2) ; 192 192 193 193 public abstract void putFunctionalMethodInstance(String fndodname, FValue cl); // Fcn? 194 194 … … 214 214 215 215 public abstract void putTypeRaw(String str, FType f2); 216 216 217 217 /** 218 218 * Put a value in the top-most scope. … … 252 252 253 253 public abstract void removeType(String s); 254 254 255 255 public abstract void removeVar(String name); 256 256 257 257 public abstract void setTopLevel(); 258 258 259 259 // Fix the untyped variable 260 260 public abstract void storeType(HasAt x, String sname, FType ft); … … 266 266 public abstract void visit(Visitor2<String, Object> nameCollector); 267 267 /** 268 * Returns the names of vars in the most recently added frame (everything 268 * Returns the names of vars in the most recently added frame (everything 269 269 * added since this environment was created with a call to "extend()" ). 270 270 */ 271 271 272 272 public Iterable<String> youngestFrame() ; 273 273 274 274 /** 275 275 * Level-tagged version of getValueRaw 276 * 276 * 277 277 * @param s 278 278 * @param level … … 280 280 */ 281 281 public FValue getValueRaw(String s, int level); 282 282 283 283 public Environment getApi(String s); 284 284 public Environment getApi(APIName s); 285 public Environment getApi(List<Id> s); 285 public Environment getApi(List<Id> s); 286 286 public Environment getApiNull(String apiName); 287 287 public void putApi(String apiName, Environment env); 288 288 289 289 public Environment getHomeEnvironment(IdOrOpOrAnonymousName ioooan); 290 290 291 291 public Environment getTopLevel(); 292 292 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java
r3123 r3132 89 89 import com.sun.fortress.nodes.Do; 90 90 import com.sun.fortress.nodes.DoFront; 91 import com.sun.fortress.nodes.Enclosing;92 91 import com.sun.fortress.nodes.Exit; 93 92 import com.sun.fortress.nodes.ExponentiationMI; … … 121 120 import com.sun.fortress.nodes.Op; 122 121 import com.sun.fortress.nodes.OpExpr; 123 import com.sun.fortress.nodes.OpName;124 122 import com.sun.fortress.nodes.OpRef; 125 123 import com.sun.fortress.nodes.Param; … … 252 250 // be no fear of duplicate evaluation. 253 251 OpRef opr_ = possOp.unwrap(); 254 //Op Nameopr = opr_.getOriginalName();252 //Op opr = opr_.getOriginalName(); 255 253 Fcn fcn = (Fcn) getOp(opr_);// opr.accept(this); 256 254 FValue lhsValue; … … 1059 1057 OpRef ref = expr.getOp(); 1060 1058 1061 Op Namename = ref.getOriginalName();1059 Op name = ref.getOriginalName(); 1062 1060 if (!(name instanceof Op)) return false; 1063 1061 else return (((Op)name).getText().equals("^") || … … 1085 1083 OpRef ref = x.getOp(); 1086 1084 1087 Op Nameop = ref.getOriginalName();1085 Op op = ref.getOriginalName(); 1088 1086 List<Expr> args = x.getArgs(); 1089 1087 FValue fvalue = getOp(ref); //op.accept(this); … … 1133 1131 } 1134 1132 Fcn fcn = (Fcn) fvalue; 1135 if (s <= 2 || (op instanceof Enclosing)) {1133 if (s <= 2 || op.isEnclosing()) { 1136 1134 res = functionInvocation(vargs, fcn, x); 1137 1135 } else { … … 1171 1169 FValue arr = obj.accept(this); 1172 1170 List<FValue> subs = evalExprListParallel(x.getSubs()); 1173 Option< Enclosing> op = x.getOp();1171 Option<Op> op = x.getOp(); 1174 1172 // Should evaluate obj.[](subs, getText) 1175 1173 String opString = "[]"; … … 1272 1270 if (opr instanceof ExponentiationMI) { 1273 1271 ExponentiationMI expo = (ExponentiationMI)opr; 1274 Op Nameop = expo.getOp().getOriginalName();1272 Op op = expo.getOp().getOriginalName(); 1275 1273 FValue fvalue = getOp(expo.getOp()); //op.accept(this); 1276 1274 if (!isFunction(fvalue)) -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java
r3123 r3132 44 44 import com.sun.fortress.nodes.AbstractFieldRef; 45 45 import com.sun.fortress.nodes.Name; 46 import com.sun.fortress.nodes.Op; 46 47 import com.sun.fortress.nodes.NodeAbstractVisitor; 47 48 import com.sun.fortress.nodes.Expr; … … 51 52 import com.sun.fortress.nodes.LValue; 52 53 import com.sun.fortress.nodes.SubscriptExpr; 53 import com.sun.fortress.nodes.Enclosing;54 54 import com.sun.fortress.nodes.TupleExpr; 55 55 import com.sun.fortress.nodes.Type; … … 77 77 args.add(value); 78 78 args.addAll(indices); 79 Option< Enclosing> op = x.getOp();79 Option<Op> op = x.getOp(); 80 80 // Should evaluate obj.[](subs, value) 81 81 String opString = "[]="; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java
r3096 r3132 26 26 import com.sun.fortress.nodes.NodeUpdateVisitor; 27 27 import com.sun.fortress.nodes.Op; 28 import com.sun.fortress.nodes.OpName;29 28 import com.sun.fortress.nodes.OpParam; 30 29 import com.sun.fortress.nodes.OpRef; … … 63 62 @Override 64 63 public Node forOpRef(OpRef op) { 65 final Op NameoriginalName = op.getOriginalName();66 final List<Op Name> ops = op.getOps();64 final Op originalName = op.getOriginalName(); 65 final List<Op> ops = op.getOps(); 67 66 final List<StaticArg> args = op.getStaticArgs(); 68 67 final Option<Type> otype = op.getExprType(); 69 68 final Type type = otype.isNone() ? null : otype.unwrap(); 70 69 71 Op Name n_originalName = (OpName) recur(originalName);72 List<Op Name> n_ops = recurOnListOfOpName(ops);70 Op n_originalName = (Op) recur(originalName); 71 List<Op> n_ops = recurOnListOfOp(ops); 73 72 List<StaticArg> n_args = recurOnListOfStaticArg(args); 74 73 Type n_type = type == null ? (Type) null : (Type) recur(type); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java
r3123 r3132 159 159 public String forOp(Op node) { 160 160 return node.getText(); 161 }162 163 public String forEnclosing(Enclosing node) {164 return node.getOpen().getText() + node.getClose().getText();165 161 } 166 162 -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r3123 r3132 256 256 257 257 public static OpRef makeOpRef(Span span, String name) { 258 Op Nameop = NodeFactory.makeOpInfix(span, name);258 Op op = NodeFactory.makeOpInfix(span, name); 259 259 return new OpRef(span, op, Collections.singletonList(op)); 260 260 } 261 261 262 public static OpRef makeOpRef(Op Nameop) {262 public static OpRef makeOpRef(Op op) { 263 263 return new OpRef(op.getSpan(), op, Collections.singletonList(op)); 264 264 } 265 265 266 public static OpRef makeOpRef(Op Nameop, List<StaticArg> staticArgs) {266 public static OpRef makeOpRef(Op op, List<StaticArg> staticArgs) { 267 267 return new OpRef(op.getSpan(), staticArgs, op, Collections.singletonList(op)); 268 268 } … … 273 273 } 274 274 275 public static OpExpr makeOpExpr(Span span, Op Nameop) {275 public static OpExpr makeOpExpr(Span span, Op op) { 276 276 return new OpExpr(span, false, makeOpRef(op)); 277 277 } 278 278 279 public static OpExpr makeOpExpr(Span span, Op Nameop, Expr arg) {279 public static OpExpr makeOpExpr(Span span, Op op, Expr arg) { 280 280 return new OpExpr(span, false, makeOpRef(op), 281 281 Collections.singletonList(arg)); 282 282 } 283 283 284 public static OpExpr makeOpExpr(Span span, Op Nameop, Expr first,284 public static OpExpr makeOpExpr(Span span, Op op, Expr first, 285 285 Expr second) { 286 286 return new OpExpr(span, false, makeOpRef(op), … … 288 288 } 289 289 290 public static OpExpr makeOpExpr(Span span, Op Nameop, List<StaticArg> staticArgs) {290 public static OpExpr makeOpExpr(Span span, Op op, List<StaticArg> staticArgs) { 291 291 return new OpExpr(span, false, makeOpRef(op, staticArgs)); 292 292 } 293 293 294 public static OpExpr makeOpExpr(Span span, Op Nameop, Expr arg,294 public static OpExpr makeOpExpr(Span span, Op op, Expr arg, 295 295 List<StaticArg> staticArgs) { 296 296 return new OpExpr(span, false, makeOpRef(op, staticArgs), … … 375 375 List<Expr> subs) { 376 376 return new SubscriptExpr(span, false, obj, subs, 377 Option.<Enclosing>none(),378 Collections.<StaticArg>emptyList());377 Option.<Op>none(), 378 Collections.<StaticArg>emptyList()); 379 379 } 380 380 381 381 public static SubscriptExpr makeSubscriptExpr(Span span, Expr obj, 382 List<Expr> subs,383 Option<Enclosing> op,384 List<StaticArg> sargs) {382 List<Expr> subs, 383 Option<Op> op, 384 List<StaticArg> sargs) { 385 385 return new SubscriptExpr(span, false, obj, Useful.immutableTrimmedList(subs), op, sargs); 386 386 } 387 387 388 388 public static SubscriptExpr makeSubscriptExpr(Span span, Expr obj, 389 List<Expr> subs,390 Option<Enclosing> op) {389 List<Expr> subs, 390 Option<Op> op) { 391 391 return new SubscriptExpr(span, false, obj, subs, op, 392 392 Collections.<StaticArg>emptyList()); … … 904 904 */ 905 905 private static Expr makeInfixOpExpr(Span s, Expr lhs, OpRef op, Expr rhs) { 906 List<Op Name> new_ops = CollectUtil.makeList(IterUtil.map(op.getOps(), new Lambda<OpName,OpName>(){907 public Op value(Op Namearg0) {908 if( arg0 instanceof Enclosing)906 List<Op> new_ops = CollectUtil.makeList(IterUtil.map(op.getOps(), new Lambda<Op,Op>(){ 907 public Op value(Op arg0) { 908 if( arg0.isEnclosing() ) 909 909 return bug("Can't make an infix operator out of an enclosing operator."); 910 910 else … … 913 913 // We are remaking this because we think that the Interpreter expects originalName to be infix 914 914 Op new_original_name; 915 if( op.getOriginalName() instanceof Enclosing)915 if( op.getOriginalName().isEnclosing() ) 916 916 return bug("Can't make an infix operator out of an enclosing operator."); 917 917 else … … 923 923 924 924 private static Expr makePostfixOpExpr(Span s, Expr e, OpRef op) { 925 List<Op Name> new_ops = CollectUtil.makeList(IterUtil.map(op.getOps(), new Lambda<OpName,OpName>(){926 public Op value(Op Namearg0) {927 if( arg0 instanceof Enclosing)925 List<Op> new_ops = CollectUtil.makeList(IterUtil.map(op.getOps(), new Lambda<Op,Op>(){ 926 public Op value(Op arg0) { 927 if( arg0.isEnclosing() ) 928 928 return bug("Can't make an postfix operator out of an enclosing operator."); 929 929 else … … 932 932 // We are remaking this because we think that the Interpreter expects originalName to be postfix 933 933 Op new_original_name; 934 if( op.getOriginalName() instanceof Enclosing)934 if( op.getOriginalName().isEnclosing() ) 935 935 return bug("Can't make an postfix operator out of an enclosing operator."); 936 936 else -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeComparator.java
r3123 r3132 137 137 public final static IdComparer idComparer = new IdComparer(); 138 138 139 static class Op NameComparer implements Comparator<OpName> {140 public int compare(Op Name left, OpNameright) {141 return NodeComparator.compare(left, right); 142 } 143 } 144 145 public final static Op NameComparer opNameComparer = new OpNameComparer();139 static class OpComparer implements Comparator<Op> { 140 public int compare(Op left, Op right) { 141 return NodeComparator.compare(left, right); 142 } 143 } 144 145 public final static OpComparer opNameComparer = new OpComparer(); 146 146 147 147 /* comparing lists ***************************************************/ -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3123 r3132 173 173 } 174 174 175 public static Op Name makeTemporaryOpName() {175 public static Op makeTemporaryOp() { 176 176 return makeOp("$$bogus_name$$"); 177 177 } … … 222 222 223 223 public static AliasedSimpleName makeAliasedSimpleName(Span span, 224 IdOrOpOrAnonymousName name) {224 IdOrOpOrAnonymousName name) { 225 225 return new AliasedSimpleName(span, name, Option.<IdOrOpOrAnonymousName>none()); 226 226 } 227 227 228 228 public static AliasedSimpleName makeAliasedSimpleName(Span span, 229 IdOrOpOrAnonymousName name,230 Id alias) {229 IdOrOpOrAnonymousName name, 230 Id alias) { 231 231 return new AliasedSimpleName(span, name, 232 Option.<IdOrOpOrAnonymousName>some(alias));232 Option.<IdOrOpOrAnonymousName>some(alias)); 233 233 } 234 234 … … 238 238 239 239 public static AliasedSimpleName makeAliasedSimpleName(Span span, Id id, 240 Id alias) {240 Id alias) { 241 241 return new AliasedSimpleName(span, id, Option.<IdOrOpOrAnonymousName>some(alias)); 242 242 } 243 243 244 244 /** Alternatively, you can invoke the FnDecl constructor without an alias */ 245 public static AliasedSimpleName makeAliasedSimpleName(Span span, Op Nameop) {245 public static AliasedSimpleName makeAliasedSimpleName(Span span, Op op) { 246 246 return new AliasedSimpleName(span, op, Option.<IdOrOpOrAnonymousName>none()); 247 247 } 248 248 249 public static AliasedSimpleName makeAliasedSimpleName(Span span, Op Nameop,250 OpNamealias) {249 public static AliasedSimpleName makeAliasedSimpleName(Span span, Op op, 250 Op alias) { 251 251 return new AliasedSimpleName(span, op, Option.<IdOrOpOrAnonymousName>some(alias)); 252 252 } … … 840 840 } 841 841 842 public static Enclosing makeEnclosing(Span in_span, Op in_open, Op in_close) { 843 return new Enclosing(in_span, in_open, in_close); 842 public static Op makeEnclosing(Span in_span, String in_open, String in_close) { 843 return new Op(in_span, PrecedenceMap.ONLY.canon(in_open + " " + in_close), 844 enclosing, true); 844 845 } 845 846 … … 855 856 856 857 public static Op makeOp(String name) { 857 return new Op(new Span(), PrecedenceMap.ONLY.canon(name), unknownFix );858 return new Op(new Span(), PrecedenceMap.ONLY.canon(name), unknownFix, false); 858 859 } 859 860 860 861 public static Op makeOp(Span span, String name) { 861 return new Op(span, PrecedenceMap.ONLY.canon(name), unknownFix );862 return new Op(span, PrecedenceMap.ONLY.canon(name), unknownFix, false); 862 863 } 863 864 864 865 public static Op makeOp(Span span, String name, Fixity fixity) { 865 return new Op(span, PrecedenceMap.ONLY.canon(name), fixity );866 return new Op(span, PrecedenceMap.ONLY.canon(name), fixity, false); 866 867 } 867 868 868 869 public static Op makeOp(Op op, String name) { 869 870 return new Op(op.getSpan(), PrecedenceMap.ONLY.canon(name), 870 op.getFixity());871 op.getFixity(), op.isEnclosing()); 871 872 } 872 873 873 874 public static Op makeOpInfix(Span span, String name) { 874 return new Op(span, PrecedenceMap.ONLY.canon(name), infix );875 return new Op(span, PrecedenceMap.ONLY.canon(name), infix, false); 875 876 } 876 877 877 878 public static Op makeOpInfix(Span span, String apiName, String name) { 878 Op op = new Op(span, Option.some(NodeFactory.makeAPIName(apiName)), PrecedenceMap.ONLY.canon(name), infix); 879 Op op = new Op(span, Option.some(NodeFactory.makeAPIName(apiName)), 880 PrecedenceMap.ONLY.canon(name), infix, false); 879 881 return op; 880 882 … … 882 884 883 885 public static Op makeOpInfix(Op op) { 884 return new Op(op.getSpan(), op.getApiName(), op.getText(), infix );886 return new Op(op.getSpan(), op.getApiName(), op.getText(), infix, op.isEnclosing()); 885 887 } 886 888 887 889 public static Op makeOpPrefix(Span span, String name) { 888 return new Op(span, PrecedenceMap.ONLY.canon(name), prefix );890 return new Op(span, PrecedenceMap.ONLY.canon(name), prefix, false); 889 891 } 890 892 891 893 public static Op makeOpPrefix(Op op) { 892 return new Op(op.getSpan(), op.getApiName(), op.getText(), prefix );894 return new Op(op.getSpan(), op.getApiName(), op.getText(), prefix, op.isEnclosing()); 893 895 } 894 896 895 897 public static Op makeOpPostfix(Span span, String name) { 896 return new Op(span, PrecedenceMap.ONLY.canon(name), postfix );898 return new Op(span, PrecedenceMap.ONLY.canon(name), postfix, false); 897 899 } 898 900 899 901 public static Op makeOpPostfix(Op op) { 900 return new Op(op.getSpan(), op.getApiName(), op.getText(), postfix );902 return new Op(op.getSpan(), op.getApiName(), op.getText(), postfix, op.isEnclosing()); 901 903 } 902 904 903 905 /** 904 * Rewrites the given Op Namewith the given api. Dispatches on the905 * type of op, so that the same subtype of Op Nameis created.906 * Rewrites the given Op with the given api. Dispatches on the 907 * type of op, so that the same subtype of Op is created. 906 908 */ 907 public static OpName makeOpName(final APIName api, OpName op) { 908 return op.accept(new NodeAbstractVisitor<OpName>(){ 909 @Override 910 public OpName forEnclosing(Enclosing that) { return new Enclosing(that.getSpan(), Option.some(api), that.getOpen(), that.getClose()); } 911 @Override 912 public OpName forOp(Op that) { return new Op(that.getSpan(), Option.some(api), that.getText(), that.getFixity() ); } 913 @Override 914 public OpName forOpName(OpName that) { return bug("A case was missed in the implementation of makeOpName."); } 915 916 }); 909 public static Op makeOp(final APIName api, Op op) { 910 return new Op(op.getSpan(), Option.some(api), 911 op.getText(), op.getFixity(), op.isEnclosing() ); 917 912 } 918 913 919 914 public static Op makeOpNofix(Op op) { 920 return new Op(op.getSpan(), op.getText(), nofix );915 return new Op(op.getSpan(), op.getText(), nofix, op.isEnclosing()); 921 916 } 922 917 923 918 public static Op makeOpMultifix(Op op) { 924 return new Op(op.getSpan(), op.getText(), multifix );919 return new Op(op.getSpan(), op.getText(), multifix, op.isEnclosing()); 925 920 } 926 921 927 922 public static Op makeOpEnclosing(Span span, String name) { 928 return new Op(span, PrecedenceMap.ONLY.canon(name), enclosing );923 return new Op(span, PrecedenceMap.ONLY.canon(name), enclosing, false); 929 924 } 930 925 931 926 public static Op makeOpBig(Span span, String name) { 932 return new Op(span, PrecedenceMap.ONLY.canon(name), big );927 return new Op(span, PrecedenceMap.ONLY.canon(name), big, false); 933 928 } 934 929 935 930 public static Op makeOpUnknown(Span span, String name) { 936 return new Op(span, PrecedenceMap.ONLY.canon(name), unknownFix); 937 } 938 939 public static Op makeBig(Op op) { 940 return new Op(op.getSpan(), PrecedenceMap.ONLY.canon("BIG " + op.getText()), big); 941 } 942 943 public static Enclosing makeBig(Enclosing op) { 944 return new Enclosing(op.getSpan(), makeBig(op.getOpen()), makeBig(op.getClose())); 945 } 931 return new Op(span, PrecedenceMap.ONLY.canon(name), unknownFix, false); 932 } 933 934 public static Op makeBig(Op op) { 935 if ( op.isEnclosing() ) { 936 String _op = op.getText(); 937 String left = _op.split(" ")[0]; 938 String right = "BIG " + _op.substring(left.length()+1); 939 left = "BIG " + left; 940 return makeEnclosing(op.getSpan(), left, right); 941 } else 942 return new Op(op.getSpan(), PrecedenceMap.ONLY.canon("BIG " + op.getText()), big, op.isEnclosing() ); 943 } 946 944 947 945 public static Param makeVarargsParam(Id name, Type type) { … … 1323 1321 } 1324 1322 1325 public static OpName makeListOpName(Span span) { 1326 Op open = NodeFactory.makeOpEnclosing(span, "<|"); 1327 Op close = NodeFactory.makeOpEnclosing(span, "|>"); 1328 return new Enclosing(FortressUtil.spanTwo(open,close), open,close); 1323 public static Op makeListOp(Span span) { 1324 return makeEnclosing(span, "<|", "|>"); 1329 1325 } 1330 1326 -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java
r3123 r3132 216 216 } 217 217 public String forOp(Op n) { 218 return OprUtil.fixityDecorator(n.getFixity(), n.getText()); 219 } 220 public String forEnclosing(Enclosing n) { 221 // Interior space is REQUIRED 222 return n.getOpen().getText() + " " + n.getClose().getText(); 218 if ( n.isEnclosing() ) 219 return n.getText(); 220 else return OprUtil.fixityDecorator(n.getFixity(), n.getText()); 223 221 } 224 222 public String forAnonymousFnName(AnonymousFnName n) { … … 246 244 } 247 245 public String forOp(Op n) { 248 Option<APIName> odn = n.getApiName(); 249 String last = OprUtil.fixityDecorator(n.getFixity(), n.getText()); 250 return odn.isSome() ? nameString(odn.unwrap()) + "." + last : last; 251 } 252 public String forEnclosing(Enclosing n) { 253 Option<APIName> odn = n.getApiName(); 254 // Interior space is REQUIRED 255 String last = n.getOpen().getText() + " " + n.getClose().getText(); 256 return odn.isSome() ? nameString(odn.unwrap()) + "." + last : last; 257 246 if ( n.isEnclosing() ) { 247 Option<APIName> odn = n.getApiName(); 248 String last = n.getText(); 249 return odn.isSome() ? nameString(odn.unwrap()) + "." + last : last; 250 } else { 251 Option<APIName> odn = n.getApiName(); 252 String last = OprUtil.fixityDecorator(n.getFixity(), n.getText()); 253 return odn.isSome() ? nameString(odn.unwrap()) + "." + last : last; 254 } 258 255 } 259 256 public String forAnonymousFnName(AnonymousFnName n) { … … 310 307 311 308 public static String nameString(Op n) { 312 return OprUtil.fixityDecorator(n.getFixity(), n.getText()); 313 } 314 315 public static String nameString(Enclosing n) { 316 // Interior space is REQUIRED 317 return n.getOpen().getText() + " " + n.getClose().getText(); 309 if ( n.isEnclosing() ) 310 return n.getText(); 311 else return OprUtil.fixityDecorator(n.getFixity(), n.getText()); 318 312 } 319 313 public static String nameString(AnonymousFnName n) { … … 373 367 @Override 374 368 public String forOp(Op that) { 375 return OprUtil.fixityDecorator(that.getFixity(), that.getText()); 376 } 377 @Override 378 public String forEnclosing(Enclosing that) { 379 String o = that.getOpen().accept(this); 380 String c = that.getClose().accept(this); 381 return o + " " + c; 369 if ( that.isEnclosing() ) 370 return that.getText(); 371 else return OprUtil.fixityDecorator(that.getFixity(), that.getText()); 382 372 } 383 373 @Override -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/OprUtil.java
r3120 r3132 18 18 package com.sun.fortress.nodes_util; 19 19 20 import com.sun.fortress.nodes.Enclosing;21 20 import com.sun.fortress.nodes.Fixity; 22 21 import com.sun.fortress.nodes.Node; 23 22 import com.sun.fortress.nodes.NodeAbstractVisitor; 24 23 import com.sun.fortress.nodes.Op; 25 import com.sun.fortress.nodes.OpName;26 24 import com.sun.fortress.nodes.UnknownFixity; 27 25 import com.sun.fortress.nodes.PostFixity; … … 30 28 31 29 public final class OprUtil { 32 public static boolean isEnclosing(Op Nameop) {33 return (op instanceof Enclosing);30 public static boolean isEnclosing(Op op) { 31 return op.isEnclosing(); 34 32 } 35 33 36 private static boolean isNotEnclosing(Op Nameop) {34 private static boolean isNotEnclosing(Op op) { 37 35 return !(isEnclosing(op)); 38 36 } 39 37 40 38 public static boolean isUnknownFixity(Op name) { 39 if (name.isEnclosing()) 40 return false; 41 41 return name.getFixity() instanceof UnknownFixity; 42 42 } 43 43 44 public static boolean is UnknownFixity(OpNamename) {45 if (name instanceof Enclosing)44 public static boolean isPostfix(Op name) { 45 if (name.isEnclosing()) 46 46 return false; 47 return isUnknownFixity((Op)name);48 }49 50 private static boolean isPostfix(Op name) {51 47 return name.getFixity() instanceof PostFixity; 52 48 } 53 49 54 public static boolean isPostfix(OpName name) { 55 if (name instanceof Enclosing) 56 return false; 57 return isPostfix((Op)name); 58 } 59 60 public static Op getOp(OpName op) { 50 public static Op getOp(Op op) { 61 51 if (isEnclosing(op)) { 62 return ((Enclosing)op).getOpen(); 52 String open = op.getText().split(" ")[0]; 53 return NodeFactory.makeOpInfix(op.getSpan(), open); 63 54 } else { // op instanceof Op 64 55 return (Op)op; … … 66 57 } 67 58 68 public static boolean hasPrefixColon(Op op) { 69 String opName = op.getText(); 70 return (opName.length()>1 && opName.charAt(0)==':' && !opName.equals("::")); 71 } 72 73 public static boolean hasPrefixColon(OpName n) { 59 public static boolean hasPrefixColon(Op n) { 74 60 if (isNotEnclosing(n)) { 75 return hasPrefixColon((Op)n); 61 String opName = n.getText(); 62 return (opName.length()>1 && opName.charAt(0)==':' && !opName.equals("::")); 76 63 } else { 77 64 return false; … … 79 66 } 80 67 81 public static boolean hasSuffixColon(Op op) { 82 String opName = op.getText(); 83 int l = opName.length(); 84 return (l>1 && opName.charAt(l-1)==':' && !opName.equals("::")); 85 } 86 87 public static boolean hasSuffixColon(OpName n) { 68 public static boolean hasSuffixColon(Op n) { 88 69 if (isNotEnclosing(n)) { 89 return hasSuffixColon((Op)n); 70 String opName = n.getText(); 71 int l = opName.length(); 72 return (l>1 && opName.charAt(l-1)==':' && !opName.equals("::")); 90 73 } else { 91 74 return false; … … 93 76 } 94 77 95 public static String noColonText(Op op) { 96 String opName = op.getText(); 97 int l = opName.length(); 98 int i = 0; 99 if (hasSuffixColon(op)) { 100 l--; 101 } 102 if (hasPrefixColon(op)) { 103 i++; 104 } 105 if (l < opName.length()) { 106 opName = opName.substring(i,l); 107 } 108 return opName; 109 } 110 111 public static String noColonText(OpName n) { 78 public static String noColonText(Op n) { 112 79 if (isNotEnclosing(n)) { 113 return noColonText((Op)n); 80 String opName = n.getText(); 81 int l = opName.length(); 82 int i = 0; 83 if (hasSuffixColon(n)) { 84 l--; 85 } 86 if (hasPrefixColon(n)) { 87 i++; 88 } 89 if (l < opName.length()) { 90 opName = opName.substring(i,l); 91 } 92 return opName; 114 93 } else { 115 94 return getOp(n).getText(); … … 117 96 } 118 97 119 public static Op noColon(Op op) { 120 if (hasSuffixColon(op) || hasPrefixColon(op)) { 121 return NodeFactory.makeOp(op.getSpan(),noColonText(op), 122 op.getFixity()); 123 } 124 return op; 125 } 126 127 public static OpName noColon(OpName n) { 98 public static Op noColon(Op n) { 128 99 if (isNotEnclosing(n)) { 129 Op op = noColon((Op)n); 100 Op op = n; 101 if (hasSuffixColon(op) || hasPrefixColon(op)) { 102 op = NodeFactory.makeOp(op.getSpan(),noColonText(op), 103 op.getFixity()); 104 } 130 105 if (op != n) return op; 131 106 } … … 164 139 /** Return a new operator with the fixity prepended to the text. */ 165 140 public static Op decorateOperator(Op o) { 166 return new Op(o.getSpan(), fixityDecorator(o.getFixity(), o.getText()), o.getFixity() );141 return new Op(o.getSpan(), fixityDecorator(o.getFixity(), o.getText()), o.getFixity(), o.isEnclosing()); 167 142 } 168 143 … … 173 148 return o; 174 149 } 175 return new Op(o.getSpan(), o.getText().substring(i+1), o.getFixity() );150 return new Op(o.getSpan(), o.getText().substring(i+1), o.getFixity(), o.isEnclosing()); 176 151 } 177 152 -
trunk/ProjectFortress/src/com/sun/fortress/parser/DelimitedExpr.rats
r3111 r3132 329 329 a3:GeneratorClauseList w closecurly 330 330 { Span span = createSpan(yyStart,yyCount); 331 Op open = NodeFactory.makeOpBig(span, "BIG {|->"); 332 Op close = NodeFactory.makeOpBig(span, "BIG }"); 333 OpName opr = new Enclosing(span, open, close); 331 Op opr = NodeFactory.makeEnclosing(span, "BIG {|->", "BIG }"); 334 332 if (a1 == null) a1 = Collections.<StaticArg>emptyList(); 335 333 yyValue = new Accumulator(createSpan(yyStart,yyCount), a1, opr, a3, a2); … … 338 336 a4:GeneratorClauseList w a5:RightEncloser 339 337 { Span span = createSpan(yyStart,yyCount); 340 Op open = NodeFactory.makeOpBig(span, "BIG " + a1.getText()); 341 Op close = NodeFactory.makeOpBig(span, "BIG " + a5.getText()); 342 OpName opr = new Enclosing(span, open, close); 338 Op opr = NodeFactory.makeEnclosing(span, "BIG " + a1.getText(), 339 "BIG " + a5.getText()); 343 340 if (a2 == null) a2 = Collections.<StaticArg>emptyList(); 344 341 yyValue = new Accumulator(createSpan(yyStart,yyCount), a2, opr, a4, a3); -
trunk/ProjectFortress/src/com/sun/fortress/parser/Expression.rats
r2840 r3132 133 133 if (a3 == null) es = FortressUtil.emptyExprs(); 134 134 else es = a3; 135 Enclosing op = new Enclosing(FortressUtil.spanTwo(a1,a4),a1,a4); 135 Op op = NodeFactory.makeEnclosing(FortressUtil.spanTwo(a1,a4), 136 a1.getText(),a4.getText()); 136 137 return ExprFactory.makeSubscriptExpr(span,base,es,Option.some(op), 137 138 sargs); … … 465 466 if (a2 == null) ss = Collections.<StaticArg>emptyList(); 466 467 else ss = a2; 467 return FortressUtil.makeSubscripting(span, spanOpen,spanClose,468 return FortressUtil.makeSubscripting(span, 468 469 a1, a4, base, a3, ss); 469 470 } else return syntaxError(span, … … 484 485 if (a2 == null) ss = Collections.<StaticArg>emptyList(); 485 486 else ss = a2; 486 return FortressUtil.makeSubscripting(span, base, a1, a4, a3, ss); 487 return FortressUtil.makeSubscripting(span, base, a1.getText(), 488 a4.getText(), a3, ss); 487 489 }}; 488 490 }; … … 587 589 { Span span = createSpan(yyStart,yyCount); 588 590 if (PrecedenceMap.ONLY.matchedBrackets(a1, a4)) { 589 Span spanOpen = createSpan(yyStart, yyStart+1); 590 Span spanClose = createSpan(yyCount-1,1); 591 Op open = NodeFactory.makeOpEnclosing(spanOpen, a1); 592 Op close = NodeFactory.makeOpEnclosing(spanClose, a4); 593 Enclosing op = new Enclosing(FortressUtil.spanTwo(open,close), 594 open,close); 595 if (a2 == null) a2 = Collections.<StaticArg>emptyList(); 596 if (a3 == null) a3 = Collections.<Expr>emptyList(); 597 yyValue = new SubscriptingMI(span, op, a3, a2); 591 Op op = NodeFactory.makeEnclosing(span, a1, a4); 592 if (a2 == null) a2 = Collections.<StaticArg>emptyList(); 593 if (a3 == null) a3 = Collections.<Expr>emptyList(); 594 yyValue = new SubscriptingMI(span, op, a3, a2); 598 595 } else return syntaxError(span, 599 596 "Mismatched subscripting operator: " + a1 + … … 607 604 / a1:LeftEncloser a2:StaticArgs? a3:(w ExprList)? w a4:RightEncloser 608 605 { Span span = createSpan(yyStart,yyCount); 609 Enclosing op = new Enclosing(FortressUtil.spanTwo(a1,a4),a1,a4);606 Op op = NodeFactory.makeEnclosing(span, a1.getText(),a4.getText()); 610 607 if (a2 == null) a2 = Collections.<StaticArg>emptyList(); 611 608 if (a3 == null) a3 = Collections.<Expr>emptyList(); … … 683 680 { Span span = createSpan(yyStart,yyCount); 684 681 if (a1 == null) a1 = Collections.<StaticArg>emptyList(); 685 Op open = NodeFactory.makeOpBig(span, "BIG {|->"); 686 Op close = NodeFactory.makeOpBig(span, "BIG }"); 687 OpName opr = new Enclosing(span, open, close); 682 Op opr = NodeFactory.makeEnclosing(span, "BIG {|->", "BIG }"); 688 683 yyValue = ExprFactory.makeOpExpr(span, opr, a2, a1); 689 684 } … … 691 686 { Span span = createSpan(yyStart,yyCount); 692 687 if (a2 == null) a2 = Collections.<StaticArg>emptyList(); 693 Op open = NodeFactory.makeOpBig(span, "BIG " + a1.getText()); 694 Op close = NodeFactory.makeOpBig(span, "BIG " + a3.getText()); 695 OpName opr = new Enclosing(span, open, close); 688 Op opr = NodeFactory.makeEnclosing(span, "BIG " + a1.getText(), 689 "BIG " + a3.getText()); 696 690 yyValue = ExprFactory.makeOpExpr(span, opr, a4, a2); 697 691 } -
trunk/ProjectFortress/src/com/sun/fortress/parser/Identifier.rats
r3034 r3132 56 56 57 57 /* IdOrOpName ::= Id | OpName */ 58 IdOrOp NameIdOrOpName = Id / OpName ;58 IdOrOp IdOrOpName = Id / OpName ; 59 59 60 60 /* BindId ::= Id | _ */ -
trunk/ProjectFortress/src/com/sun/fortress/parser/MethodParam.rats
r3107 r3132 85 85 (right.equals("}") || right.equals("\u007d"))) { 86 86 if (big != null) { 87 left Op = NodeFactory.makeOpBig(leftOp.getSpan(), "BIG " + left);88 opa4 = NodeFactory.makeOpBig(opa4.getSpan(), "BIG " + right);87 left = "BIG " + left; 88 right = "BIG " + right; 89 89 } 90 name = new Enclosing(span, leftOp, opa4);90 name = NodeFactory.makeEnclosing(span, left, right); 91 91 } else 92 92 name = syntaxError(leftOp.getSpan(), … … 123 123 left.equals("{|->") && right.equals("}")) { 124 124 if (big != null) { 125 left Op = NodeFactory.makeOpBig(leftOp.getSpan(), "BIG " + left);126 opa4 = NodeFactory.makeOpBig(opa4.getSpan(), "BIG " + right);125 left = "BIG " + left; 126 right = "BIG " + right; 127 127 } 128 name = new Enclosing(span, leftOp, opa4);128 name = NodeFactory.makeEnclosing(span, left, right); 129 129 } else 130 130 name = syntaxError(leftOp.getSpan(), -
trunk/ProjectFortress/src/com/sun/fortress/parser/OtherDecl.rats
r3034 r3132 1 /*******************************************************************************1 /******************************************************************************* 2 2 Copyright 2008 Sun Microsystems, Inc., 3 3 4150 Network Circle, Santa Clara, California 95054, U.S.A. -
trunk/ProjectFortress/src/com/sun/fortress/parser/Parameter.rats
r3107 r3132 165 165 (right.equals("}") || right.equals("\u007d"))) { 166 166 if (big != null) { 167 left Op = NodeFactory.makeOpBig(leftOp.getSpan(), "BIG " + left);168 opa4 = NodeFactory.makeOpBig(opa4.getSpan(), "BIG " + right);167 left = "BIG " + left; 168 right = "BIG " + right; 169 169 } 170 name = new Enclosing(span, leftOp, opa4);170 name = NodeFactory.makeEnclosing(span, left, right); 171 171 } else 172 172 name = syntaxError(leftOp.getSpan(), … … 239 239 left.equals("{|->") && right.equals("}")) { 240 240 if (big != null) { 241 left Op = NodeFactory.makeOpBig(leftOp.getSpan(), "BIG " + left);242 opa4 = NodeFactory.makeOpBig(opa4.getSpan(), "BIG " + right);241 left = "BIG " + left; 242 right = "BIG " + right; 243 243 } 244 name = new Enclosing(span, leftOp, opa4);244 name = NodeFactory.makeEnclosing(span, left, right); 245 245 } else 246 246 name = syntaxError(leftOp.getSpan(), -
trunk/ProjectFortress/src/com/sun/fortress/parser/Symbol.rats
r3032 r3132 47 47 (LeftEncloser | Encloser) (w DOT)? w (RightEncloser | Encloser) 48 48 */ 49 EnclosingEncloserPair =49 Op EncloserPair = 50 50 a1:(LeftEncloser / Encloser) (w DOT)? w a2:(RightEncloser / Encloser) 51 51 { if (PrecedenceMap.ONLY.matchedBrackets(a1.getText(), a2.getText())) 52 yyValue = new Enclosing(createSpan(yyStart,yyCount), a1, a2);52
