Changeset 3092

Show
Ignore:
Timestamp:
11/24/08 12:05:37 (12 months ago)
Author:
dr2chase
Message:

[astgen] Reshuffled some node fields; added a foreign language fields to imports

Location:
trunk/ProjectFortress
Files:
10 modified

Legend:

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

    r3082 r3092  
    188188         * Import ::= import ImportedNames | import api AliasedAPINames 
    189189         */ 
    190         abstract Import(); 
     190        abstract Import(Option<String> foreignLanguage = Option.<String>none()); 
    191191            /** 
    192192             * ImportedNames ::= APIName . {...} (except SimpleNames)? 
     
    11271127                         */ 
    11281128                        FnRef(Id originalName, 
    1129                               List<Id> fns = Collections.<Id>singletonList(in_originalName), 
    1130                               List<StaticArg> staticArgs 
    1131                                   = Collections.<StaticArg>emptyList()); 
     1129                              List<Id> fns = Collections.<Id>singletonList(in_originalName)); 
    11321130                            /** 
    11331131                             * A list of FnRefs used for infering static arguments. Used only between the two 
     
    11441142                         */ 
    11451143                        OpRef(OpName originalName, 
    1146                               List<OpName> ops = Collections.<OpName>singletonList(in_originalName), 
    1147                               List<StaticArg> staticArgs 
    1148                                   = Collections.<StaticArg>emptyList()); 
     1144                              List<OpName> ops = Collections.<OpName>singletonList(in_originalName)); 
    11491145                            /** 
    11501146                             * Similar to _RewriteInstantiatedFnRefs, this node is used for inferring static 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/OverloadRewriteVisitor.java

    r3071 r3092  
    3636 
    3737    @Override 
    38     public Node forFnRefOnly(FnRef that, Option<Type> exprType_result, Id originalName, List<Id> fns, 
    39             List<StaticArg> staticArgs) { 
     38    public Node forFnRefOnly(FnRef that, Option<Type> exprType_result, 
     39            List<StaticArg> staticArgs, Id originalName, List<Id> fns) { 
    4040        if (fns.size() > 1) { 
    4141            Collections.<Id>sort(fns, NodeComparator.idComparer); 
     
    5757            fns = Collections.unmodifiableList(Collections.singletonList(overloadingId)); 
    5858        } 
    59         return super.forFnRefOnly(that, exprType_result , originalName, fns, staticArgs); 
     59        return super.forFnRefOnly(that, exprType_result, staticArgs , originalName, fns); 
    6060    } 
    6161 
    6262 
    6363    @Override 
    64     public Node forOpRefOnly(OpRef that, Option<Type> exprType_result, OpName originalName, List<OpName> ops, 
    65             List<StaticArg> staticArgs) { 
     64    public Node forOpRefOnly(OpRef that, Option<Type> exprType_result, 
     65            List<StaticArg> staticArgs, OpName originalName, List<OpName> ops) { 
    6666        if (ops.size() > 1) { 
    6767            Collections.<OpName>sort(ops, NodeComparator.opNameComparer); 
     
    8383            ops = Collections.unmodifiableList(Collections.singletonList(overloadingOpName)); 
    8484        } 
    85         return super.forOpRefOnly(that, exprType_result, originalName, ops, staticArgs); 
     85        return super.forOpRefOnly(that, exprType_result, staticArgs, originalName, ops); 
    8686    } 
    8787 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java

    r3082 r3092  
    524524    @Override 
    525525    public Node forFnRefOnly(FnRef that, Option<Type> exprType_result, 
    526                              Id fnResult, List<Id> fns_result, 
    527                              List<StaticArg> staticArgs_result) { 
     526                             List<StaticArg> staticArgs_result, 
     527                             Id fnResult, List<Id> fns_result) { 
    528528        // After disambiguation, the Id in a FnRef should have an empty API. 
    529529        assert(fnResult.getApi().isNone()); 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java

    r3082 r3092  
    13071307        } 
    13081308 
    1309         OpRef result = new OpRef(that.getSpan(),that.isParenthesized(),op_name,CollectUtil.makeList(ops),that.getStaticArgs()); 
     1309        OpRef result = new OpRef(that.getSpan(),that.isParenthesized(),that.getStaticArgs(),op_name,CollectUtil.makeList(ops)); 
    13101310        return Option.<OpRef>some(result); 
    13111311    } 
     
    13371337        if ( result_.isNone() ) { 
    13381338            // Make sure to populate the 'originalName' field. 
    1339             return new OpRef(that.getSpan(),that.isParenthesized(),IterUtil.first(that.getOps()), that.getOps(),that.getStaticArgs()); 
     1339            return new OpRef(that.getSpan(),that.isParenthesized(),that.getStaticArgs(),IterUtil.first(that.getOps()), that.getOps()); 
    13401340        } 
    13411341        else { 
  • trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java

    r3082 r3092  
    24422442        @Override 
    24432443        public TypeCheckerResult forFnRefOnly(final FnRef that, Option<TypeCheckerResult> exprType_result, 
     2444                List<TypeCheckerResult> staticArgs_result, 
    24442445                        TypeCheckerResult originalName_result, 
    2445                         List<TypeCheckerResult> fns_result, 
    2446                         List<TypeCheckerResult> staticArgs_result) { 
     2446                        List<TypeCheckerResult> fns_result) { 
    24472447 
    24482448                // Could we give a type to each of our fns? 
     
    25022502                                                        that.isParenthesized(), 
    25032503                                                        some(new_type), 
     2504                                                        new_args, 
    25042505                                                        that.getLexicalDepth(), 
    25052506                                                        that.getOriginalName(), 
    2506                                                         that.getFns(), 
    2507                                                         new_args); 
     2507                                                        that.getFns()); 
    25082508                                        fn_overloadings.add(new _RewriteFnRefOverloading(that.getSpan(), fn_ref, new_type)); 
    25092509                                        arrow_types.add(new_type); 
     
    25192519                                                        that.isParenthesized(), 
    25202520                                                        type, 
    2521                                                         that.getLexicalDepth(), 
    2522                                                         that.getOriginalName(), 
    2523                                                         that.getFns(), 
    2524                                                         that.getStaticArgs(), 
    2525                                                         fn_overloadings); 
     2521                                                         that.getStaticArgs(), 
     2522                                                         that.getLexicalDepth(), 
     2523                                                         that.getOriginalName(), 
     2524                                                         that.getFns(), 
     2525                                                         fn_overloadings); 
    25262526                } 
    25272527                else { 
     
    25512551                                                        that.isParenthesized(), 
    25522552                                                        type, 
     2553                                                        that.getStaticArgs(), 
    25532554                                                        that.getLexicalDepth(), 
    25542555                                                        that.getOriginalName(), 
    2555                                                         that.getFns(), 
    2556                                                         that.getStaticArgs()); 
     2556                                                        that.getFns()); 
    25572557                } 
    25582558 
     
    36563656        @Override 
    36573657        public TypeCheckerResult forOpRefOnly(final OpRef that, Option<TypeCheckerResult> exprType_result, 
     3658                List<TypeCheckerResult> staticArgs_result, 
    36583659                        TypeCheckerResult originalName_result, 
    3659                         List<TypeCheckerResult> ops_result, 
    3660                         List<TypeCheckerResult> staticArgs_result) { 
     3660                        List<TypeCheckerResult> ops_result) { 
    36613661                // Did all ops typecheck? 
    36623662                for( TypeCheckerResult o_r : ops_result ) { 
     
    37143714                                        OpRef new_op_ref = new OpRef(that.getSpan(), 
    37153715                                                        that.isParenthesized(), 
     3716                                                        new_args, 
    37163717                                                        that.getLexicalDepth(), 
    37173718                                                        that.getOriginalName(), 
    3718                                                         that.getOps(), 
    3719                                                         new_args); 
     3719                                                        that.getOps()); 
    37203720 
    37213721                                        overloadings.add(new _RewriteOpRefOverloading(that.getSpan(), new_op_ref, new_type)); 
     
    37303730                                                        that.isParenthesized(), 
    37313731                                                        type, 
     3732                                                        that.getStaticArgs(), 
    37323733                                                        that.getLexicalDepth(), 
    37333734                                                        that.getOriginalName(), 
    37343735                                                        that.getOps(), 
    3735                                                         that.getStaticArgs(), 
    37363736                                                        overloadings); 
    37373737                                        constraints = accumulated_constraints; 
     
    37573757                                                        that.isParenthesized(), 
    37583758                                                        type, 
     3759                                                        (List<StaticArg>)TypeCheckerResult.astFromResults(staticArgs_result), 
    37593760                                                        that.getLexicalDepth(), 
    37603761                                                        that.getOriginalName(), 
    3761                                                         (List<OpName>)TypeCheckerResult.astFromResults(ops_result), 
    3762                                                         (List<StaticArg>)TypeCheckerResult.astFromResults(staticArgs_result)); 
     3762                                                        (List<OpName>)TypeCheckerResult.astFromResults(ops_result)); 
    37633763                } 
    37643764 
  • trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/OprInstantiaterVisitor.java

    r3089 r3092  
    7575         
    7676        if (args != n_args || originalName != n_originalName || ops != n_ops || type != n_type) { 
    77             return new OpRef(op.getSpan(), op.isParenthesized(), Option.wrap(n_type), Environment.TOP_LEVEL, 
    78                     n_originalName, n_ops, n_args); 
     77            return new OpRef(op.getSpan(), op.isParenthesized(), Option.wrap(n_type), n_args, Environment.TOP_LEVEL, 
     78                    n_originalName, n_ops); 
    7979        } 
    8080         
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java

    r3082 r3092  
    265265 
    266266    public static OpRef makeOpRef(OpName op, List<StaticArg> staticArgs) { 
    267         return new OpRef(op.getSpan(), op, Collections.singletonList(op), staticArgs); 
     267        return new OpRef(op.getSpan(), staticArgs, op, Collections.singletonList(op)); 
    268268    } 
    269269 
     
    315315 
    316316    public static FnRef makeFnRef(FnRef original, int lexicalNestedness) { 
    317         return new FnRef(original.getSpan(), original.isParenthesized(), original.getLexicalDepth(), original.getOriginalName(), original.getFns(), original.getStaticArgs()); 
     317        return new FnRef(original.getSpan(), original.isParenthesized(), original.getStaticArgs(), original.getLexicalDepth(), original.getOriginalName(), original.getFns()); 
    318318    } 
    319319 
    320320    public static FnRef makeFnRef(FnRef that, Option<Type> ty, Id name, 
    321321                                  List<Id> ids, List<StaticArg> sargs) { 
    322         return new FnRef(that.getSpan(), that.isParenthesized(), ty, name, ids, 
    323                          sargs); 
     322        return new FnRef(that.getSpan(), that.isParenthesized(), ty, 
     323                sargs, name, ids); 
    324324    } 
    325325 
     
    331331    public static FnRef makeFnRef(Span span, Id name, List<StaticArg> sargs) { 
    332332        List<Id> names = Collections.singletonList(name); 
    333         return new FnRef(span, false, name, names, sargs); 
     333        return new FnRef(span, false, sargs, name, names); 
    334334    } 
    335335 
     
    337337        List<Id> names = 
    338338            Collections.singletonList(name); 
    339         return new FnRef(name.getSpan(), false, name, names, Collections.<StaticArg>emptyList()); 
     339        return new FnRef(name.getSpan(), false, Collections.<StaticArg>emptyList(), name, names); 
    340340    } 
    341341 
    342342    public static FnRef makeFnRef(Id name, Id orig){ 
    343      return new FnRef(name.getSpan(),false, orig, Collections.singletonList(name),Collections.<StaticArg>emptyList()); 
     343     return new FnRef(name.getSpan(),false,Collections.<StaticArg>emptyList(), orig, Collections.singletonList(name)); 
    344344    } 
    345345 
    346346    public static FnRef makeFnRef(Id orig, List<Id> names){ 
    347      return new FnRef(orig.getSpan(),false, orig, names,Collections.<StaticArg>emptyList()); 
     347     return new FnRef(orig.getSpan(),false,Collections.<StaticArg>emptyList(), orig, names); 
    348348    } 
    349349 
     
    351351        Id qName = NodeFactory.makeId(apiIds, name); 
    352352        List<Id> qNames = Collections.singletonList(qName); 
    353         return new FnRef(qName.getSpan(), false, qName, qNames, 
    354                 Collections.<StaticArg>emptyList()); 
     353        return new FnRef(qName.getSpan(), false, 
     354                Collections.<StaticArg>emptyList(), qName, qNames); 
    355355    } 
    356356 
     
    358358        Id qName = NodeFactory.makeId(api, name); 
    359359        List<Id> qNames = Collections.singletonList(qName); 
    360         return new FnRef(qName.getSpan(), false, qName, qNames, 
    361                 Collections.<StaticArg>emptyList()); 
     360        return new FnRef(qName.getSpan(), false, 
     361                Collections.<StaticArg>emptyList(), qName, qNames); 
    362362    } 
    363363 
    364364    public static FnRef makeFnRef(Span span, boolean paren, Id original_fn, List<Id> fns, List<StaticArg> sargs) { 
    365      return new FnRef(span, paren, original_fn, fns, sargs); 
     365     return new FnRef(span, paren, sargs, original_fn, fns); 
    366366    } 
    367367 
     
    873873        } 
    874874        public Expr forFnRef(FnRef e) { 
    875             return new FnRef(e.getSpan(), true, e.getOriginalName(), e.getFns(), 
    876                     e.getStaticArgs()); 
     875            return new FnRef(e.getSpan(), true, 
     876                    e.getStaticArgs(), e.getOriginalName(), e.getFns()); 
    877877        } 
    878878        public Expr forOpRef(OpRef e) { 
    879             return new OpRef(e.getSpan(), true, e.getOriginalName(), e.getOps(), 
    880                     e.getStaticArgs()); 
     879            return new OpRef(e.getSpan(), true, 
     880                    e.getStaticArgs(), e.getOriginalName(), e.getOps()); 
    881881        } 
    882882        public Expr forSubscriptExpr(SubscriptExpr e) { 
     
    920920      new_original_name = NodeFactory.makeOpInfix((Op)op.getOriginalName()); 
    921921 
    922      OpRef new_op = new OpRef(op.getSpan(),op.isParenthesized(),op.getLexicalDepth(),new_original_name,new_ops,op.getStaticArgs()); 
     922     OpRef new_op = new OpRef(op.getSpan(),op.isParenthesized(),op.getStaticArgs(),op.getLexicalDepth(),new_original_name,new_ops); 
    923923     return ExprFactory.makeOpExpr(new_op, lhs, rhs); 
    924924    } 
     
    939939      new_original_name = NodeFactory.makeOpPostfix((Op)op.getOriginalName()); 
    940940 
    941      OpRef new_op = new OpRef(op.getSpan(),op.isParenthesized(),op.getLexicalDepth(),new_original_name,new_ops,op.getStaticArgs()); 
     941     OpRef new_op = new OpRef(op.getSpan(),op.isParenthesized(),op.getStaticArgs(),op.getLexicalDepth(),new_original_name,new_ops); 
    942942     return ExprFactory.makeOpExpr(e, new_op); 
    943943    } 
  • trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java

    r3082 r3092  
    12911291 
    12921292    public static Expr makeOpRef(OpRef original, int lexicalNestedness) { 
    1293             return new OpRef(original.getSpan(), original.isParenthesized(), lexicalNestedness, original.getOriginalName(), original.getOps(), original.getStaticArgs()); 
     1293            return new OpRef(original.getSpan(), original.isParenthesized(), original.getStaticArgs(), lexicalNestedness, original.getOriginalName(), original.getOps()); 
    12941294 
    12951295    } 
  • trunk/ProjectFortress/src/com/sun/fortress/parser_util/precedence_resolver/ASTUtil.java

    r2236 r3092  
    109109            Enclosing en = new Enclosing(s, left, right); 
    110110            OpRef ref = new OpRef(s, 
     111                    sargs, 
    111112                    en, 
    112                                   Collections.<OpName>singletonList(en), 
    113                                   sargs); 
     113                                  Collections.<OpName>singletonList(en)); 
    114114            return new OpExpr(span, false, ref, args); 
    115115        } else { 
  • trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java

    r3082 r3092  
    18331833 
    18341834    @Override public String forFnRefOnly(FnRef that, Option<String> exprType_result, 
     1835                                         List<String> staticArgs_result, 
    18351836                                         String originalName_result, 
    1836                                          List<String> fns_result, 
    1837                                          List<String> staticArgs_result) { 
     1837                                         List<String> fns_result) { 
    18381838        StringBuilder s = new StringBuilder(); 
    18391839 
     
    18581858 
    18591859    @Override public String forOpRefOnly(OpRef that, Option<String> exprType_result, 
     1860                                         List<String> staticArgs_result, 
    18601861                                         String originalName_result, 
    1861                                          List<String> ops_result, 
    1862                                          List<String> staticArgs_result) { 
     1862                                         List<String> ops_result) { 
    18631863        return handleParen( canonicalOp(originalName_result), 
    18641864                            that.isParenthesized() ); 
     
    18761876    public String for_RewriteInstantiatedFnRefsOnly( 
    18771877            _RewriteInstantiatedFnRefs that, Option<String> exprType_result, 
    1878             String originalName_result, List<String> fns_result, 
    1879             List<String> staticArgs_result, List<String> overloadings_result) { 
     1878            List<String> staticArgs_result, 
     1879            String originalName_result, List<String> fns_result, List<String> overloadings_result) { 
    18801880        return "(* _RewriteInstantiatedFnRefs *)"; 
    18811881    } 
     
    18841884    public String for_RewriteInstantiatedOpRefsOnly( 
    18851885            _RewriteInstantiatedOpRefs that, Option<String> exprType_result, 
    1886             String originalName_result, List<String> ops_result, 
    1887             List<String> staticArgs_result, List<String> overloadings_result) { 
     1886            List<String> staticArgs_result, 
     1887            String originalName_result, List<String> ops_result, List<String> overloadings_result) { 
    18881888        return "(* _RewriteInstantiatedOpRefs *)"; 
    18891889    }