Changeset 3182

Show
Ignore:
Timestamp:
12/09/08 17:39:54 (12 months ago)
Author:
sukyoungryu
Message:

[ast refactoring] Merged nodes: Juxt, LooseJuxt?, and TightJuxt?

Location:
trunk/ProjectFortress
Files:
19 modified

Legend:

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

    r3178 r3182  
    914914                         * e.g.) myString.replace("foo", "few") 
    915915                         * e.g.) log log n 
    916                          */ 
    917                         abstract Juxt(FunctionalRef multiJuxt = ExprFactory.makeMultiJuxt(), 
    918                                       FunctionalRef infixJuxt = ExprFactory.makeInfixJuxt(), 
    919                                       List<Expr> exprs = new LinkedList<Expr>()); 
    920                             /** 
    921                              * juxtaposition with intervening whitespace 
    922                              * e.g.) 3 5 
    923                              */ 
    924                             LooseJuxt(); 
    925                             /** 
    926                              * juxtaposition without intervening whitespace. If fnApp is true, 
    927                              * then this juxtaposition should be type checked ONLY as a function 
    928                              * application. This should be the case for desugarings only. 
    929                              * e.g.) f(3+5) 
    930                              */ 
    931                             TightJuxt(boolean fnApp = false); 
     916                         * 
     917                         * loose juxtaposition 
     918                         * juxtaposition with intervening whitespace 
     919                         * e.g.) 3 5 
     920                         * 
     921                         * tight juxtaposition 
     922                         * juxtaposition without intervening whitespace. If fnApp is true, 
     923                         * then this juxtaposition should be type checked ONLY as a function 
     924                         * application. This should be the case for desugarings only. 
     925                         * e.g.) f(3+5) 
     926                         */ 
     927                        Juxt(FunctionalRef multiJuxt = ExprFactory.makeMultiJuxt(), 
     928                             FunctionalRef infixJuxt = ExprFactory.makeInfixJuxt(), 
     929                             List<Expr> exprs = new LinkedList<Expr>(), 
     930                             boolean fnApp, boolean tight) implements OutAfterTypeChecking; 
    932931                        /** 
    933932                         * functional application 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DottedMethodRewriteVisitor.java

    r3156 r3182  
    2727import com.sun.fortress.nodes.Expr; 
    2828import com.sun.fortress.nodes.FnRef; 
    29 import com.sun.fortress.nodes.LooseJuxt; 
     29import com.sun.fortress.nodes.Juxt; 
    3030import com.sun.fortress.nodes.MethodInvocation; 
    3131import com.sun.fortress.nodes.Node; 
    3232import com.sun.fortress.nodes.NodeUpdateVisitor; 
    3333import com.sun.fortress.nodes.ObjectDecl; 
    34 import com.sun.fortress.nodes.TightJuxt; 
    3534import com.sun.fortress.nodes.VarRef; 
    3635import com.sun.fortress.nodes._RewriteFnApp; 
     
    5958 
    6059    @Override 
    61     public Node forLooseJuxt(LooseJuxt that) { 
     60    public Node forJuxt(Juxt that) { 
    6261        // FIXME: Not sure if I really need to recur on other things 
    6362        List<Expr> exprs_result = recurOnListOfExpr(that.getExprs()); 
    64  
    6563        Expr first = exprs_result.get(0); 
    6664        if(first instanceof FnRef && methodRefs.contains(first)) { 
    6765            FnRef fnRef = (FnRef) first; 
    68             MethodInvocation mi = makeMethodInvocationFrom( 
    69                     fnRef, exprs_result.subList(1, exprs_result.size()) ); 
     66            MethodInvocation mi = makeMethodInvocationFrom(fnRef, exprs_result.subList(1, exprs_result.size()) ); 
    7067            exprs_result = new LinkedList<Expr>(); 
    7168            exprs_result.add(mi); 
    7269        } 
    73  
    74         return forLooseJuxtOnly(that, that.getExprType(), that.getMultiJuxt(), 
    75                                 that.getInfixJuxt(), exprs_result); 
     70        return forJuxtOnly(that, 
     71                          that.getExprType(), that.getMultiJuxt(), 
     72                           that.getInfixJuxt(), exprs_result); 
    7673    } 
    77  
    78  
    79     public Node forTightJuxt(TightJuxt that) { 
    80         // FIXME: Not sure if I really need to recur on other things 
    81         List<Expr> exprs_result = recurOnListOfExpr(that.getExprs()); 
    82  
    83         Expr first = exprs_result.get(0); 
    84         if(first instanceof FnRef && methodRefs.contains(first)) { 
    85             FnRef fnRef = (FnRef) first; 
    86             MethodInvocation mi = makeMethodInvocationFrom( 
    87                     fnRef, exprs_result.subList(1, exprs_result.size()) ); 
    88             exprs_result = new LinkedList<Expr>(); 
    89             exprs_result.add(mi); 
    90         } 
    91  
    92         return forTightJuxtOnly(that, that.getExprType(), that.getMultiJuxt(), 
    93                                 that.getInfixJuxt(), exprs_result); 
    94     } 
    95  
    9674 
    9775    public Node for_RewriteFnApp(_RewriteFnApp that) { 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java

    r3176 r3182  
    408408                    Pair<Id,Type> exitFnInfo = exitFnParamMap.get(exitKey); 
    409409                    if(exitFnInfo != null) { 
    410                         List<Expr> exprs = new LinkedList<Expr>(); 
    411410                        Option<Expr> returnExpr = that.getReturnExpr(); 
    412  
    413411                        Id fnName = exitFnInfo.first(); 
    414412                        FnRef fnRef = ExprFactory.makeFnRef(fnName); 
    415                         exprs.add(fnRef); 
    416                         exprs.add( unwrapIfSomeElseAlternative(returnExpr, 
    417                                      ExprFactory.makeVoidLiteralExpr(span)) ); 
    418  
    419                         return ExprFactory.makeTightJuxt(span, false, exprs); 
     413                        Expr arg = unwrapIfSomeElseAlternative(returnExpr, 
     414                                                               ExprFactory.makeVoidLiteralExpr(span)); 
     415                        return ExprFactory.make_RewriteFnApp(fnRef, arg); 
    420416                    } else { 
    421417                        return that; 
     
    426422 
    427423        newObjectDecls.add(lifted); 
    428         TightJuxt callToLifted = makeCallToLiftedObj(lifted, that, freeNames); 
     424        Expr callToLifted = makeCallToLiftedObj(lifted, that, freeNames); 
    429425 
    430426        scopeStack.pop(); 
     
    435431 
    436432 
    437     private TightJuxt makeCallToLiftedObj(ObjectDecl lifted, 
    438                                           ObjectExpr objExpr, 
    439                                           FreeNameCollection freeNames) { 
     433    private Expr makeCallToLiftedObj(ObjectDecl lifted, 
     434                                      ObjectExpr objExpr, 
     435                                      FreeNameCollection freeNames) { 
    440436        Span span = objExpr.getSpan(); 
    441437        Id originalName = lifted.getName(); 
     
    460456        List<Expr> exprs = makeArgsForCallToLiftedObj(objExpr, 
    461457                                                      freeNames, enclosingSelf); 
    462         exprs.add(0, fnRef); 
    463  
    464         TightJuxt callToConstructor = 
    465             ExprFactory.makeTightJuxt(span, objExpr.isParenthesized(), exprs); 
    466  
    467         return callToConstructor; 
     458        Expr arg = ExprFactory.makeTuple(exprs); 
     459        return ExprFactory.make_RewriteFnApp(fnRef, arg); 
    468460    } 
    469461 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/PreDisambiguationDesugaringVisitor.java

    r3158 r3182  
    196196        body = visitGenerators(span, gens, body); 
    197197        Expr opexp = ExprFactory.makeOpExpr(span,op,staticArgs); 
    198         Expr res = new TightJuxt(span, false, 
    199                                  Useful.list(BIGOP_NAME, 
    200                                              ExprFactory.makeTuple(opexp,body))); 
     198        Expr res = ExprFactory.makeTightJuxt(span, false, 
     199                                             Useful.list(BIGOP_NAME, 
     200                                                         ExprFactory.makeTuple(opexp,body))); 
    201201        return (Expr)recur(res); 
    202202    } 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/VarRefContainer.java

    r3163 r3182  
    3737import com.sun.fortress.nodes.StaticArg; 
    3838import com.sun.fortress.nodes.StaticParam; 
    39 import com.sun.fortress.nodes.TightJuxt; 
    4039import com.sun.fortress.nodes.TraitTypeWhere; 
    4140import com.sun.fortress.nodes.Type; 
     
    155154    } 
    156155 
    157     private TightJuxt makeCallToContainerObj() { 
     156    private Expr makeCallToContainerObj() { 
    158157        List<IdOrOp> fns = new LinkedList<IdOrOp>(); 
    159158        Span origSpan = origDeclNode.getSpan(); 
     
    163162                                                   containerDeclId(), fns, Collections.<StaticArg>emptyList() ); 
    164163 
    165         List<Expr> exprs = new LinkedList<Expr>(); 
    166         exprs.add(fnRefToDecl); 
    167         exprs.add(origVar); 
    168  
    169         return( ExprFactory.makeTightJuxt(origSpan, false, exprs) ); 
     164        return( ExprFactory.make_RewriteFnApp(fnRefToDecl, origVar) ); 
    170165    } 
    171166 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java

    r3176 r3182  
    29902990 
    29912991        @Override 
    2992         public TypeCheckerResult forLooseJuxtOnly(LooseJuxt that, Option<TypeCheckerResult> exprType_result, 
    2993                                                   TypeCheckerResult multiJuxt_result, 
    2994                                                   TypeCheckerResult infixJuxt_result, 
    2995                                                   List<TypeCheckerResult> exprs_result) { 
    2996             // The implementation of this method is very similar to tight juxt except 
    2997             // the ordering of association is different. 
    2998             // Notice also that tightJuxt has to be recursive, but loose juxt is not, due to specification. 
    2999  
    3000             // Did any subexpressions fail to typecheck? 
    3001             for( TypeCheckerResult r : exprs_result ) { 
    3002                 if( r.type().isNone()) 
    3003                     return TypeCheckerResult.compose(that, subtypeChecker, exprs_result); 
    3004             } 
    3005  
    3006             if( that.getExprs().size() != exprs_result.size() ) { 
    3007                 bug("Number of types don't match number of sub-expressions"); 
    3008             } 
    3009             // Specification describes chunks, which are elements group together. Chunking process goes first. 
    3010             List<Pair<TypeCheckerResult,Expr>> checked_chunks = new LinkedList<Pair<TypeCheckerResult,Expr>>(); 
    3011             { 
    3012                 List<Pair<TypeCheckerResult,Expr>> cur_chunk = new LinkedList<Pair<TypeCheckerResult,Expr>>(); 
    3013                 Iterator<Expr> expr_iter = that.getExprs().iterator(); 
    3014                 boolean seen_non_fn = false; 
    3015                 // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed 
    3016                 // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of 
    3017                 // functions followed by some number (possibly zero) of non-functions. 
     2992        public TypeCheckerResult forJuxt(Juxt that) { 
     2993            if ( that.isTight() ) { 
     2994                // Just create a MathPrimary 
     2995                Expr front = IterUtil.first(that.getExprs()); 
     2996 
     2997                // If this juxt is actually a fn app, then rewrite to a fn app. 
     2998                if (that.isFnApp()) { 
     2999                    // Make sure it is just two exprs. 
     3000                    if (that.getExprs().size() != 2) { 
     3001                        bug(String.format("TightJuxt denoted as function application but has %d (!= 2) exprs.", 
     3002                                          that.getExprs().size())); 
     3003                    } 
     3004                    Expr arg = that.getExprs().get(1); 
     3005                    _RewriteFnApp fnApp = new _RewriteFnApp(new Span(front.getSpan(), arg.getSpan()), 
     3006                                                            front, arg); 
     3007 
     3008                    // Simulate a TypeCheckerResult for the front, giving it a fresh arrow type. 
     3009                    Type freshArrow = NodeFactory.makeArrowType(new Span(), 
     3010                                                                NodeFactory.make_InferenceVarType(that.getSpan()), 
     3011                                                                NodeFactory.make_InferenceVarType(that.getSpan())); 
     3012                    TypeCheckerResult front_result = new TypeCheckerResult(front, freshArrow); 
     3013 
     3014                    // Type check the other nodes and recur on the fn app. 
     3015                    Option<TypeCheckerResult> exprType_result = this.recurOnOptionOfType(that.getExprType()); 
     3016                    TypeCheckerResult arg_result = arg.accept(this); 
     3017                    TypeCheckerResult fnApp_result = this.for_RewriteFnAppOnly(fnApp, 
     3018                                                                               exprType_result, 
     3019                                                                               front_result, 
     3020                                                                               arg_result); 
     3021                    return TypeCheckerResult.compose(that, 
     3022                                                     fnApp_result.type(), 
     3023                                                     subtypeChecker, 
     3024                                                     fnApp_result); 
     3025                } 
     3026 
     3027                Iterable<Expr> rest = IterUtil.skipFirst(that.getExprs()); 
     3028                List<MathItem> items = CollectUtil.makeList(IterUtil.map(rest, new Lambda<Expr,MathItem>(){ 
     3029                            public MathItem value(Expr arg0) { 
     3030                                if( arg0.isParenthesized() || arg0 instanceof TupleExpr || arg0 instanceof VoidLiteralExpr) 
     3031                                    return new ParenthesisDelimitedMI(arg0.getSpan(),arg0); 
     3032                                else 
     3033                                    return new NonParenthesisDelimitedMI(arg0.getSpan(),arg0); 
     3034                            }})); 
     3035                MathPrimary new_primary = new MathPrimary(that.getSpan(), 
     3036                                                          that.isParenthesized(), 
     3037                                                          that.getMultiJuxt(), 
     3038                                                          that.getInfixJuxt(), 
     3039                                                          front,items); 
     3040                return new_primary.accept(this); 
     3041            } else 
     3042                return super.forJuxt(that); 
     3043        } 
     3044 
     3045        @Override 
     3046        public TypeCheckerResult forJuxtOnly(Juxt that, Option<TypeCheckerResult> exprType_result, 
     3047                                             TypeCheckerResult multiJuxt_result, 
     3048                                             TypeCheckerResult infixJuxt_result, 
     3049                                             List<TypeCheckerResult> exprs_result) { 
     3050            if (! that.isTight() ) { 
     3051                // The implementation of this method is very similar to tight juxt except 
     3052                // the ordering of association is different. 
     3053                // Notice also that tightJuxt has to be recursive, but loose juxt is not, due to specification. 
     3054 
     3055                // Did any subexpressions fail to typecheck? 
    30183056                for( TypeCheckerResult r : exprs_result ) { 
    3019                     boolean is_arrow = TypesUtil.isArrows(r.type().unwrap()); 
    3020                     if( is_arrow && seen_non_fn ) { 
    3021                         // finished last chunk 
    3022                         Pair<TypeCheckerResult,Expr> checked_chunk = this.checkChunk(cur_chunk, that.getInfixJuxt()); 
    3023                         checked_chunks.add(checked_chunk); 
    3024                         cur_chunk.clear(); 
    3025                         seen_non_fn = false; 
     3057                    if( r.type().isNone()) 
     3058                        return TypeCheckerResult.compose(that, subtypeChecker, exprs_result); 
     3059                } 
     3060 
     3061                if( that.getExprs().size() != exprs_result.size() ) { 
     3062                    bug("Number of types don't match number of sub-expressions"); 
     3063                } 
     3064                // Specification describes chunks, which are elements group together. Chunking process goes first. 
     3065                List<Pair<TypeCheckerResult,Expr>> checked_chunks = new LinkedList<Pair<TypeCheckerResult,Expr>>(); 
     3066                { 
     3067                    List<Pair<TypeCheckerResult,Expr>> cur_chunk = new LinkedList<Pair<TypeCheckerResult,Expr>>(); 
     3068                    Iterator<Expr> expr_iter = that.getExprs().iterator(); 
     3069                    boolean seen_non_fn = false; 
     3070                    // First the loose juxtaposition is broken into nonempty chunks; wherever there is a non-function element followed 
     3071                    // by a function element, the latter begins a new chunk. Thus a chunk consists of some number (possibly zero) of 
     3072                    // functions followed by some number (possibly zero) of non-functions. 
     3073                    for( TypeCheckerResult r : exprs_result ) { 
     3074                        boolean is_arrow = TypesUtil.isArrows(r.type().unwrap()); 
     3075                        if( is_arrow && seen_non_fn ) { 
     3076                            // finished last chunk 
     3077                            Pair<TypeCheckerResult,Expr> checked_chunk = this.checkChunk(cur_chunk, that.getInfixJuxt()); 
     3078                            checked_chunks.add(checked_chunk); 
     3079                            cur_chunk.clear(); 
     3080                            seen_non_fn = false; 
     3081                        } 
     3082                        if( is_arrow ){ 
     3083                            cur_chunk.add(Pair.make(r, expr_iter.next())); 
     3084                        } 
     3085                        else { 
     3086                            seen_non_fn = true; 
     3087                            cur_chunk.add(Pair.make(r, expr_iter.next())); 
     3088                        } 
    30263089                    } 
    3027                     if( is_arrow ){ 
    3028                         cur_chunk.add(Pair.make(r, expr_iter.next())); 
    3029                     } 
    3030                     else { 
    3031                         seen_non_fn = true; 
    3032                         cur_chunk.add(Pair.make(r, expr_iter.next())); 
     3090                    // Last chunk needs to be checked, if there is one 
     3091                    if( !cur_chunk.isEmpty() ) { 
     3092                        checked_chunks.add(checkChunk(cur_chunk, that.getInfixJuxt())); 
    30333093                    } 
    30343094                } 
    3035                 // Last chunk needs to be checked, if there is one 
    3036                 if( !cur_chunk.isEmpty() ) { 
    3037                     checked_chunks.add(checkChunk(cur_chunk, that.getInfixJuxt())); 
     3095                // After chunking 
     3096                List<Expr> new_juxt_exprs = CollectUtil.makeList(IterUtil.pairSeconds(checked_chunks)); 
     3097                List<TypeCheckerResult> new_juxt_results = CollectUtil.makeList(IterUtil.pairFirsts(checked_chunks)); 
     3098 
     3099                if( checked_chunks.size() == 1 ) { 
     3100                    Expr expr = IterUtil.first(new_juxt_exprs); 
     3101                    TypeCheckerResult expr_result = expr.accept(this); // Is it bad to re-typecheck all args? 
     3102                    return TypeCheckerResult.compose(expr_result.ast(), expr_result.type(), subtypeChecker, expr_result, 
     3103                                                     TypeCheckerResult.compose(expr_result.ast(), subtypeChecker, new_juxt_results)); 
    30383104                } 
     3105                // (1) If any element that remains has type String, then it is a static error if any two adjacent elements are not of type String. 
     3106                // TODO: Separate pass? 
     3107                // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply: 
     3108                OpExpr multi_op_expr = new OpExpr(that.getSpan(), that.getMultiJuxt(), new_juxt_exprs); 
     3109                TypeCheckerResult multi_op_result = multi_op_expr.accept(this); 
     3110                if( multi_op_result.type().isSome() ) { 
     3111                    return TypeCheckerResult.compose(multi_op_result.ast(), multi_op_result.type(), subtypeChecker, 
     3112                                                     TypeCheckerResult.compose(multi_op_result.ast(), subtypeChecker, new_juxt_results)); 
     3113                } 
     3114                // if an applicable method cannot be found for the entire expression, then it is left-associated. 
     3115                Iterator<Expr> expr_iter = new_juxt_exprs.iterator(); 
     3116                Expr expr_1 = expr_iter.next(); // the fact that >= two items are here is guaranteed from above. 
     3117                Expr expr_2 = expr_iter.next(); 
     3118                OpExpr cur_op_expr = new OpExpr(new Span(expr_1.getSpan(),expr_2.getSpan()), that.getInfixJuxt(), Useful.list(expr_1,expr_2)); 
     3119                while( expr_iter.hasNext() ) { 
     3120                    Expr next_expr = expr_iter.next(); 
     3121                    cur_op_expr = new OpExpr(new Span(cur_op_expr.getSpan(),next_expr.getSpan()), that.getInfixJuxt(), Useful.list(cur_op_expr, next_expr)); 
     3122                } 
     3123                // typecheck this result instead 
     3124                TypeCheckerResult op_expr_result = cur_op_expr.accept(this); // Is it bad to re-typecheck all args? 
     3125                return TypeCheckerResult.compose(op_expr_result.ast(), op_expr_result.type(), subtypeChecker, op_expr_result, 
     3126                                                 TypeCheckerResult.compose(op_expr_result.ast(), subtypeChecker, new_juxt_results)); 
     3127            } else { 
     3128                return super.forJuxtOnly(that, exprType_result, 
     3129                                         multiJuxt_result, infixJuxt_result, 
     3130                                         exprs_result); 
    30393131            } 
    3040             // After chunking 
    3041             List<Expr> new_juxt_exprs = CollectUtil.makeList(IterUtil.pairSeconds(checked_chunks)); 
    3042             List<TypeCheckerResult> new_juxt_results = CollectUtil.makeList(IterUtil.pairFirsts(checked_chunks)); 
    3043  
    3044             if( checked_chunks.size() == 1 ) { 
    3045                 Expr expr = IterUtil.first(new_juxt_exprs); 
    3046                 TypeCheckerResult expr_result = expr.accept(this); // Is it bad to re-typecheck all args? 
    3047                 return TypeCheckerResult.compose(expr_result.ast(), expr_result.type(), subtypeChecker, expr_result, 
    3048                                                  TypeCheckerResult.compose(expr_result.ast(), subtypeChecker, new_juxt_results)); 
    3049             } 
    3050             // (1) If any element that remains has type String, then it is a static error if any two adjacent elements are not of type String. 
    3051             // TODO: Separate pass? 
    3052             // (2) Treat the sequence that remains as a multifix application of the juxtaposition operator. The rules for multifix operators then apply: 
    3053             OpExpr multi_op_expr = new OpExpr(that.getSpan(), that.getMultiJuxt(), new_juxt_exprs); 
    3054             TypeCheckerResult multi_op_result = multi_op_expr.accept(this); 
    3055             if( multi_op_result.type().isSome() ) { 
    3056                 return TypeCheckerResult.compose(multi_op_result.ast(), multi_op_result.type(), subtypeChecker, 
    3057                                                  TypeCheckerResult.compose(multi_op_result.ast(), subtypeChecker, new_juxt_results)); 
    3058             } 
    3059             // if an applicable method cannot be found for the entire expression, then it is left-associated. 
    3060             Iterator<Expr> expr_iter = new_juxt_exprs.iterator(); 
    3061             Expr expr_1 = expr_iter.next(); // the fact that >= two items are here is guaranteed from above. 
    3062             Expr expr_2 = expr_iter.next(); 
    3063             OpExpr cur_op_expr = new OpExpr(new Span(expr_1.getSpan(),expr_2.getSpan()), that.getInfixJuxt(), Useful.list(expr_1,expr_2)); 
    3064             while( expr_iter.hasNext() ) { 
    3065                 Expr next_expr = expr_iter.next(); 
    3066                 cur_op_expr = new OpExpr(new Span(cur_op_expr.getSpan(),next_expr.getSpan()), that.getInfixJuxt(), Useful.list(cur_op_expr, next_expr)); 
    3067             } 
    3068             // typecheck this result instead 
    3069             TypeCheckerResult op_expr_result = cur_op_expr.accept(this); // Is it bad to re-typecheck all args? 
    3070             return TypeCheckerResult.compose(op_expr_result.ast(), op_expr_result.type(), subtypeChecker, op_expr_result, 
    3071                                              TypeCheckerResult.compose(op_expr_result.ast(), subtypeChecker, new_juxt_results)); 
    3072         } 
     3132        } 
    30733133 
    30743134        // Math primary, which is the more general case, is going to be called for both TightJuxt and MathPrimary 
     
    38873947 
    38883948        @Override 
    3889         public TypeCheckerResult forTightJuxt(TightJuxt that) { 
    3890             // Just create a MathPrimary 
    3891             Expr front = IterUtil.first(that.getExprs()); 
    3892  
    3893             // If this juxt is actually a fn app, then rewrite to a fn app. 
    3894             if (that.isFnApp()) { 
    3895                 // Make sure it is just two exprs. 
    3896                 if (that.getExprs().size() != 2) { 
    3897                     bug(String.format("TightJuxt denoted as function application but has %d (!= 2) exprs.", that.getExprs().size())); 
    3898                 } 
    3899                 Expr arg = that.getExprs().get(1); 
    3900                 _RewriteFnApp fnApp = new _RewriteFnApp(new Span(front.getSpan(), arg.getSpan()), 
    3901                                                         front, arg); 
    3902  
    3903                 // Simulate a TypeCheckerResult for the front, giving it a fresh arrow type. 
    3904                 Type freshArrow = NodeFactory.makeArrowType(new Span(), 
    3905                                                             NodeFactory.make_InferenceVarType(that.getSpan()), 
    3906                                                             NodeFactory.make_InferenceVarType(that.getSpan())); 
    3907                 TypeCheckerResult front_result = new TypeCheckerResult(front, freshArrow); 
    3908  
    3909                 // Type check the other nodes and recur on the fn app. 
    3910                 Option<TypeCheckerResult> exprType_result = this.recurOnOptionOfType(that.getExprType()); 
    3911                 TypeCheckerResult arg_result = arg.accept(this); 
    3912                 TypeCheckerResult fnApp_result = this.for_RewriteFnAppOnly(fnApp, 
    3913                                                                            exprType_result, 
    3914                                                                            front_result, 
    3915                                                                            arg_result); 
    3916                 return TypeCheckerResult.compose(that, 
    3917                                                  fnApp_result.type(), 
    3918                                                  subtypeChecker, 
    3919                                                  fnApp_result); 
    3920             } 
    3921  
    3922             Iterable<Expr> rest = IterUtil.skipFirst(that.getExprs()); 
    3923             List<MathItem> items = CollectUtil.makeList(IterUtil.map(rest, new Lambda<Expr,MathItem>(){ 
    3924                         public MathItem value(Expr arg0) { 
    3925                             if( arg0.isParenthesized() || arg0 instanceof TupleExpr || arg0 instanceof VoidLiteralExpr) 
    3926                                 return new ParenthesisDelimitedMI(arg0.getSpan(),arg0); 
    3927                             else 
    3928                                 return new NonParenthesisDelimitedMI(arg0.getSpan(),arg0); 
    3929                         }})); 
    3930             MathPrimary new_primary = new MathPrimary(that.getSpan(), 
    3931                                                       that.isParenthesized(), 
    3932                                                       that.getMultiJuxt(), 
    3933                                                       that.getInfixJuxt(), 
    3934                                                       front,items); 
    3935                 return new_primary.accept(this); 
    3936         } 
    3937  
    3938         @Override 
    39393949        public TypeCheckerResult forTraitDecl(final TraitDecl that) { 
    39403950                TypeChecker checker_with_sparams = this.extend(that.getStaticParams(), that.getWhereClause()); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java

    r3171 r3182  
    505505                // Create a little expression to run the constructor. 
    506506                Expr init = ExprFactory.makeTightJuxt(x.getSpan(), 
    507                       ExprFactory.makeVarRef(x.getSpan(), WellKnownNames.obfuscatedSingletonConstructorName(fname, x), 0), 
    508                       ExprFactory.makeVoidLiteralExpr(x.getSpan())); 
     507                                                      ExprFactory.makeVarRef(x.getSpan(), WellKnownNames.obfuscatedSingletonConstructorName(fname, x), 0), 
     508                                                      ExprFactory.makeVoidLiteralExpr(x.getSpan())); 
    509509                FValue init_value = new LazilyEvaluatedCell(init, containing); 
    510510                putValue(bindInto, fname, init_value); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildNativeEnvironment.java

    r2969 r3182  
    160160 
    161161                // Create a little expression to run the constructor. 
    162                 Expr init = ExprFactory.makeTightJuxt(x.getSpan(), ExprFactory 
    163                         .makeVarRef(x.getSpan(), WellKnownNames.obfuscatedSingletonConstructorName(fname, x), 0), 
    164                         ExprFactory.makeVoidLiteralExpr(x.getSpan())); 
     162                Expr init = ExprFactory.makeTightJuxt(x.getSpan(), 
     163                                                      ExprFactory.makeVarRef(x.getSpan(), WellKnownNames.obfuscatedSingletonConstructorName(fname, x), 0), 
     164                                                      ExprFactory.makeVoidLiteralExpr(x.getSpan())); 
    165165                FValue init_value = new LazilyEvaluatedCell(init, containing); 
    166166                putValue(bindInto, fname, init_value); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java

    r3166 r3182  
    108108import com.sun.fortress.nodes.Lhs; 
    109109import com.sun.fortress.nodes.Link; 
    110 import com.sun.fortress.nodes.LooseJuxt; 
    111110import com.sun.fortress.nodes.MathItem; 
    112111import com.sun.fortress.nodes.MathPrimary; 
     
    127126import com.sun.fortress.nodes.SubscriptingMI; 
    128127import com.sun.fortress.nodes.Throw; 
    129 import com.sun.fortress.nodes.TightJuxt; 
    130128import com.sun.fortress.nodes.Try; 
    131129import com.sun.fortress.nodes.TryAtomicExpr; 
     
    906904    } 
    907905 
    908     public FValue forLooseJuxt(LooseJuxt x) { 
    909         return forJuxt(x); 
    910     } 
    911906    public FValue forJuxt(Juxt x) { 
     907        if ( x.isTight() ) { 
     908            /** Assumes wrapped FnRefs have ids fields of length 1. */ 
     909            return forTightJuxt(x, false); 
     910        } else 
     911            return forJuxtCommon(x); 
     912    } 
     913 
     914    public FValue forJuxtCommon(Juxt x) { 
    912915        // This is correct except for one minor detail: 
    913916        // We should treat names from another scope as if they were functions. 
     
    920923            bug(x,"empty juxtaposition"); 
    921924        try { 
    922             // times = e.getValue("juxtaposition"); 
     925                // times = e.getValue("juxtaposition"); 
    923926            times = e.getValueNull(x.getInfixJuxt()); 
    924927        } catch (FortressException fe) { 
     
    10961099                              "immediately followed by a non-expression " + 
    10971100                              "element."); 
    1098             } else if (arg instanceof TightJuxt) { // f(x)! 
    1099                 vargs = Useful.list(forTightJuxt((TightJuxt)arg, true)); 
     1101            } else if ( arg instanceof Juxt && 
     1102                        ((Juxt)arg).isTight() ) { // f(x)! 
     1103                vargs = Useful.list(forTightJuxt((Juxt)arg, true)); 
    11001104            } else if (arg instanceof MathPrimary) { // f(x)^y! y[a](x)! 
    11011105                vargs = Useful.list(forMathPrimary((MathPrimary)arg, true)); 
     
    13901394    } 
    13911395 
    1392     /** Assumes wrapped FnRefs have ids fields of length 1. */ 
    1393     public FValue forTightJuxt(TightJuxt x) { 
    1394         return forTightJuxt(x, false); 
    1395     } 
    1396  
    1397     private FValue forTightJuxt(TightJuxt x, boolean isPostfix) { 
     1396    private FValue forTightJuxt(Juxt x, boolean isPostfix) { 
    13981397        List<Expr> exprs = x.getExprs(); 
    13991398        if (exprs.size() == 0) 
     
    14531452            // Please fix it if you know how to do it.  -- Sukyoung 
    14541453            // Less of a hack now.  -- David 
    1455             return forJuxt(x); 
     1454            return forJuxtCommon(x); 
    14561455        } 
    14571456    } 
     
    14661465     * @throws ProgramError 
    14671466     */ 
    1468     private FValue juxtMemberSelection(TightJuxt x, FValue fobj, Id fld, 
     1467    private FValue juxtMemberSelection(Juxt x, FValue fobj, Id fld, 
    14691468                                       List<Expr> exprs) throws ProgramError { 
    14701469        List<FValue> args = evalInvocationArgs(exprs); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/glue/NativeApp.java

    r3123 r3182  
    3636import com.sun.fortress.nodes.Id; 
    3737import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 
     38import com.sun.fortress.nodes.Juxt; 
    3839import com.sun.fortress.nodes.MathItem; 
    3940import com.sun.fortress.nodes.MathPrimary; 
     
    4142import com.sun.fortress.nodes.StaticParam; 
    4243import com.sun.fortress.nodes.StringLiteralExpr; 
    43 import com.sun.fortress.nodes.TightJuxt; 
    4444import com.sun.fortress.nodes.Type; 
    4545import com.sun.fortress.nodes.VarRef; 
     
    153153        Expr fn; 
    154154        Expr arg; 
    155         if (body instanceof TightJuxt) { 
    156             List<Expr> juxts = ((TightJuxt)body).getExprs(); 
     155        if ( body instanceof Juxt && 
     156             ((Juxt)body).isTight() ) { 
     157            List<Expr> juxts = ((Juxt)body).getExprs(); 
    157158            if (juxts.size()!=2) return defn; 
    158159            fn = juxts.get(0); 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java

    r3176 r3182  
    9393import com.sun.fortress.nodes.StaticParam; 
    9494import com.sun.fortress.nodes.TestDecl; 
    95 import com.sun.fortress.nodes.TightJuxt; 
    9695import com.sun.fortress.nodes.BaseType; 
    9796import com.sun.fortress.nodes.TraitDecl; 
     
    775774    } 
    776775    @Override 
    777     public Node forTightJuxt(TightJuxt node) { 
    778         if (looksLikeMethodInvocation(node)) 
    779             return translateJuxtOfDotted(node); 
    780         else 
    781             return visitNode(node); 
     776    public Node forJuxt(Juxt node) { 
     777        if ( node.isTight() ) { 
     778            if (looksLikeMethodInvocation(node)) 
     779                return translateJuxtOfDotted(node); 
     780            else 
     781                return visitNode(node); 
     782        } else return visitNode(node); 
    782783    } 
    783784    @Override 
     
    10781079            args.add(bindsAndBody(g,w.getBody())); 
    10791080            Expr cond = 
    1080                 new TightJuxt(g.getSpan(), false, 
    1081                               Useful.list(Q_WHILECOND_NAME, 
    1082                                           ExprFactory.makeTuple(w.getSpan(),args))); 
     1081                ExprFactory.makeTightJuxt(g.getSpan(), 
     1082                                          Q_WHILECOND_NAME, 
     1083                                          ExprFactory.makeTuple(w.getSpan(),args)); 
    10831084            w = ExprFactory.makeWhile(w.getSpan(),cond); 
    10841085        } 
     
    11141115        List<Param> params = Collections.emptyList(); 
    11151116        FnExpr fnExpr = new FnExpr(sp, params, (Expr) rewrittenExpr); 
    1116         List<Expr> exprs = new ArrayList<Expr>(2); 
    1117         exprs.add(fn); 
    1118  
    1119         exprs.add(fnExpr); 
    1120  
    1121         TightJuxt juxt = new TightJuxt(s.getSpan(), false, exprs); 
    1122  
    1123         return visitNode(juxt); 
     1117 
     1118        return visitNode(ExprFactory.makeTightJuxt(s.getSpan(), fn, fnExpr)); 
    11241119    } 
    11251120 
     
    11911186            args.add(bindsAndBody(g,c.getBody())); 
    11921187            if (elsePart != null) args.add(thunk(elsePart)); 
    1193             return new TightJuxt(c.getSpan(), false, 
    1194                                  Useful.list(Q_COND_NAME, 
    1195                                              ExprFactory.makeTuple(c.getSpan(),args))); 
     1188            return ExprFactory.makeTightJuxt(c.getSpan(), 
     1189                                             Q_COND_NAME, 
     1190                                             ExprFactory.makeTuple(c.getSpan(),args)); 
    11961191        } 
    11971192        // if expr then body else elsePart end is preserved 
     
    12181213            Expr loopSel = ExprFactory.makeFieldRef(g.getSpan(), 
    12191214                                                    g.getInit(), LOOP_NAME); 
    1220             body = new TightJuxt(span, false, Useful.list(loopSel,loopBody)); 
     1215            body = ExprFactory.makeTightJuxt(span, loopSel,loopBody); 
    12211216        } 
    12221217        // System.out.println("Desugared to "+body.toStringVerbose()); 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/DesugarerUtil.java

    r3123 r3182  
    134134        if (i==0) { 
    135135            /* Single generator as body, with no generator clauses. */ 
    136             body = new TightJuxt(span, false, 
    137                              Useful.list(GENERATE_NAME, 
    138                                          ExprFactory.makeTuple(body,redVar,unitVar))); 
     136            body = ExprFactory.makeTightJuxt(span, 
     137                                             GENERATE_NAME, 
     138                                             ExprFactory.makeTuple(body,redVar,unitVar)); 
    139139        } else { 
    140140            List<GeneratorClause> squozenGens = 
     
    162162            // Wrap the body in parentheses (as a singleton tuple) so that it can be considered 
    163163            // as the argument in a function application (denoted by the true argument). 
    164             body = new TightJuxt(body.getSpan(), 
    165                                  false, 
    166                                  Useful.list(unitVar, body), 
    167                                  true); 
     164            body = ExprFactory.makeTightJuxt(body.getSpan(), 
     165                                             false, 
     166                                             Useful.list(unitVar, body), 
     167                                             true); 
    168168            for (i--; i>=0; i--) { 
    169169                body = oneGenerator(gens.get(i), redVar, body); 
     
    273273        Expr loopBody = bindsAndBody(g, body); 
    274274        Expr params = ExprFactory.makeTuple(g.getInit(), reduction, loopBody); 
    275         return new TightJuxt(g.getSpan(), false, 
    276                              Useful.list(GENERATE_NAME,params)); 
     275        return ExprFactory.makeTightJuxt(g.getSpan(), GENERATE_NAME, params); 
    277276    } 
    278277} 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r3164 r3182  
    426426    } 
    427427 
    428     public static TightJuxt makeTightJuxt(Span span, Expr first, Expr second) { 
    429         return new TightJuxt(span, false, Useful.list(first, second)); 
    430     } 
    431  
    432     public static TightJuxt makeTightJuxt(Span span, boolean isParenthesized, List<Expr> exprs) { 
    433         return new TightJuxt(span, isParenthesized, Useful.immutableTrimmedList(exprs)); 
    434     } 
    435  
    436     public static TightJuxt makeTightJuxt(Span span, List<Expr> exprs, Boolean isParenthesized, FunctionalRef infixJuxt, FunctionalRef multiJuxt){ 
    437      return new TightJuxt(span, isParenthesized, multiJuxt, infixJuxt ,Useful.immutableTrimmedList(exprs)); 
     428    public static Juxt makeLooseJuxt(Span span, boolean isParenthesized, List<Expr> exprs) { 
     429        return new Juxt(span, isParenthesized, Useful.immutableTrimmedList(exprs), 
     430                        false, false); 
     431    } 
     432 
     433    public static Juxt makeTightJuxt(Span span, Expr first, Expr second) { 
     434        return new Juxt(span, false, Option.<Type>none(), 
     435                        Useful.list(first, second), false, true); 
     436    } 
     437 
     438    public static Juxt makeTightJuxt(Span span, boolean isParenthesized, List<Expr> exprs) { 
     439        return new Juxt(span, isParenthesized, Useful.immutableTrimmedList(exprs), 
     440                        false, true); 
     441    } 
     442 
     443    public static Juxt makeTightJuxt(Span span, boolean isParenthesized, List<Expr> exprs, boolean isFnApp) { 
     444        return new Juxt(span, isParenthesized, Useful.immutableTrimmedList(exprs), 
     445                        isFnApp, true); 
     446    } 
     447 
     448    public static Juxt makeTightJuxt(Span span, List<Expr> exprs, 
     449                                     Boolean isParenthesized, 
     450                                     FunctionalRef infixJuxt, 
     451                                     FunctionalRef multiJuxt){ 
     452        return new Juxt(span, isParenthesized, multiJuxt, infixJuxt, 
     453                        Useful.immutableTrimmedList(exprs), 
     454                        false, true); 
    438455    } 
    439456 
     
    442459     * with new exprs. 
    443460     */ 
    444     public static TightJuxt makeTightJuxt(TightJuxt that, List<Expr> exprs) { 
    445      return new TightJuxt(that.getSpan(), that.isParenthesized(), 
    446                           that.getMultiJuxt(), that.getInfixJuxt(), Useful.immutableTrimmedList(exprs)); 
     461    public static Juxt makeTightJuxt(Juxt that, List<Expr> exprs) { 
     462     return new Juxt(that.getSpan(), that.isParenthesized(), 
     463                     that.getMultiJuxt(), that.getInfixJuxt(), 
     464                     Useful.immutableTrimmedList(exprs), 
     465                     that.isFnApp(), true); 
    447466    } 
    448467 
     
    895914                    e.getArg()); 
    896915        } 
    897         public Expr forLooseJuxt(LooseJuxt e) { 
    898             return new LooseJuxt(e.getSpan(), true, e.getExprs()); 
    899         } 
    900         public Expr forTightJuxt(TightJuxt e) { 
    901             return new TightJuxt(e.getSpan(), true, e.getExprs()); 
     916        public Expr forJuxt(Juxt e) { 
     917            return new Juxt(e.getSpan(), true, e.getExprType(), 
     918                            e.getMultiJuxt(), e.getInfixJuxt(), 
     919                            e.getExprs(), e.isFnApp(), e.isTight()); 
    902920        } 
    903921        public Expr forFnRef(FnRef e) { 
     
    9851003        if (mi instanceof ExprMI) { 
    9861004            Expr expr = ((ExprMI)mi).getExpr(); 
    987             return new TightJuxt(span, Useful.list(front, expr)); 
     1005            return makeTightJuxt(span, front, expr); 
    9881006        } else if (mi instanceof ExponentiationMI) { 
    9891007            ExponentiationMI expo = (ExponentiationMI)mi; 
     
    10381056    } 
    10391057 
    1040     public static TemplateGapLooseJuxt makeTemplateGapLooseJuxt(Span s, Id id, List<Id> params) { 
    1041         return new TemplateGapLooseJuxt(s, id, params); 
     1058    public static TemplateGapJuxt makeTemplateGapJuxt(Span s, Id id, List<Id> params) { 
     1059        return new TemplateGapJuxt(s, id, params); 
    10421060    } 
    10431061 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/Expression.rats

    r3146 r3182  
    502502          public Expr run(Expr base) { 
    503503              List<Expr> exprs = FortressUtil.mkList(base, a1); 
    504               return new TightJuxt(FortressUtil.spanTwo(base, a1), false, exprs); 
     504              return ExprFactory.makeTightJuxt(FortressUtil.spanTwo(base, a1), false, exprs); 
    505505          }}; 
    506506    }; 
  • trunk/ProjectFortress/src/com/sun/fortress/parser/templateparser/Gaps.rats

    r3079 r3182  
    5656     }; 
    5757 
    58 LooseJuxt LooseJuxtGap = 
     58Juxt LooseJuxtGap = 
    5959     <GAP> prefix "LooseJuxt" w a1:Id params:ParamList? w suffix 
    6060     { if (params == null) params = new LinkedList<Id>(); 
    61        yyValue = ExprFactory.makeTemplateGapLooseJuxt(createSpan(yyStart,yyCount), a1, params); 
     61       yyValue = ExprFactory.makeTemplateGapJuxt(createSpan(yyStart,yyCount), a1, params); 
    6262     }; 
    6363 
  • trunk/ProjectFortress/src/com/sun/fortress/parser_util/FortressUtil.java

    r3163 r3182  
    874874            exprs = exprs.reverse(); 
    875875            List<Expr> javaList = Useful.immutableTrimmedList(exprs); 
    876             return new TightJuxt(spanAll(javaList.toArray(new AbstractNode[0]), 
    877                                          javaList.size()), false, javaList); 
     876            return new Juxt(spanAll(javaList.toArray(new AbstractNode[0]), 
     877                                    javaList.size()), 
     878                            false, javaList, false, true); 
    878879        } 
    879880    } 
  • trunk/ProjectFortress/src/com/sun/fortress/parser_util/precedence_resolver/ASTUtil.java

    r3156 r3182  
    3232import com.sun.fortress.nodes.Expr; 
    3333import com.sun.fortress.nodes.Link; 
    34 import com.sun.fortress.nodes.LooseJuxt; 
    3534import com.sun.fortress.nodes.IdOrOp; 
    3635import com.sun.fortress.nodes.Op; 
     
    144143                } 
    145144            }); 
    146         return new LooseJuxt(spanAll(exprs), false, _exprs.toJavaList()); 
     145        return ExprFactory.makeLooseJuxt(spanAll(exprs), false, _exprs.toJavaList()); 
    147146    } 
    148147 
  • trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/EllipsesJUTest.java

    r3071 r3182  
    2222import com.sun.fortress.nodes.*; 
    2323import com.sun.fortress.nodes_util.NodeFactory; 
     24import com.sun.fortress.nodes_util.ExprFactory; 
    2425import com.sun.fortress.nodes_util.Span; 
    2526 
     
    3031 
    3132    static Span span = NodeFactory.makeSpan("EllipsesJUTest"); 
    32      
     33 
    3334    private <T> List<T> mkList( T... e ){ 
    3435        List<T> list = new ArrayList<T>(); 
     
    5455            List<Expr> exprs = new ArrayList<Expr>(); 
    5556            exprs.add( new _EllipsesExpr(new Span(), mkTemplate( "x" ) ) ); 
    56             original = new TightJuxt(new Span(), false, exprs);  
     57            original = ExprFactory.makeTightJuxt(new Span(), false, exprs); 
    5758            EllipsesEnvironment env = new EllipsesEnvironment(); 
    5859            env.add( NodeFactory.makeId( "x" ), 1, mkList(new StringLiteralExpr(span,  "hello" )) ); 
     
    6364            List<Expr> exprs = new ArrayList<Expr>(); 
    6465            exprs.add( new StringLiteralExpr(span,  "hello" ) ); 
    65             expected = new TightJuxt( new Span(), false, exprs ); 
     66            expected = ExprFactory.makeTightJuxt( new Span(), false, exprs ); 
    6667        } 
    6768 
     
    7677            List<Expr> exprs = new ArrayList<Expr>(); 
    7778            exprs.add( new _EllipsesExpr(new Span(), mkTemplate( "x" ) ) ); 
    78             original = new TightJuxt(new Span(), false, exprs);  
     79            original = ExprFactory.makeTightJuxt(new Span(), false, exprs); 
    7980            EllipsesEnvironment env = new EllipsesEnvironment(); 
    8081            env.add( NodeFactory.makeId( "x" ), 1, mkList(new StringLiteralExpr(span, "hello" ), new StringLiteralExpr(span, "goodbye" ) ) ); 
     
    8384 
    8485        { 
    85             List<Expr> exprs = new ArrayList<Expr>(); 
    86             exprs.add( new StringLiteralExpr(span, "hello" ) ); 
    87             exprs.add( new StringLiteralExpr(span, "goodbye" ) ); 
    88             expected = new TightJuxt( new Span(), false, exprs ); 
     86            expected = ExprFactory.makeTightJuxt( new Span(), 
     87                                                  new StringLiteralExpr(span, "hello" ), 
     88                                                  new StringLiteralExpr(span, "goodbye" ) ); 
    8989        } 
    9090 
     
    104104            List<Expr> exprs = new ArrayList<Expr>(); 
    105105            exprs.add( new _EllipsesExpr( new Span(), extra ) ); 
    106             original = new TightJuxt(new Span(), false, exprs ); 
     106            original = ExprFactory.makeTightJuxt(new Span(), false, exprs ); 
    107107            EllipsesEnvironment env = new EllipsesEnvironment(); 
    108108            env.add( NodeFactory.makeId( "x" ), 1, mkList( new StringLiteralExpr(span, "a"), new StringLiteralExpr(span, "b" ) ) ); 
     
    116116            exprs.add( new Block(span,  mkExprList( new StringLiteralExpr(span, "hi" ), 
    117117                                              new StringLiteralExpr(span, "b" ) ) ) ); 
    118             expected = new TightJuxt(new Span(), false, exprs ); 
     118            expected = ExprFactory.makeTightJuxt(new Span(), false, exprs ); 
    119119        } 
    120120 
     
    131131            List<Expr> exprs = new ArrayList<Expr>(); 
    132132            exprs.add( new StringLiteralExpr(span, "bar" ) ); 
    133             exprs.add( new _EllipsesExpr(new Span(), new TightJuxt(new Span(), false, extra ) ) ); 
    134             original = new TightJuxt(new Span(), false, exprs ); 
     133            exprs.add( new _EllipsesExpr(new Span(), ExprFactory.makeTightJuxt(new Span(), false, extra ) ) ); 
     134            original = ExprFactory.makeTightJuxt(new Span(), false, exprs ); 
    135135            EllipsesEnvironment env = new EllipsesEnvironment(); 
    136136            env.add( NodeFactory.makeId( "i" ), 0, new StringLiteralExpr(span, "a" ) ); 
     
    142142 
    143143        { 
    144             expected = new TightJuxt(new Span(), false, 
     144            expected = ExprFactory.makeTightJuxt(new Span(), false, 
    145145                                     mkExprList( new StringLiteralExpr(span, "bar" ), 
    146                                                  new TightJuxt(new Span(), false, 
    147                                                                mkExprList( new StringLiteralExpr(span, "a"), 
    148                                                                            new StringLiteralExpr(span, "1"))), 
    149                                                  new TightJuxt(new Span(), false, 
    150                                                                mkExprList( new StringLiteralExpr(span, "a"), 
    151                                                                            new StringLiteralExpr(span, "2"))), 
    152                                                  new TightJuxt(new Span(), false, 
    153                                                                mkExprList( new StringLiteralExpr(span, "a"), 
    154                                                                            new StringLiteralExpr(span, "3"))))); 
     146                                                 ExprFactory.makeTightJuxt(new Span(), 
     147                                                                           new StringLiteralExpr(span, "a"), 
     148                                                                           new StringLiteralExpr(span, "1")), 
     149                                                 ExprFactory.makeTightJuxt(new Span(), 
     150                                                                           new StringLiteralExpr(span, "a"), 
     151                                                                           new StringLiteralExpr(span, "2")), 
     152                                                 ExprFactory.makeTightJuxt(new Span(), 
     153                                                                           new StringLiteralExpr(span, "a"), 
     154                                                                           new StringLiteralExpr(span, "3")))); 
    155155        } 
    156156 
    157157        assertEquals( actual, expected ); 
    158158    } 
    159          
     159 
    160160} 
  • trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java

    r3176 r3182  
    17041704    } 
    17051705 
    1706     @Override public String forLooseJuxtOnly(LooseJuxt that, Option<String> exprType_result, 
    1707                                              String multiJuxt_result, 
    1708                                              String infixJuxt_result, 
    1709                                              List<String> exprs_result) { 
    1710         StringBuilder s = new StringBuilder(); 
    1711  
    1712         for ( String expr : exprs_result ){ 
    1713             s.append( expr ); 
    1714             s.append( " " ); 
    1715         } 
    1716  
    1717         return handleParen( s.toString(), 
    1718                             that.isParenthesized() ); 
    1719     } 
    1720  
    1721     @Override public String forTightJuxtOnly(TightJuxt that, Option<String> exprType_result, 
    1722                                              String multiJuxt_result, 
    1723                                              String infixJuxt_result, 
    1724                                              List<String> exprs_result) { 
    1725         StringBuilder s = new StringBuilder(); 
    1726  
    1727         if ( exprs_result.isEmpty() ) 
    1728             return bug(that, "A tight juxtaposition expression should have " + 
    1729                        "at least two subexpressions."); 
    1730         s.append(IterUtil.first(exprs_result)); 
    1731         for ( String expr : IterUtil.skipFirst(exprs_result) ){ 
    1732             s.append( inParentheses(expr) ); 
    1733         } 
    1734  
    1735         if ( that.isParenthesized() ) 
    1736             return "(" + s.toString() + ")"; 
    1737         else 
    1738             return s.toString(); 
     1706    @Override public String forJuxtOnly(Juxt that, Option<String> exprType_result, 
     1707                                        String multiJuxt_result, 
     1708                                        String infixJuxt_result, 
     1709                                        List<String> exprs_result) { 
     1710        StringBuilder s = new StringBuilder(); 
     1711 
     1712        if ( that.isTight() ) { 
     1713            if ( exprs_result.isEmpty() ) 
     1714                return bug(that, "A tight juxtaposition expression should have " + 
     1715                           "at least two subexpressions."); 
     1716            s.append(IterUtil.first(exprs_result)); 
     1717            for ( String expr : IterUtil.skipFirst(exprs_result) ){ 
     1718                s.append( inParentheses(expr) ); 
     1719            } 
     1720            if ( that.isParenthesized() ) 
     1721                return "(" + s.toString() + ")"; 
     1722            else 
     1723                return s.toString(); 
     1724        } else { 
     1725            for ( String expr : exprs_result ){ 
     1726                s.append( expr ); 
     1727                s.append( " " ); 
     1728            } 
     1729            return handleParen( s.toString(), 
     1730                                that.isParenthesized() ); 
     1731        } 
    17391732    } 
    17401733