Changeset 3077
- Timestamp:
- 11/18/08 09:34:54 (12 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 removed
- 38 modified
-
Library/FortressSyntax.fsi (modified) (1 diff)
-
ProjectFortress/astgen/AST-doc.txt (deleted)
-
ProjectFortress/astgen/Fortress.ast (modified) (2 diffs)
-
ProjectFortress/not_passing_yet/staticParamNotFound.fss (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java (modified) (7 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java (modified) (20 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java (modified) (11 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredFunction.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredMethod.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/index/FunctionalMethod.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/FnDeclTypeEnv.java (added)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/FnDefTypeEnv.java (deleted)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (9 diffs)
-
ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeEnv.java (modified) (9 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/Driver.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java (modified) (8 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildLetEnvironments.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTestEnvironments.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTraitEnvironment.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalVarsEnvironment.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvaluatorBase.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/scopes/SFnDecl.java (added)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/scopes/SFnDef.java (deleted)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObject.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/Constructor.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/FGenericFunction.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/GenericFunctionalMethod.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java (modified) (7 diffs)
-
ProjectFortress/src/com/sun/fortress/interpreter/rewrite/IsAnArrowName.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (12 diffs)
-
ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/parser/LocalDecl.rats (modified) (2 diffs)
-
ProjectFortress/src/com/sun/fortress/parser_util/FortressUtil.java (modified) (3 diffs)
-
ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java (modified) (1 diff)
-
ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/Transform.java (modified) (4 diffs)
-
ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (1 diff)
-
ProjectFortress/static_tests/syntax_abstraction/transformer/SyntaxExtends.fsi (modified) (3 diffs)
-
ProjectFortress/tests/forFnDecl.fss (added)
-
ProjectFortress/tests/forFnDef.fss (deleted)
-
ProjectFortress/tests/objectCC_staticParams.fss (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Library/FortressSyntax.fsi
r2502 r3077 75 75 native grammar LocalVarFnDecl 76 76 LocalVarFnDecl : LetExpr 77 LocalFnDecl : FnDe f77 LocalFnDecl : FnDecl 78 78 LocalVarDecl : LocalVarDecl 79 79 end -
trunk/ProjectFortress/astgen/Fortress.ast
r3074 r3077 456 456 /** 457 457 * functional declaration in components 458 */ 459 abstract FnDecl(); 460 /** 461 * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause = Expr 462 * e.g.) swap (x, y) = (y, x) 463 */ 464 FnDef(Expr body, Option<Id> implementsUnambiguousName = Option.<Id>none()); 458 * FnDecl ::= FnMods? FnHeaderFront FnHeaderClause = Expr 459 * e.g.) swap (x, y) = (y, x) 460 */ 461 FnDecl(Expr body, Option<Id> implementsUnambiguousName = Option.<Id>none()); 465 462 /** 466 463 * value parameter of functional declarations and object declarations … … 1021 1018 * e.g.) localFn(x: ZZ32) = x + 2 1022 1019 */ 1023 LetFn(List<FnDe f> fns);1020 LetFn(List<FnDecl> fns); 1024 1021 /** 1025 1022 * local variable declaration -
trunk/ProjectFortress/not_passing_yet/staticParamNotFound.fss
r2965 r3077 49 49 end 50 50 51 (* Nested FnDe fs within the object decl which declares more static params *)51 (* Nested FnDecls within the object decl which declares more static params *) 52 52 object O4[\X extends String, S extends String\](x:X, s:S) 53 53 foo[\Z1 extends ZZ32\](z1:Z1):Y = do -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java
r3074 r3077 254 254 field.getType()); 255 255 else 256 return NodeFactory.makeFnDe f(span, mods, field.getName(),256 return NodeFactory.makeFnDecl(span, mods, field.getName(), 257 257 field.getType(), body); 258 258 } … … 306 306 Option.some(voidType)); 307 307 else 308 return NodeFactory.makeFnDe f(span, mods, name, params,308 return NodeFactory.makeFnDecl(span, mods, name, params, 309 309 Option.some(voidType), assign); 310 310 } … … 630 630 631 631 @Override 632 public Node forFnDe fOnly(FnDefthat, List<Modifier> mods_result,632 public Node forFnDeclOnly(FnDecl that, List<Modifier> mods_result, 633 633 IdOrOpOrAnonymousName name_result, 634 634 List<StaticParam> staticParams_result, … … 642 642 Option<Id> implementsUnambiguousName_result) 643 643 { 644 return new FnDe f(that.getSpan(), removeGetterSetterMod(mods_result),644 return new FnDecl(that.getSpan(), removeGetterSetterMod(mods_result), 645 645 name_result, staticParams_result, params_result, 646 646 returnType_result, throwsClause_result, -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java
r3071 r3077 42 42 private TypeCheckerOutput typeCheckerOutput; 43 43 // A stack keeping track of all nodes that can create new scope 44 // TraitDecl, ObjectDecl, FnDe f, FnExpr, IfClause, For, LetFn, LocalVarDecl,44 // TraitDecl, ObjectDecl, FnDecl, FnExpr, IfClause, For, LetFn, LocalVarDecl, 45 45 // Label, Catch, Typecase, GeneratedExpr, While, and ObjectExpr 46 46 private Stack<Node> scopeStack; … … 154 154 155 155 @Override 156 public void forFnDe f(FnDefthat) {157 scopeStack.push(that); 158 super.forFnDe f(that);156 public void forFnDecl(FnDecl that) { 157 scopeStack.push(that); 158 super.forFnDecl(that); 159 159 scopeStack.pop(); 160 160 } … … 323 323 public void forExit(Exit that) { 324 324 // Not in object expression; we are done. 325 if( objExprStack.isEmpty() ) { 325 if( objExprStack.isEmpty() ) { 326 326 super.forExit(that); 327 327 return; 328 328 } 329 329 330 330 forExitDoFirst(that); 331 331 332 // figure out the exit label name; 332 // figure out the exit label name; 333 333 // there should be one assigned in Exit._target by the 334 // ExprDisambiguator already; if it's not found, throw an error 334 // ExprDisambiguator already; if it's not found, throw an error 335 335 Option<Id> targetOp = that.getTarget(); 336 336 Id target = null; … … 342 342 ObjectExpr innerMostObjExpr = null; 343 343 for(int i=scopeStack.size()-1; i>=0; i++) { 344 Node n = scopeStack.get(i); 344 Node n = scopeStack.get(i); 345 345 if(n instanceof Label) { 346 innerMostLabel = (Label) n; 346 innerMostLabel = (Label) n; 347 347 break; 348 348 } else if(n instanceof ObjectExpr) { 349 innerMostObjExpr = (ObjectExpr) n; 349 innerMostObjExpr = (ObjectExpr) n; 350 350 } 351 351 } 352 352 353 if(innerMostObjExpr == null) { 353 if(innerMostObjExpr == null) { 354 354 // the label is not captured because it's defined within the 355 355 // inner-most object expr; no need to handle this. 356 356 super.forExit(that); 357 357 return; 358 } 358 } 359 359 360 360 // this label _is_ captured 361 361 target = innerMostLabel.getName(); */ 362 throw new DesugarerError( that.getSpan(), 362 throw new DesugarerError( that.getSpan(), 363 363 "Exit target label is not disambiguated!" ); 364 364 } 365 366 // check wither the target label is declared within obj expr or free 365 366 // check wither the target label is declared within obj expr or free 367 367 Label label = null; 368 368 ObjectExpr innerMostObjExpr = null; 369 369 370 370 for(int i=scopeStack.size()-1; i>=0; i--) { 371 Node n = scopeStack.get(i); 371 Node n = scopeStack.get(i); 372 372 if(n instanceof Label) { 373 label = (Label) n; 373 label = (Label) n; 374 374 if( label.getName().equals(target) ) { 375 375 // label found before hitting the inner most obj 376 376 // expr, so it is not free 377 break; 378 } 377 break; 378 } 379 379 } else if(n instanceof ObjectExpr) { 380 380 // found the obj expr before finding the label, so it's free … … 410 410 411 411 if(enclosingTraitDecl.isSome()) { 412 isShadowed = isShadowedInNode( enclosingTraitDecl.unwrap(), 412 isShadowed = isShadowedInNode( enclosingTraitDecl.unwrap(), 413 413 that.getVar() ); 414 414 } else if(enclosingObjectDecl.isSome()) { 415 isShadowed = isShadowedInNode( enclosingObjectDecl.unwrap(), 415 isShadowed = isShadowedInNode( enclosingObjectDecl.unwrap(), 416 416 that.getVar() ); 417 417 } … … 1000 1000 1001 1001 @Override 1002 public void forFnDe f(FnDefthat) {1002 public void forFnDecl(FnDecl that) { 1003 1003 IdOrOpOrAnonymousName name = that.getName(); 1004 1004 if(name instanceof Id) { … … 1006 1006 } else { 1007 1007 throw new DesugarerError(that.getSpan(), "Unexpected type " + 1008 "for FnDe fname " + that.getName() + " when " +1008 "for FnDecl name " + that.getName() + " when " + 1009 1009 "when parsing decls for object expr at " + 1010 1010 root.getSpan() ); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java
r3026 r3077 45 45 // Type info passed down from the type checking phase 46 46 private TypeCheckerOutput typeCheckerOutput; 47 /* 47 /* 48 48 * A list of newly created ObjectDecls (i.e. lifted obj expressions and 49 49 * objectDecls for boxed mutable var refs they capture) … … 225 225 } 226 226 227 /* 227 /* 228 228 * if rewriteList == null, returnValue = that; otherwise, 229 229 * returnValue is updated by the MutableVarRefRewriteVisitor. … … 254 254 255 255 @Override 256 public Node forFnDe f(FnDefthat) {257 scopeStack.push(that); 258 Node returnValue = super.forFnDe f(that);256 public Node forFnDecl(FnDecl that) { 257 scopeStack.push(that); 258 Node returnValue = super.forFnDecl(that); 259 259 scopeStack.pop(); 260 260 return returnValue; … … 385 385 * A map mapping from Exit node to its corresponding exitFnParam info 386 386 * that we created when lifting the ObjectExpr - we need the param Id 387 * and type to make the FnRef in ExitRewriter 387 * and type to make the FnRef in ExitRewriter 388 388 * We use the Exit's span and target label id as the key instead of 389 * just the Exit node itself, because by this point, the Exit may 390 * have been rewritten and may not be the same if its return 389 * just the Exit node itself, because by this point, the Exit may 390 * have been rewritten and may not be the same if its return 391 391 * expression captured mutable variables (they would be boxed). 392 392 * We only store the function id and type pair as value because … … 394 394 * would have to dig those info out again. 395 395 */ 396 final Map<Pair<Span,Id>, Pair<Id,Type>> 396 final Map<Pair<Span,Id>, Pair<Id,Type>> 397 397 exitFnParamMap = new HashMap<Pair<Span,Id>, Pair<Id,Type>>(); 398 398 … … 404 404 * Anonymous inner class that rewrites the Exit node which captured 405 405 * the free label inside ObjectExpr into a call to the Exit function 406 * that passed into lifted ObjectDecl as a param 406 * that passed into lifted ObjectDecl as a param 407 407 */ 408 408 NodeUpdateVisitor rewriter = new NodeUpdateVisitor() { 409 @Override 409 @Override 410 410 public Node forExit(Exit that) { 411 411 Span span = that.getSpan(); 412 412 Id labelId = unwrapIfSomeElseError( that.getTarget(), 413 that.getSpan(), 413 that.getSpan(), 414 414 "Exit target label is not disambiguated!" ); 415 415 Pair<Span,Id> exitKey = new Pair<Span,Id>(span, labelId); … … 421 421 Id fnName = exitFnInfo.first(); 422 422 FnRef fnRef = ExprFactory.makeFnRef(fnName); 423 exprs.add(fnRef); 424 exprs.add( unwrapIfSomeElseAlternative(returnExpr, 423 exprs.add(fnRef); 424 exprs.add( unwrapIfSomeElseAlternative(returnExpr, 425 425 ExprFactory.makeVoidLiteralExpr(span)) ); 426 426 … … 510 510 } 511 511 512 // Handle static params from the enclosing nested FnDe f512 // Handle static params from the enclosing nested FnDecl 513 513 for(Node n : scopeStack) { 514 if(n instanceof FnDe f) {515 sParams = ((FnDe f) n).getStaticParams();514 if(n instanceof FnDecl) { 515 sParams = ((FnDecl) n).getStaticParams(); 516 516 for(StaticParam sp : sParams) { 517 args.add( makeStaticArgFromStaticParam(sp) ); 517 args.add( makeStaticArgFromStaticParam(sp) ); 518 518 } 519 519 } … … 571 571 /* Make the argument for each exit label captured: 572 572 * fn(e:exitWithType) : exitWithType => exit foo with e OR 573 * fn() : () => exit foo 573 * fn() : () => exit foo 574 574 * Actually, this is a "cheat". The fn should really have 575 575 * BottomType as its return type, but since BottomType cannot be … … 578 578 */ 579 579 for(Exit exit : freeExitLabels) { 580 Span exitSpan = exit.getSpan(); 580 Span exitSpan = exit.getSpan(); 581 581 exitFnExprParams = new LinkedList<Param>(); 582 exitWithId = NodeFactory.makeId( exitSpan, 582 exitWithId = NodeFactory.makeId( exitSpan, 583 583 MANGLE_CHAR+EXIT_WITH_PARAM ); 584 584 … … 589 589 VarRef var = ExprFactory.makeVarRef(exitSpan, 590 590 exitWithId, exitWithTypeOp); 591 exitFnBody = ExprFactory.makeExit(exitSpan, 591 exitFnBody = ExprFactory.makeExit(exitSpan, 592 592 exit.getExprType(), exit.getTarget(), var); 593 exitFnExprParams.add( 593 exitFnExprParams.add( 594 594 NodeFactory.makeNormalParam(exitSpan, 595 595 exitWithId, exitWithTypeOp) ); … … 598 598 "Exit with expr of an unknown type!" ); 599 599 } 600 exitFnRetTypeOp = exitWithTypeOp; 600 exitFnRetTypeOp = exitWithTypeOp; 601 601 } else { 602 exitFnBody = exit; 603 exitFnRetTypeOp = Option.<Type>some( 602 exitFnBody = exit; 603 exitFnRetTypeOp = Option.<Type>some( 604 604 NodeFactory.makeVoidType(exitSpan) ); 605 } 606 607 exitFnExpr = ExprFactory.makeFnExpr( exitSpan, 605 } 606 607 exitFnExpr = ExprFactory.makeFnExpr( exitSpan, 608 608 exitFnExprParams, exitFnRetTypeOp, exitFnBody ); 609 609 exprs.add(exitFnExpr); … … 651 651 } 652 652 653 params = makeParamsForLiftedObj(target, freeNames, 653 params = makeParamsForLiftedObj(target, freeNames, 654 654 enclosingSelf, exitFnParamMap); 655 655 /* Use default value for modifiers, where clauses, … … 702 702 } 703 703 704 // Handle static params from the enclosing nested FnDe f704 // Handle static params from the enclosing nested FnDecl 705 705 for(Node n : scopeStack) { 706 if(n instanceof FnDe f) {707 sParams = ((FnDe f) n).getStaticParams();708 sParamsCopy.addAll(sParams); 706 if(n instanceof FnDecl) { 707 sParams = ((FnDecl) n).getStaticParams(); 708 sParamsCopy.addAll(sParams); 709 709 } 710 710 } … … 743 743 // FIXME: what span should I use? 744 744 type = var.getExprType(); 745 param = NodeFactory.makeNormalParam(var.getSpan(), 745 param = NodeFactory.makeNormalParam(var.getSpan(), 746 746 var.getVar(), type); 747 747 params.add(param); … … 774 774 if(retExpr.isSome()) { 775 775 retType = unwrapIfSomeElseError( 776 retExpr.unwrap().getExprType(), 777 exitSpan, 776 retExpr.unwrap().getExprType(), 777 exitSpan, 778 778 "Exit with expr of an unknown type!" ); 779 779 } else { // exit with no expr … … 783 783 exitFnType = NodeFactory.makeArrowType( exitSpan, retType, retType ); 784 784 type = Option.<Type>some(exitFnType); 785 Id exitFnId = NodeFactory.makeId(exitSpan, 785 Id exitFnId = NodeFactory.makeId(exitSpan, 786 786 MANGLE_CHAR + EXIT_FUNC_PREFIX + "_" + exitIndex); 787 787 param = NodeFactory.makeNormalParam(exitSpan, exitFnId, type); … … 815 815 Id enclosingParamId = NodeFactory.makeId(paramSpan, 816 816 MANGLE_CHAR + ENCLOSING_PREFIX + "_" + objExprNestingLevel); 817 param = NodeFactory.makeNormalParam(paramSpan, 817 param = NodeFactory.makeNormalParam(paramSpan, 818 818 enclosingParamId, enclosingSelfType); 819 819 … … 821 821 } 822 822 823 /* 823 /* 824 824 * Generate a map mapping from mutable VarRef to its coresponding 825 825 * container info (i.e. its boxed ObjectDecl, the new VarDecl to create … … 892 892 return uniqueId++; 893 893 } 894 894 895 895 /* Static helper methods for handling Option<T> */ 896 896 private static <T> T -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java
r3074 r3077 46 46 import com.sun.fortress.nodes.Exit; 47 47 import com.sun.fortress.nodes.Expr; 48 import com.sun.fortress.nodes.FnDe f;48 import com.sun.fortress.nodes.FnDecl; 49 49 import com.sun.fortress.nodes.FnExpr; 50 50 import com.sun.fortress.nodes.FnRef; … … 432 432 433 433 @Override 434 public Set<Id> forFnDe f(FnDefthat) {434 public Set<Id> forFnDecl(FnDecl that) { 435 435 return Collections.emptySet(); 436 436 } … … 464 464 465 465 @Override 466 public Set<IdOrOpOrAnonymousName> forFnDe f(FnDefthat) {466 public Set<IdOrOpOrAnonymousName> forFnDecl(FnDecl that) { 467 467 if (NodeUtil.isSetterOrGetter(that.getMods())) { 468 468 accessors.add(that.getName()); … … 510 510 511 511 // @Override 512 // public Set<Id> forFnDe f(FnDefthat) {512 // public Set<Id> forFnDecl(FnDecl that) { 513 513 // return Collections.emptySet(); 514 514 // } … … 541 541 542 542 // @Override 543 // public Set<IdOrOpOrAnonymousName> forFnDe f(FnDefthat) {543 // public Set<IdOrOpOrAnonymousName> forFnDecl(FnDecl that) { 544 544 // if( isSetterOrGetter(that.getMods()) ) 545 545 // accessors.add(that.getName()); … … 900 900 901 901 // No need to recur on the name, as we will not modify it and we have already checked 902 // for shadowing in forObjectDecl. Also, if this FnDe fis a getter, we allow it902 // for shadowing in forObjectDecl. Also, if this FnDecl is a getter, we allow it 903 903 // to share its name with a field, so blindly checking for shadowing at this point 904 904 // doesn't work. … … 917 917 918 918 /** 919 * When recurring on a FnDe f, we first need to extend the919 * When recurring on a FnDecl, we first need to extend the 920 920 * environment with all the newly bound static parameters that 921 921 * can be used in an expression context, along with all function … … 923 923 * TODO: Handle variables bound in where clauses. 924 924 */ 925 @Override public Node forFnDe f(FnDefthat) {925 @Override public Node forFnDecl(FnDecl that) { 926 926 Set<Id> staticExprVars = extractStaticExprVars(that.getStaticParams()); 927 927 Set<Id> params = extractParamNames(that.getParams()); … … 930 930 931 931 // No need to recur on the name, as we will not modify it and we have already checked 932 // for shadowing in forObjectDecl. Also, if this FnDe fis a getter, we allow it932 // for shadowing in forObjectDecl. Also, if this FnDecl is a getter, we allow it 933 933 // to share its name with a field, so blindly checking for shadowing at this point 934 934 // doesn't work. 935 return forFnDe fOnly(that,935 return forFnDeclOnly(that, 936 936 v.recurOnListOfModifier(that.getMods()), 937 937 (IdOrOpOrAnonymousName) that.getName(), … … 1136 1136 Set<IdOrOpOrAnonymousName> definedNames = extractDefinedFnNames(that.getFns()); 1137 1137 ExprDisambiguator v = extendWithLocalFns(definedNames); 1138 List<FnDe f> fnsResult = v.recurOnListOfFnDef(that.getFns());1138 List<FnDecl> fnsResult = v.recurOnListOfFnDecl(that.getFns()); 1139 1139 List<Expr> bodyResult = v.recurOnListOfExpr(that.getBody()); 1140 1140 Option<Type> type_result = recurOnOptionOfType(that.getExprType()); … … 1143 1143 1144 1144 1145 private Set<IdOrOpOrAnonymousName> extractDefinedFnNames(Iterable<FnDe f> fnDefs) {1145 private Set<IdOrOpOrAnonymousName> extractDefinedFnNames(Iterable<FnDecl> fnDefs) { 1146 1146 Set<IdOrOpOrAnonymousName> result = new HashSet<IdOrOpOrAnonymousName>(); 1147 for (FnDe ffd : fnDefs) { result.add(fd.getName()); }1147 for (FnDecl fd : fnDefs) { result.add(fd.getName()); } 1148 1148 // multiple instances of the same name are allowed 1149 1149 return result; -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/TypeDisambiguator.java
r3074 r3077 44 44 import com.sun.fortress.nodes.Effect; 45 45 import com.sun.fortress.nodes.Expr; 46 import com.sun.fortress.nodes.FnDe f;46 import com.sun.fortress.nodes.FnDecl; 47 47 import com.sun.fortress.nodes.GrammarDef; 48 48 import com.sun.fortress.nodes.GrammarMemberDecl; … … 231 231 * environment with all the newly bound static parameters. 232 232 */ 233 @Override public Node forFnDe f(final FnDefthat) {233 @Override public Node forFnDecl(final FnDecl that) { 234 234 TypeDisambiguator v = this.extend(that.getStaticParams()); 235 235 236 return forFnDe fOnly(that,236 return forFnDeclOnly(that, 237 237 v.recurOnListOfModifier(that.getMods()), 238 238 (IdOrOpOrAnonymousName) that.getName().accept(v), -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredFunction.java
r2455 r3077 25 25 import com.sun.fortress.nodes.Expr; 26 26 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 27 import com.sun.fortress.nodes.FnDe f;27 import com.sun.fortress.nodes.FnDecl; 28 28 import com.sun.fortress.nodes.Node; 29 29 import com.sun.fortress.nodes.NodeDepthFirstVisitor; … … 52 52 } 53 53 @Override 54 public Option<Expr> forFnDe f(FnDefthat) {54 public Option<Expr> forFnDecl(FnDecl that) { 55 55 return Option.some(that.getBody()); 56 56 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredMethod.java
r2455 r3077 25 25 import com.sun.fortress.nodes.Expr; 26 26 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 27 import com.sun.fortress.nodes.FnDe f;27 import com.sun.fortress.nodes.FnDecl; 28 28 import com.sun.fortress.nodes.Id; 29 29 import com.sun.fortress.nodes.Node; … … 57 57 } 58 58 @Override 59 public Option<Expr> forFnDe f(FnDefthat) {59 public Option<Expr> forFnDecl(FnDecl that) { 60 60 return Option.some(that.getBody()); 61 61 } 62 62 }); 63 63 } 64 64 65 65 @Override 66 66 public List<Param> parameters() { … … 83 83 @Override 84 84 public Functional instantiate(List<StaticParam> params, List<StaticArg> args) { 85 FnAbsDeclOrDecl replaced_decl = 85 FnAbsDeclOrDecl replaced_decl = 86 86 (FnAbsDeclOrDecl)_ast.accept(new StaticTypeReplacer(params,args)); 87 87 return new DeclaredMethod(replaced_decl,_declaringTrait); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/FunctionalMethod.java
r2455 r3077 25 25 import com.sun.fortress.nodes.Expr; 26 26 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 27 import com.sun.fortress.nodes.FnDe f;27 import com.sun.fortress.nodes.FnDecl; 28 28 import com.sun.fortress.nodes.Id; 29 29 import com.sun.fortress.nodes.Node; … … 62 62 } 63 63 @Override 64 public Option<Expr> forFnDe f(FnDefthat) {64 public Option<Expr> forFnDecl(FnDecl that) { 65 65 return Option.some(that.getBody()); 66 66 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java
r3074 r3077 23 23 import com.sun.fortress.nodes.Contract; 24 24 import com.sun.fortress.nodes.Expr; 25 import com.sun.fortress.nodes.FnDe f;25 import com.sun.fortress.nodes.FnDecl; 26 26 import com.sun.fortress.nodes.Id; 27 27 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; … … 88 88 89 89 @Override 90 public Node forFnDe fOnly(FnDefthat, List<Modifier> mods_result,90 public Node forFnDeclOnly(FnDecl that, List<Modifier> mods_result, 91 91 IdOrOpOrAnonymousName name_result, 92 92 List<StaticParam> staticParams_result, List<Param> params_result, … … 101 101 returnType_result; 102 102 103 return super.forFnDe fOnly(that, mods_result, name_result, staticParams_result,103 return super.forFnDeclOnly(that, mods_result, name_result, staticParams_result, 104 104 params_result, new_ret_type, throwsClause_result, where_result, 105 105 contract_result, unambiguousName_result, body_result, implementsUnambiguousName_result); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3071 r3077 530 530 } 531 531 532 public TypeChecker extendWithFnDe fs(Relation<IdOrOpOrAnonymousName, ? extends FnDef> fns) {532 public TypeChecker extendWithFnDecls(Relation<IdOrOpOrAnonymousName, ? extends FnDecl> fns) { 533 533 return new TypeChecker(table, 534 typeEnv.extendWithFnDe fs(fns),534 typeEnv.extendWithFnDecls(fns), 535 535 compilationUnit, 536 536 subtypeChecker, … … 696 696 if(arg0 instanceof TypeParam){ 697 697 Set<BaseType> bounds = CollectUtil.asSet(((TypeParam)arg0).getExtendsClause()); 698 Type ivt = NodeFactory.make_InferenceVarType(method_name.getSpan()); 699 ConstraintFormula constraint=TypeChecker.this.subtypeChecker.subtype(ivt, NodeFactory.makeIntersectionType(bounds)); 698 Type ivt = NodeFactory.make_InferenceVarType(method_name.getSpan()); 699 ConstraintFormula constraint=TypeChecker.this.subtypeChecker.subtype(ivt, NodeFactory.makeIntersectionType(bounds)); 700 700 all_results.add(new TypeCheckerResult(that, Option.<Type>none(), constraint)); 701 701 return new TypeArg(NodeFactory.makeSpan(ivt), ivt); … … 1223 1223 else{ 1224 1224 List<StaticArg> sargs = that.getStaticArgs(); 1225 Option<ConstraintFormula> constraints = StaticTypeReplacer.argsMatchParams(sargs, trait_index.staticParameters(), this.subtypeChecker); 1225 Option<ConstraintFormula> constraints = StaticTypeReplacer.argsMatchParams(sargs, trait_index.staticParameters(), this.subtypeChecker); 1226 1226 if(constraints.isSome()) { 1227 1227 // First arg MUST BE a TypeArg, and it must be a supertype of the elements … … 2303 2303 2304 2304 @Override 2305 public TypeCheckerResult forFnDe f(FnDefthat) {2305 public TypeCheckerResult forFnDecl(FnDecl that) { 2306 2306 TypeChecker newChecker = this.extend(that.getStaticParams(), that.getParams(), that.getWhere()); 2307 2307 … … 2338 2338 } 2339 2339 2340 FnDe f new_node = new FnDef(that.getSpan(),2340 FnDecl new_node = new FnDecl(that.getSpan(), 2341 2341 that.getMods(), 2342 2342 that.getName(), … … 2684 2684 Type lhstype; 2685 2685 // Now create the bindings 2686 2686 2687 2687 if( bindings_count == 1 ){ 2688 2688 // Just one binding … … 2942 2942 @Override 2943 2943 public TypeCheckerResult forLetFn(LetFn that) { 2944 Relation<IdOrOpOrAnonymousName, FnDe f> fnDefs = new IndexedRelation<IdOrOpOrAnonymousName, FnDef>(false);2945 for (FnDe ffnDef : that.getFns()) {2944 Relation<IdOrOpOrAnonymousName, FnDecl> fnDefs = new IndexedRelation<IdOrOpOrAnonymousName, FnDecl>(false); 2945 for (FnDecl fnDef : that.getFns()) { 2946 2946 fnDefs.add(fnDef.getName(), fnDef); 2947 2947 } 2948 2948 2949 TypeChecker newChecker = this.extendWithFnDe fs(fnDefs);2950 List<TypeCheckerResult> fn_results = newChecker.recurOnListOfFnDe f(that.getFns());2949 TypeChecker newChecker = this.extendWithFnDecls(fnDefs); 2950 List<TypeCheckerResult> fn_results = newChecker.recurOnListOfFnDecl(that.getFns()); 2951 2951 2952 2952 // A LetFn is like a let. It has a body, and it's type is the type of the body … … 2961 2961 body_type, 2962 2962 (List<Expr>)TypeCheckerResult.astFromResults(body_results), 2963 (List<FnDe f>)TypeCheckerResult.astFromResults(fn_results));2963 (List<FnDecl>)TypeCheckerResult.astFromResults(fn_results)); 2964 2964 2965 2965 TypeCheckerResult result = … … 3766 3766 Option.<Type>some(new IntersectionType(NodeFactory.makeSetSpan("impossible", arrow_types), arrow_types)); 3767 3767 3768 constraints = accumulated_constraints; 3768 constraints = accumulated_constraints; 3769 3769 new_node = new OpRef(that.getSpan(), 3770 3770 that.isParenthesized(), -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeEnv.java
r3071 r3077 50 50 import com.sun.fortress.nodes.Enclosing; 51 51 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 52 import com.sun.fortress.nodes.FnDe f;52 import com.sun.fortress.nodes.FnDecl; 53 53 import com.sun.fortress.nodes.Id; 54 54 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; … … 109 109 110 110 //Iterate over top level types, adding each to component-level environment 111 111 112 112 typeEnv = typeEnv.extendWithTypeConses(cu.typeConses()); 113 114 113 114 115 115 return typeEnv; 116 116 } … … 229 229 return NodeFactory.makeIdFromLast(id); 230 230 } 231 231 232 232 static Enclosing removeApi(Enclosing id) { 233 233 return NodeFactory.makeEnclosing(id.getSpan(), id.getOpen(), id.getClose()); 234 234 } 235 235 236 236 static Op removeApi(Op id) { 237 237 return NodeFactory.makeOp(id.getSpan(), id.getText(), id.getFixity()); 238 238 } 239 239 240 240 static IdOrOpOrAnonymousName removeApi(IdOrOpOrAnonymousName id) { 241 241 return id.accept(new NodeDepthFirstVisitor<IdOrOpOrAnonymousName>(){ 242 @Override 242 @Override 243 243 public IdOrOpOrAnonymousName forEnclosing(Enclosing that) { 244 244 return NodeFactory.makeEnclosing(that.getSpan(), that.getOpen(), that.getClose()); … … 259 259 }); 260 260 } 261 261 262 262 /** 263 263 * Return a BindingLookup that binds the given IdOrOpOrAnonymousName to a type … … 271 271 */ 272 272 public abstract Option<StaticParam> staticParam(IdOrOpOrAnonymousName id); 273 273 274 274 /** 275 275 * Return the {@code Node} that declared the given id, or None if the id does not … … 277 277 * functions have multiple declaration sites. You can tell if an id is a function 278 278 * or not by calling type() on the same id. 279 * 279 * 280 280 * @exception IllegalArgumentException If var is a function, since functions have 281 281 * multiple declaration sites. 282 282 */ 283 283 public abstract Option<Node> declarationSite(IdOrOpOrAnonymousName var); 284 284 285 285 /** 286 286 * Return the type of the given IdOrOpOrAnonymousName (if the given IdOrOpOrAnonymousName is in … … 394 394 } 395 395 396 public final TypeEnv extendWithFnDe fs(Relation<IdOrOpOrAnonymousName, ? extends FnDef> fns) {396 public final TypeEnv extendWithFnDecls(Relation<IdOrOpOrAnonymousName, ? extends FnDecl> fns) { 397 397 if (fns.size() == 0) { return this; } 398 else { return new FnDe fTypeEnv(fns, this); }398 else { return new FnDeclTypeEnv(fns, this); } 399 399 } 400 400 … … 413 413 else { return new StaticParamTypeEnv(params,this); } 414 414 } 415 415 416 416 public final TypeEnv extendWithTypeConses(Map<Id, TypeConsIndex> typeConses) { 417 417 if (typeConses.isEmpty()) { … … 509 509 public List<Modifier> getMods() { return mods; } 510 510 511 public boolean isMutable() { 512 if( mutable ) 511 public boolean isMutable() { 512 if( mutable ) 513 513 return true; 514 514 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/Driver.java
r3047 r3077 73 73 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 74 74 import com.sun.fortress.nodes.FnDecl; 75 import com.sun.fortress.nodes.FnDef;76 75 import com.sun.fortress.nodes.GrammarDecl; 77 76 import com.sun.fortress.nodes.GrammarDef; … … 132 131 133 132 public static ArrayList<ComponentWrapper> components; 134 133 135 134 public static void reset() { 136 135 components = null; 137 136 libraryComponentWrapper = null; 138 137 } 139 138 140 139 public static Environment evalComponent(ComponentIndex p, 141 140 FortressRepository fr) -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java
r3053 r3077 272 272 273 273 274 private void forFnDe f1(FnDefx) {274 private void forFnDecl1(FnDecl x) { 275 275 List<StaticParam> optStaticParams = x.getStaticParams(); 276 276 String fname = NodeUtil.nameAsMethod(x); … … 289 289 } 290 290 291 private void forFnDe f2(FnDefx) {291 private void forFnDecl2(FnDecl x) { 292 292 } 293 293 294 294 // Overridden in BuildTraitEnvironment 295 protected void forFnDe f3(FnDefx) {295 protected void forFnDecl3(FnDecl x) { 296 296 List<StaticParam> optStaticParams = x.getStaticParams(); 297 297 String fname = NodeUtil.nameAsMethod(x); … … 300 300 } 301 301 302 private void forFnDe f4(FnDefx) {302 private void forFnDecl4(FnDecl x) { 303 303 } 304 304 … … 306 306 * (non-Javadoc) 307 307 * 308 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDe f(com.sun.fortress.interpreter.nodes.FnDef)309 */ 310 @Override 311 public Boolean forFnDe f(FnDefx) {308 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDecl(com.sun.fortress.interpreter.nodes.FnDecl) 309 */ 310 @Override 311 public Boolean forFnDecl(FnDecl x) { 312 312 switch (getPass()) { 313 case 1: forFnDe f1(x); break;314 case 2: forFnDe f2(x); break;315 case 3: forFnDe f3(x); break;316 case 4: forFnDe f4(x); break;313 case 1: forFnDecl1(x); break; 314 case 2: forFnDecl2(x); break; 315 case 3: forFnDecl3(x); break; 316 case 4: forFnDecl4(x); break; 317 317 } 318 318 return null; … … 796 796 return bug("BuildEnvironments.forAbsTraitDecl should not be called"); 797 797 } 798 798 799 799 /* 800 800 * (non-Javadoc) … … 874 874 public void finishTrait(TraitAbsDeclOrDecl x, FTypeTrait ftt, Environment interior) { 875 875 List<BaseType> extends_ = NodeUtil.getTypes(x.getExtendsClause()); 876 // TODO What if I don't 876 // TODO What if I don't 877 877 // interior = interior.extendAt(x); 878 878 … … 1094 1094 * (non-Javadoc) 1095 1095 * 1096 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDe f(com.sun.fortress.interpreter.nodes.AbsFnDecl)1096 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDecl(com.sun.fortress.interpreter.nodes.AbsFnDecl) 1097 1097 */ 1098 1098 @Override … … 1100 1100 return bug("BuildEnvironments.forAbsFnDecl should not be called"); 1101 1101 } 1102 1102 1103 1103 /* 1104 1104 * (non-Javadoc) -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildLetEnvironments.java
r2649 r3077 33 33 import com.sun.fortress.nodes.NodeAbstractVisitor; 34 34 import com.sun.fortress.nodes.Expr; 35 import com.sun.fortress.nodes.FnDe f;35 import com.sun.fortress.nodes.FnDecl; 36 36 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 37 37 import com.sun.fortress.nodes.LValue; … … 61 61 @Override 62 62 public FValue forLetFn(LetFn x) { 63 List<FnDe f> fns = x.getFns();63 List<FnDecl> fns = x.getFns(); 64 64 List<Expr> body = x.getBody(); 65 65 66 66 for (int i = 0; i < fns.size(); i++) { 67 FnDe ffn = fns.get(i);67 FnDecl fn = fns.get(i); 68 68 69 69 IdOrOpOrAnonymousName name = fn.getName(); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTestEnvironments.java
r2896 r3077 65 65 } 66 66 67 public Boolean forFnDe f(FnDefx) {68 Debug.debug( Debug.Type.INTERPRETER, 2, "ForFnDe f", x);67 public Boolean forFnDecl(FnDecl x) { 68 Debug.debug( Debug.Type.INTERPRETER, 2, "ForFnDecl ", x); 69 69 List<StaticParam> optStaticParams = x.getStaticParams(); 70 70 String fname = NodeUtil.nameAsMethod(x); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTraitEnvironment.java
r2969 r3077 28 28 import com.sun.fortress.interpreter.evaluator.values.Simple_fcn; 29 29 import com.sun.fortress.nodes.AbsFnDecl; 30 import com.sun.fortress.nodes.FnDe f;30 import com.sun.fortress.nodes.FnDecl; 31 31 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 32 32 import com.sun.fortress.nodes.Id; … … 94 94 } 95 95 96 protected void forFnDe f3(FnDefx) {96 protected void forFnDecl3(FnDecl x) { 97 97 List<StaticParam> staticParams = x.getStaticParams(); 98 98 String fname = NodeUtil.nameAsMethod(x); … … 124 124 * (non-Javadoc) 125 125 * 126 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDe f(com.sun.fortress.interpreter.nodes.AbsFnDecl)126 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forFnDecl(com.sun.fortress.interpreter.nodes.AbsFnDecl) 127 127 */ 128 128 @Override -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvalVarsEnvironment.java
r2713 r3077 24 24 import com.sun.fortress.nodes.Component; 25 25 import com.sun.fortress.nodes.DimUnitDecl; 26 import com.sun.fortress.nodes.FnDe f;26 import com.sun.fortress.nodes.FnDecl; 27 27 import com.sun.fortress.nodes.ImportApi; 28 28 import com.sun.fortress.nodes.ImportNames; … … 69 69 70 70 /* (non-Javadoc) 71 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forFnDe f(com.sun.fortress.interpreter.nodes.AbsFnDecl)71 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forFnDecl(com.sun.fortress.interpreter.nodes.AbsFnDecl) 72 72 */ 73 73 @Override … … 78 78 79 79 /* (non-Javadoc) 80 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forFnDe f(com.sun.fortress.interpreter.nodes.FnDef)80 * @see com.sun.fortress.interpreter.evaluator.BuildEnvironments#forFnDecl(com.sun.fortress.interpreter.nodes.FnDecl) 81 81 */ 82 82 @Override 83 public Boolean forFnDe f(FnDefx) {83 public Boolean forFnDecl(FnDecl x) { 84 84 return null; 85 85 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/EvaluatorBase.java
r2741 r3077 131 131 132 132 GenericFunctionOrMethod bar = (GenericFunctionOrMethod) appliedThing; 133 // FnAbsDeclOrDecl fndod = bar.getFnDe fOrDecl();133 // FnAbsDeclOrDecl fndod = bar.getFnDeclOrDecl(); 134 134 List<StaticParam> tparams = bar.getStaticParams(); 135 135 List<Param> params = bar.getParams(); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/ScoutVisitor.java
r1649 r3077 28 28 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 29 29 import com.sun.fortress.nodes.FnDecl; 30 import com.sun.fortress.nodes.FnDe f;30 import com.sun.fortress.nodes.FnDecl; 31 31 import com.sun.fortress.nodes.VarType; 32 32 import com.sun.fortress.nodes.TraitType; … … 120 120 121 121 /* (non-Javadoc) 122 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forFnDef(com.sun.fortress.nodes.FnDef)123 */124 @Override125 public void forFnDef(FnDef that) {126 // TODO Auto-generated method stub127 super.forFnDef(that);128 }129 130 /* (non-Javadoc)131 122 * @see com.sun.fortress.nodes.NodeAbstractVisitor_void#forVarType(com.sun.fortress.nodes.VarType) 132 123 */ -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTraitOrObject.java
r2996 r3077 39 39 import com.sun.fortress.nodes.AbsDeclOrDecl; 40 40 import com.sun.fortress.nodes.AbstractNode; 41 import com.sun.fortress.nodes.FnDe f;41 import com.sun.fortress.nodes.FnDecl; 42 42 import com.sun.fortress.nodes.StaticArg; 43 43 import com.sun.fortress.nodes.TraitType; … … 456 456 } 457 457 Applicable a = mc.getDef(); 458 if (a instanceof FnDe f) {458 if (a instanceof FnDecl) { 459 459 thisSupplies.putItem(s, mo); 460 460 } else { -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/Constructor.java
r2973 r3077 42 42 import com.sun.fortress.interpreter.glue.WellKnownNames; 43 43 import com.sun.fortress.nodes.AbsDeclOrDecl; 44 import com.sun.fortress.nodes.FnDe f;44 import com.sun.fortress.nodes.FnDecl; 45 45 import com.sun.fortress.nodes.GenericWithParams; 46 46 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; … … 451 451 MethodClosure pdm = (MethodClosure) sf; 452 452 Applicable a = pdm.getDef(); 453 if (a instanceof FnDe f|| a instanceof NativeApp) return;453 if (a instanceof FnDecl || a instanceof NativeApp) return; 454 454 if (a.at().equals(sf.at())) { 455 455 error(cfn, errorMsg("Object ",cfn.stringName(), -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/FGenericFunction.java
r3003 r3077 53 53 FnAbsDeclOrDecl fndef; 54 54 55 55 56 56 /* (non-Javadoc) 57 57 * @see com.sun.fortress.interpreter.evaluator.values.SingleFcn#getDomain() … … 134 134 } 135 135 136 public FnAbsDeclOrDecl getFnDe fOrDecl() {136 public FnAbsDeclOrDecl getFnDeclOrDecl() { 137 137 return fndef; 138 138 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/values/GenericFunctionalMethod.java
r2649 r3077 47 47 // BUG IS HERE, NEED TO instantiate the selfParameterType! ; 48 48 49 FTraitOrObjectOrGeneric instantiatedSelfType = ((FTypeGeneric) selfParameterType).make(args, getFnDe fOrDecl());49 FTraitOrObjectOrGeneric instantiatedSelfType = ((FTypeGeneric) selfParameterType).make(args, getFnDeclOrDecl()); 50 50 51 51 FunctionalMethod cl = FType.anyAreSymbolic(args) ? -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java
r3073 r3077 72 72 import com.sun.fortress.nodes.FieldRef; 73 73 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 74 import com.sun.fortress.nodes.FnDe f;74 import com.sun.fortress.nodes.FnDecl; 75 75 import com.sun.fortress.nodes.FnExpr; 76 76 import com.sun.fortress.nodes.For; … … 602 602 immediateDef = null; 603 603 604 boolean savedFnDe fIsMethod = atTopLevelInsideTraitOrObject;604 boolean savedFnDeclIsMethod = atTopLevelInsideTraitOrObject; 605 605 int savedObjectNestingDepth = objectNestingDepth; 606 606 int savedLexicalNestingDepth = lexicalNestingDepth; … … 627 627 visibleGenericParameters = savedVisibleGenerics; 628 628 usedGenericParameters = savedUsedGenerics; 629 atTopLevelInsideTraitOrObject = savedFnDe fIsMethod;629 atTopLevelInsideTraitOrObject = savedFnDeclIsMethod; 630 630 objectNestingDepth = savedObjectNestingDepth; 631 631 lexicalNestingDepth = savedLexicalNestingDepth; … … 782 782 783 783 @Override 784 public Node forFnDe f(FnDeffndef) {784 public Node forFnDecl(FnDecl fndef) { 785 785 if (atTopLevelInsideTraitOrObject) { 786 786 rewrites_put(WellKnownNames.defaultSelfName, new SelfRewrite()); … … 822 822 823 823 // Remove the original contract, add the translation 824 FnDe f f = new FnDef(fndef.getSpan(), fndef.getMods(),824 FnDecl f = new FnDecl(fndef.getSpan(), fndef.getMods(), 825 825 fndef.getName(), 826 826 fndef.getStaticParams(), fndef.getParams(), … … 855 855 AbstractNode n; 856 856 857 // TODO Contracts, properties, not handled here. See forFnDe ffor details.857 // TODO Contracts, properties, not handled here. See forFnDecl for details. 858 858 859 859 // Strip the contract, we don't know what to do with it, … … 957 957 lexicalNestingDepth++; 958 958 // defined var is no longer eligible for rewrite. 959 List<FnDe f> defs = lf.getFns();959 List<FnDecl> defs = lf.getFns(); 960 960 defsToLocals(defs); 961 961 // All the function names are in scope in the function -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/IsAnArrowName.java
r2798 r3077 19 19 import com.sun.fortress.nodes.AbsFnDecl; 20 20 import com.sun.fortress.nodes.ArrowType; 21 import com.sun.fortress.nodes.FnDe f;21 import com.sun.fortress.nodes.FnDecl; 22 22 import com.sun.fortress.nodes.LValueBind; 23 23 import com.sun.fortress.nodes.Node; … … 62 62 63 63 /* (non-Javadoc) 64 * @see com.sun.fortress.nodes.NodeAbstractVisitor#forFnDe f(com.sun.fortress.nodes.FnDef)64 * @see com.sun.fortress.nodes.NodeAbstractVisitor#forFnDecl(com.sun.fortress.nodes.FnDecl) 65 65 */ 66 66 @Override 67 public ArrowOrFunctional forFnDe f(FnDefthat) {67 public ArrowOrFunctional forFnDecl(FnDecl that) { 68 68 // Return "is a self method" 69 69 return NodeUtil.selfParameterIndex(that) >= 0 ? ArrowOrFunctional.FUNCTIONAL : ArrowOrFunctional.NEITHER; -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java
r3067 r3077 80 80 } 81 81 82 @Override public Boolean forFnDe f(FnDefthat) {82 @Override public Boolean forFnDecl(FnDecl that) { 83 83 return new Boolean(containsPrivate(that.getMods())); 84 84 } … … 173 173 } 174 174 175 public Option<Node> forFnDe f(FnDefthat) {175 public Option<Node> forFnDecl(FnDecl that) { 176 176 if ( ! isPrivate(that) ) { 177 177 if ( that.getReturnType().isNone() ) -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3071 r3077 48 48 return new Span(sl,sl); 49 49 } 50 50 51 51 /** 52 * 52 * 53 53 * @param start 54 54 * @return the span from a node. … … 56 56 return node.getSpan(); 57 57 } 58 58 59 59 /** 60 * 60 * 61 61 * @param start 62 62 * @param finish … … 65 65 return new Span(start.getBegin(), finish.getEnd()); 66 66 } 67 67 68 68 /** 69 * 69 * 70 70 * @param start 71 71 * @param finish … … 75 75 return makeSpan(start.getSpan(), finish.getSpan()); 76 76 } 77 77 78 78 /** 79 * 79 * 80 80 * @param start 81 81 * @param l … … 86 86 return makeSpan(start, s == 0 ? start : l.get(s-1)); 87 87 } 88 88 89 89 /** 90 * 90 * 91 91 * @param start 92 92 * @param l … … 97 97 return makeSpan(s == 0 ? finish : l.get(0), finish); 98 98 } 99 99 100 100 /** 101 * 101 * 102 102 * @param start 103 103 * @param l … … 112 112 * more like a set of spans ought to be used. Even though this is not yet 113 113 * implemented, the name is provided to allow expression of intent. 114 * 114 * 115 115 * @param start 116 116 * @param l … … 124 124 * more like a set of spans ought to be used. Even though this is not yet 125 125 * implemented, the name is provided to allow expression of intent. 126 * 126 * 127 127 * @param start 128 128 * @param l … … 136 136 * more like a set of spans ought to be used. Even though this is not yet 137 137 * implemented, the name is provided to allow expression of intent. 138 * 138 * 139 139 * @param l 140 140 * @return the span encompassing the spans the first and last nodes of the list. … … 143 143 return makeSpan(ifEmpty, l); 144 144 } 145 145 146 146 public static AbsFnDecl makeAbsFnDecl(Span span, List<Modifier> mods, 147 147 Id name, Option<Type> type) { … … 672 672 673 673 /** 674 * Alternatively, you can invoke the FnDe fconstructor without a selfName674 * Alternatively, you can invoke the FnDecl constructor without a selfName 675 675 */ 676 public static FnDe fmakeFnDecl(Span s, List<Modifier> mods,676 public static FnDecl makeFnDecl(Span s, List<Modifier> mods, 677 677 IdOrOpOrAnonymousName name, 678 678 List<StaticParam> staticParams, … … 683 683 Option<Contract> contract, 684 684 Expr body) { 685 return new FnDe f(s, mods, name, staticParams, params, returnType,685 return new FnDecl(s, mods, name, staticParams, params, returnType, 686 686 throwss, where, contract, body); 687 687 } 688 688 689 public static FnDe f makeFnDef(Span span, List<Modifier> mods,689 public static FnDecl makeFnDecl(Span span, List<Modifier> mods, 690 690 Id name, Option<Type> type, Expr body) { 691 return makeFnDe f(span, mods, name, Collections.<Param>emptyList(), type,691 return makeFnDecl(span, mods, name, Collections.<Param>emptyList(), type, 692 692 body); 693 693 } 694 694 695 public static FnDe f makeFnDef(Span span, List<Modifier> mods,695 public static FnDecl makeFnDecl(Span span, List<Modifier> mods, 696 696 Id name, List<Param> params, 697 697 Option<Type> type, Expr body) { 698 return new FnDe f(span, mods, name, Collections.<StaticParam>emptyList(),698 return new FnDecl(span, mods, name, Collections.<StaticParam>emptyList(), 699 699 params, type, Option.<List<BaseType>>none(), 700 700 Option.<WhereClause>none(), Option.<Contract>none(), -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java
r3073 r3077 150 150 151 151 public static Option<Expr> getBody(Applicable def) { 152 if (def instanceof FnDe f) { return Option.some(((FnDef)def).getBody()); }152 if (def instanceof FnDecl) { return Option.some(((FnDecl)def).getBody()); } 153 153 else if (def instanceof FnExpr) { return Option.some(((FnExpr)def).getBody()); } 154 154 else { return Option.none(); } -
trunk/ProjectFortress/src/com/sun/fortress/parser/LocalDecl.rats
r3016 r3077 75 75 private LetExpr LocalVarFnDecl = 76 76 a1:LocalFnDecl a2s:(br LocalFnDecl)* 77 { List<FnDe f> fns = FortressUtil.mkList(a1, a2s.list());77 { List<FnDecl> fns = FortressUtil.mkList(a1, a2s.list()); 78 78 yyValue = new LetFn(createSpan(yyStart,yyCount), false, 79 79 FortressUtil.emptyExprs(), fns); … … 82 82 83 83 /* LocalFnDecl ::= Mods? NamedFnHeaderFront FnHeaderClause w = w NoNewlineExpr */ 84 private FnDe fLocalFnDecl =84 private FnDecl LocalFnDecl = 85 85 a1:Mods? a2:NamedFnHeaderFront a3:FnHeaderClause w equals w a4:NoNewlineExpr 86 86 { if (a1 == null) a1 = FortressUtil.emptyModifiers(); -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/FortressUtil.java
r3071 r3077 92 92 93 93 private static Effect effect = new Effect(NodeFactory.makeSpan("singleton")); 94 94 95 95 public static Effect emptyEffect() { 96 96 return effect; … … 618 618 } 619 619 620 public static FnDe fmkFnDecl(Span span, List<Modifier> mods,620 public static FnDecl mkFnDecl(Span span, List<Modifier> mods, 621 621 FnHeaderFront fhf, 622 622 FnHeaderClause fhc, Expr expr) { … … 630 630 } 631 631 632 public static FnDe fmkFnDecl(Span span, List<Modifier> mods, IdOrOpOrAnonymousName name,632 public static FnDecl mkFnDecl(Span span, List<Modifier> mods, IdOrOpOrAnonymousName name, 633 633 List<StaticParam> sparams, List<Param> params, 634 634 FnHeaderClause fhc, Expr expr) { -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java
r3072 r3077 243 243 } 244 244 245 public void forFnDe fOnly(FnDefthat) {245 public void forFnDeclOnly(FnDecl that) { 246 246 if ( NodeUtil.isGetter(that) ) { 247 247 if ( ! that.getParams().isEmpty() ) -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/Transform.java
r3071 r3077 128 128 * LValueBind ( only for LocalVarDecl ) - done 129 129 * UnpastingBind ( only for LocalVarDecl ) - done 130 * FnDe f( only for local function decls ) - done130 * FnDecl ( only for local function decls ) - done 131 131 * NormalParam ( only for FnExpr and local function decls ) - done 132 132 * VarargsParam ( only for FnExpr and local function decls ) - done … … 138 138 * For - done 139 139 * While - done 140 * Accumulator - 141 * GeneratedExpr 142 * ArrayComprehensionClause 140 * Accumulator - 141 * GeneratedExpr 142 * ArrayComprehensionClause 143 143 * IfClause - done 144 144 */ … … 336 336 Option<Type> exprType_result = recurOnOptionOfType(that.getExprType()); 337 337 List<Expr> body_result = recurOnListOfExpr(that.getBody()); 338 List<FnDe f> fns_result = Useful.applyToAll(that.getFns(), new Fn<FnDef, FnDef>(){339 public FnDe f apply(FnDeffn){340 return (FnDe f) fn.accept( new TemplateUpdateVisitor(){341 public Node forFnDe fOnly(FnDefthat, List<Modifier> mods_result, IdOrOpOrAnonymousName name_result, List<StaticParam> staticParams_result, List<Param> params_result, Option<Type> returnType_result, Option<List<BaseType>> throwsClause_result, Option<WhereClause> where_result, Option<Contract> contract_result, Expr body_result) {338 List<FnDecl> fns_result = Useful.applyToAll(that.getFns(), new Fn<FnDecl, FnDecl>(){ 339 public FnDecl apply(FnDecl fn){ 340 return (FnDecl) fn.accept( new TemplateUpdateVisitor(){ 341 public Node forFnDeclOnly(FnDecl that, List<Modifier> mods_result, IdOrOpOrAnonymousName name_result, List<StaticParam> staticParams_result, List<Param> params_result, Option<Type> returnType_result, Option<List<BaseType>> throwsClause_result, Option<WhereClause> where_result, Option<Contract> contract_result, Expr body_result) { 342 342 List<Param> new_params_result = Useful.applyToAll(params_result, renameParam); 343 343 if ( name_result instanceof Id) { … … 345 345 Id generatedId = generateId(old); 346 346 extendSyntaxEnvironment(old, generatedId); 347 return new FnDe f(that.getSpan(), mods_result, generatedId, staticParams_result, new_params_result, returnType_result, throwsClause_result, where_result, contract_result, body_result);347 return new FnDecl(that.getSpan(), mods_result, generatedId, staticParams_result, new_params_result, returnType_result, throwsClause_result, where_result, contract_result, body_result); 348 348 } else { 349 return new FnDe f(that.getSpan(), mods_result, name_result, staticParams_result,349 return new FnDecl(that.getSpan(), mods_result, name_result, staticParams_result, 350 350 new_params_result, returnType_result, throwsClause_result, 351 351 where_result, contract_result, body_result); -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r3074 r3077 778 778 779 779 780 @Override public String forFnDe fOnly(FnDefthat,780 @Override public String forFnDeclOnly(FnDecl that, 781 781 List<String> mods_result, 782 782 final String name_result, -
trunk/ProjectFortress/static_tests/syntax_abstraction/transformer/SyntaxExtends.fsi
r2957 r3077 24 24 grammar A extends { Declaration, D } 25 25 Decl |List[\Decl\]:= 26 some Thing 26 some Thing 27 27 do 28 fnDef : FnDe f = FnDef(emptyList[\Modifier\](),28 fnDef : FnDecl = FnDecl(emptyList[\Modifier\](), 29 29 Id(Nothing[\APIName\], "some" Thing.in_text), 30 30 emptyList[\StaticParam\](), … … 36 36 "foo", 37 37 StringLiteralExpr("some " Thing.in_text)) 38 ls : List[\FnDe f\] = emptyList[\FnDef\](1)38 ls : List[\FnDecl\] = emptyList[\FnDecl\](1) 39 39 ls.addRight(fnDef) 40 40 end … … 63 63 thingC1 <[ thingC1 ]> 64 64 65 Gnu :Expr:= 65 Gnu :Expr:= 66 66 Thing do Thing.in_text end 67 67 -
trunk/ProjectFortress/tests/objectCC_staticParams.fss
r2999 r3077 64 64 end 65 65 66 (* Nested FnDe fs within the object decl which declares more static params *)67 (* Local functions with generatics are not supported at the moment; 66 (* Nested FnDecls within the object decl which declares more static params *) 67 (* Local functions with generatics are not supported at the moment; 68 68 remove the comments when they are. 69 69 object O3[\X extends String, S extends String\](x:X, s:S) … … 75 75 end *) 76 76 77 (* Nested FnDe fs within the object decl which declares more static params *)78 (* Local functions with generatics are not supported at the moment; 77 (* Nested FnDecls within the object decl which declares more static params *) 78 (* Local functions with generatics are not supported at the moment; 79 79 remove the comments when they are. 80 80 object O4[\X extends String, S extends String\](x:X, s:S) … … 98 98 assert( o1.s, t.a(), "t.a() failed." ) 99 99 100 (* Local functions with generatics are not supported at the moment; 100 (* Local functions with generatics are not supported at the moment; 101 101 remove the comments when they are. 102 102

