Changeset 3120

Show
Ignore:
Timestamp:
11/29/08 06:56:10 (12 months ago)
Author:
sukyoungryu
Message:

[ast refactoring] Always provide a fixity for an Op.

Location:
trunk/ProjectFortress
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/ProjectFortress/astgen/Fortress.ast

    r3118 r3120  
    18961896                             * e.g.) === 
    18971897                             */ 
    1898                             Op(String text, 
    1899                                Option<Fixity> fixity = Option.<Fixity>none()); 
     1898                            Op(String text, Fixity fixity); 
    19001899                            /** 
    19011900                             * pair of enclosing operators 
     
    21012100                 */ 
    21022101                BigFixity(); 
     2102                /** 
     2103                 * Fixity is not yet known 
     2104                 * This should not appear after parsing. 
     2105                 */ 
     2106                UnknownFixity(); 
    21032107            /* 
    21042108             * A Link in a ChainExpr is a pair of OpRef and the next Expr in the chain. 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r3111 r3120  
    660660 
    661661    public static _RewriteObjectExpr make_RewriteObjectExpr(ObjectExpr expr, 
    662             BATree<String, StaticParam> implicit_type_parameters) { 
     662                                                            BATree<String, StaticParam> implicit_type_parameters) { 
    663663        List<StaticArg> staticArgs = 
    664664            new ArrayList<StaticArg>(implicit_type_parameters.size()); 
     
    675675        } 
    676676        return new _RewriteObjectExpr(expr.getSpan(), false, 
    677                 expr.getExtendsClause(), expr.getDecls(), 
    678                 implicit_type_parameters, WellKnownNames.objectExprName(expr), 
    679                 stParams, staticArgs, 
    680                 Option.some(Collections.<Param>emptyList())); 
     677                                      expr.getExtendsClause(), expr.getDecls(), 
     678                                      implicit_type_parameters, WellKnownNames.objectExprName(expr), 
     679                                      stParams, staticArgs, 
     680                                      Option.some(Collections.<Param>emptyList())); 
    681681    } 
    682682 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java

    r3118 r3120  
    845845 
    846846    // All of these should go away, except for the gross overhead of allocating separate items. 
    847     private static Option<Fixity> infix = Option.<Fixity>some(new InFixity(makeSpan("singleton"))); 
    848     private static Option<Fixity> prefix = Option.<Fixity>some(new PreFixity(makeSpan("singleton"))); 
    849     private static Option<Fixity> postfix = Option.<Fixity>some(new PostFixity(makeSpan("singleton"))); 
    850     private static Option<Fixity> nofix = Option.<Fixity>some(new NoFixity(makeSpan("singleton"))); 
    851     private static Option<Fixity> multifix = Option.<Fixity>some(new MultiFixity(makeSpan("singleton"))); 
    852     private static Option<Fixity> enclosing = Option.<Fixity>some(new EnclosingFixity(makeSpan("singleton"))); 
    853     private static Option<Fixity> big = Option.<Fixity>some(new BigFixity(makeSpan("singleton"))); 
    854     private static Option<Fixity> unknownFix = Option.<Fixity>none(); 
     847    private static Fixity infix = new InFixity(makeSpan("singleton")); 
     848    private static Fixity prefix = new PreFixity(makeSpan("singleton")); 
     849    private static Fixity postfix = new PostFixity(makeSpan("singleton")); 
     850    private static Fixity nofix = new NoFixity(makeSpan("singleton")); 
     851    private static Fixity multifix = new MultiFixity(makeSpan("singleton")); 
     852    private static Fixity enclosing = new EnclosingFixity(makeSpan("singleton")); 
     853    private static Fixity big = new BigFixity(makeSpan("singleton")); 
     854    private static Fixity unknownFix = new UnknownFixity(makeSpan("singleton")); 
    855855 
    856856    public static Op makeOp(String name) { 
     
    862862    } 
    863863 
    864     public static Op makeOp(Span span, String name, Option<Fixity> fixity) { 
     864    public static Op makeOp(Span span, String name, Fixity fixity) { 
    865865        return new Op(span, PrecedenceMap.ONLY.canon(name), fixity); 
    866866    } 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/OprUtil.java

    r2690 r3120  
    2424import com.sun.fortress.nodes.Op; 
    2525import com.sun.fortress.nodes.OpName; 
     26import com.sun.fortress.nodes.UnknownFixity; 
    2627import com.sun.fortress.nodes.PostFixity; 
    2728import com.sun.fortress.nodes.PreFixity; 
     
    3839 
    3940    public static boolean isUnknownFixity(Op name) { 
    40         return name.getFixity().isNone(); 
     41        return name.getFixity() instanceof UnknownFixity; 
    4142    } 
    4243 
     
    4849 
    4950    private static boolean isPostfix(Op name) { 
    50         return name.getFixity().unwrap(null) instanceof PostFixity; 
     51        return name.getFixity() instanceof PostFixity; 
    5152    } 
    5253 
     
    132133    } 
    133134 
    134     public static String fixityDecorator(final Option<Fixity> of, final String s) { 
    135         if (of.isNone()) { 
    136             return s; 
    137         } 
    138         return of.unwrap().accept(new NodeAbstractVisitor<String>() { 
     135    public static String fixityDecorator(final Fixity of, final String s) { 
     136        return of.accept(new NodeAbstractVisitor<String>() { 
    139137//            @Override public String forInFixity(InFixity that) { 
    140138//                return "infix "+s; 
  • trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java

    r3115 r3120  
    631631            @Override public String forOp(final Op opThat) { 
    632632                final String oper = opThat.getText(); 
    633                 /* fixity shouldnt be null */ 
    634                 assert(opThat.getFixity().isSome()); 
    635                 return opThat.getFixity().unwrap().accept( new NodeDepthFirstVisitor<String>(){ 
     633                return opThat.getFixity().accept( new NodeDepthFirstVisitor<String>(){ 
    636634                    @Override public String forPreFixityOnly(PreFixity that) { 
    637635                        return "opr " + oper + sparams + inParentheses(vparams); 
     
    18161814            @Override public String forOp(final Op opThat) { 
    18171815                final String oper = canonicalOp( opThat.getText() ); 
    1818                 /* fixity shouldnt be null */ 
    1819                 assert(opThat.getFixity().isSome()); 
    1820                 return opThat.getFixity().unwrap().accept( new NodeDepthFirstVisitor<String>(){ 
     1816                return opThat.getFixity().accept( new NodeDepthFirstVisitor<String>(){ 
    18211817                    @Override public String forPreFixityOnly(PreFixity that) { 
    18221818                        assert( args_result.size() == 1 ); 
     
    27462742    @Override public String forOpOnly(Op that, 
    27472743                                      Option<String> api_result, 
    2748                                       Option<String> fixity_result) { 
     2744                                      String fixity_result) { 
    27492745        return canonicalOp( that.getText() ); 
    27502746    }