Changeset 3082
- Timestamp:
- 11/19/08 08:38:20 (12 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 39 modified
-
astgen/Fortress.ast (modified) (2 diffs)
-
src/com/sun/fortress/compiler/IndexBuilder.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java (modified) (7 diffs)
-
src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/desugarer/MutableVarRefRewriteVisitor.java (modified) (13 diffs)
-
src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/desugarer/VarRefContainer.java (modified) (5 diffs)
-
src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java (modified) (3 diffs)
-
src/com/sun/fortress/compiler/environments/TopLevelEnvGen.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/index/DeclaredVariable.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java (modified) (2 diffs)
-
src/com/sun/fortress/compiler/typechecker/LValueTypeEnv.java (modified) (7 diffs)
-
src/com/sun/fortress/compiler/typechecker/LocalVarTypeEnv.java (modified) (4 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (22 diffs)
-
src/com/sun/fortress/compiler/typechecker/TypeEnv.java (modified) (5 diffs)
-
src/com/sun/fortress/interpreter/Driver.java (modified) (1 diff)
-
src/com/sun/fortress/interpreter/evaluator/BuildApiEnvironment.java (modified) (9 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java (modified) (5 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BuildLetEnvironments.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/BuildTraitEnvironment.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/Evaluator.java (modified) (4 diffs)
-
src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java (modified) (5 diffs)
-
src/com/sun/fortress/interpreter/evaluator/LHSToLValue.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/evaluator/types/FTypeObject.java (modified) (2 diffs)
-
src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java (modified) (8 diffs)
-
src/com/sun/fortress/interpreter/rewrite/IsAnArrowName.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/ApiMaker.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/ErrorMsgMaker.java (modified) (1 diff)
-
src/com/sun/fortress/nodes_util/ExprFactory.java (modified) (2 diffs)
-
src/com/sun/fortress/nodes_util/NodeFactory.java (modified) (9 diffs)
-
src/com/sun/fortress/nodes_util/NodeUtil.java (modified) (1 diff)
-
src/com/sun/fortress/parser/AbsField.rats (modified) (2 diffs)
-
src/com/sun/fortress/parser/LocalDecl.rats (modified) (6 diffs)
-
src/com/sun/fortress/parser/NoNewlineExpr.rats (modified) (2 diffs)
-
src/com/sun/fortress/parser/Variable.rats (modified) (7 diffs)
-
src/com/sun/fortress/parser_util/FortressUtil.java (modified) (18 diffs)
-
src/com/sun/fortress/parser_util/SyntaxChecker.java (modified) (1 diff)
-
src/com/sun/fortress/syntax_abstractions/phases/Transform.java (modified) (2 diffs)
-
src/com/sun/fortress/tools/FortressAstToConcrete.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/astgen/Fortress.ast
r3081 r3082 349 349 * variable declaration in components or APIs 350 350 */ 351 abstract VarAbsDeclOrDecl(List<LValue Bind> lhs) implements AbsDeclOrDecl;351 abstract VarAbsDeclOrDecl(List<LValue> lhs) implements AbsDeclOrDecl; 352 352 /** 353 353 * variable declaration in APIs … … 375 375 /** 376 376 * left-hand side of variable declaration 377 */ 378 abstract LValue(); 379 /** 380 * e.g.) var x: ZZ32 381 * Name must be unqualified. 382 */ 383 LValueBind(Id name, Option<Type> type = Option.<Type>none(), 384 List<Modifier> mods = Collections.<Modifier>emptyList(), 385 boolean mutable = false) implements Lhs, ImplicitGetterSetter; 386 /** 387 * left-hand side of matrix unpasting 388 * Unpasting ::= [ UnpastingElems ] 389 */ 390 abstract Unpasting(); 391 /** 392 * simple unpasting 393 * Names must be unqualified. 394 * UnpastingElem ::= BindId ([ UnpastingDim ])? 395 * | Unpasting 396 * UnpastingDim ::= ExtentRange (BY ExtentRange)+ 397 * e.g.) squareShape[m BY m] 398 */ 399 UnpastingBind(Id name, List<ExtentRange> dim); 400 /** 401 * complex unpasting 402 * UnpastingElems ::= UnpastingElem RectSeparator UnpastingElems 403 * | UnpastingElem 404 * e.g.) squareShape[m BY m] rest 405 */ 406 UnpastingSplit(List<Unpasting> elems, int dim); 377 * e.g.) var x: ZZ32 378 * Name must be unqualified. 379 */ 380 LValue(Id name, Option<Type> type = Option.<Type>none(), 381 List<Modifier> mods = Collections.<Modifier>emptyList(), 382 boolean mutable = false) implements Lhs, ImplicitGetterSetter; 407 383 /** 408 384 * Overloading specification -
trunk/ProjectFortress/src/com/sun/fortress/compiler/IndexBuilder.java
r3076 r3082 387 387 private void buildVariables(VarAbsDeclOrDecl ast, 388 388 Map<Id, Variable> variables) { 389 for (LValue Bindb : ast.getLhs()) {389 for (LValue b : ast.getLhs()) { 390 390 variables.put(b.getName(), new DeclaredVariable(b)); 391 391 } … … 400 400 Map<Id, Method> getters, 401 401 Map<Id, Method> setters) { 402 for (LValue Bindb : ast.getLhs()) {402 for (LValue b : ast.getLhs()) { 403 403 ModifierSet mods = extractModifiers(b.getMods()); 404 404 // TODO: check for correct modifiers? … … 422 422 Map<Id, Method> getters, 423 423 Map<Id, Method> setters) { 424 for (LValue Bindb : ast.getLhs()) {424 for (LValue b : ast.getLhs()) { 425 425 ModifierSet mods = extractModifiers(b.getMods()); 426 426 // TODO: check for correct modifiers? -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/DesugaringVisitor.java
r3077 r3082 97 97 98 98 private boolean mutable(ImplicitGetterSetter field) { 99 if ( field instanceof LValue Bind)100 return ((LValue Bind)field).isMutable();99 if ( field instanceof LValue ) 100 return ((LValue)field).isMutable(); 101 101 102 102 for (Modifier mod : field.getMods()) { … … 179 179 for (Decl decl: decls) { 180 180 if (decl instanceof VarAbsDeclOrDecl) { 181 for (LValue Bindbinding : (((VarAbsDeclOrDecl)decl).getLhs())) {181 for (LValue binding : (((VarAbsDeclOrDecl)decl).getLhs())) { 182 182 newScope.add(binding.getName()); 183 183 } … … 197 197 for (Decl decl: decls) { 198 198 if (decl instanceof VarAbsDeclOrDecl) { 199 for (LValue Bindbinding : (((VarAbsDeclOrDecl)decl).getLhs())) {199 for (LValue binding : (((VarAbsDeclOrDecl)decl).getLhs())) { 200 200 newScope.add(binding.getName()); 201 201 } … … 331 331 decl.accept(new NodeAbstractVisitor_void() { 332 332 public void forVarAbsDeclOrDecl(VarAbsDeclOrDecl decl) { 333 for (LValue Bindbinding : decl.getLhs()) {333 for (LValue binding : decl.getLhs()) { 334 334 if (! hidden(binding) && 335 335 ! hasExplicitGetter(binding.getName(), decls)) { … … 355 355 decl.accept(new NodeAbstractVisitor_void() { 356 356 public void forVarAbsDeclOrDecl(VarAbsDeclOrDecl dec) { 357 for (LValue Bindbinding : dec.getLhs()) {357 for (LValue binding : dec.getLhs()) { 358 358 if (! hidden(binding) && 359 359 ! hasExplicitGetter(binding.getName(), decls)) { … … 374 374 return new NodeUpdateVisitor() { 375 375 public Node forVarDecl(VarDecl that) { 376 List<LValue Bind> newLVals = new ArrayList<LValueBind>();377 378 for (LValue Bindlval : that.getLhs()) {376 List<LValue> newLVals = new ArrayList<LValue>(); 377 378 for (LValue lval : that.getLhs()) { 379 379 // System.err.println(mangleName(lval.getName())); 380 380 newLVals.add(NodeFactory.makeLValue(lval, mangleName(lval.getName()))); … … 383 383 } 384 384 public Node forAbsVarDecl(AbsVarDecl that) { 385 List<LValue Bind> newLVals = new ArrayList<LValueBind>();386 387 for (LValue Bindlval : that.getLhs()) {385 List<LValue> newLVals = new ArrayList<LValue>(); 386 387 for (LValue lval : that.getLhs()) { 388 388 newLVals.add(NodeFactory.makeLValue(lval, mangleName(lval.getName()))); 389 389 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/FreeNameCollector.java
r3077 r3082 70 70 * pair.first is the VarRef 71 71 * pair.second is the decl node where the VarRef is declared 72 * (which is either a Param, LValue Bind, or LocalVarDecl)72 * (which is either a Param, LValue, or LocalVarDecl) 73 73 * 74 74 * IMPORTANT: Need to use Pair of String & Span as key! … … 286 286 declSite = declNode; 287 287 } else if( declNode instanceof Param || 288 declNode instanceof LValue Bind) {288 declNode instanceof LValue ) { 289 289 if( enclosingObjectDecl.isNone() ) { 290 290 throw new DesugarerError( var.getSpan(), … … 666 666 List<LValue> lhs = cast.getLhs(); 667 667 for(LValue lvalue : lhs) { 668 if ( lvalue instanceof LValueBind ) 669 name += ( "_" + ((LValueBind) lvalue).getName().getText() ); 670 else // lvalue instanceof Unpasting 671 throw new DesugarerError("Unpasting is not yet supported."); 668 name += ( "_" + lvalue.getName().getText() ); 672 669 } 673 670 return new Pair<String,Span>( name, cast.getSpan() ); … … 991 988 @Override 992 989 public void forVarDecl(VarDecl that) { 993 recurOnListOfLValue Bind(that.getLhs());990 recurOnListOfLValue(that.getLhs()); 994 991 } 995 992 996 993 @Override 997 public void forLValue Bind(LValueBindthat) {994 public void forLValue(LValue that) { 998 995 decledNames.add(that.getName()); 999 996 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/MutableVarRefRewriteVisitor.java
r2714 r3082 26 26 import com.sun.fortress.nodes.Expr; 27 27 import com.sun.fortress.nodes.FieldRef; 28 import com.sun.fortress.nodes.LValue Bind;28 import com.sun.fortress.nodes.LValue; 29 29 import com.sun.fortress.nodes.LocalVarDecl; 30 30 import com.sun.fortress.nodes.Node; … … 39 39 40 40 public class MutableVarRefRewriteVisitor extends NodeUpdateVisitor { 41 // The root of the subtree in AST which we are trying to rewrite 41 // The root of the subtree in AST which we are trying to rewrite 42 42 // This root can only be either ObjectDecl or LocalVarDecl, which can 43 43 // declare mutable variables captured by ObjectExpr … … 45 45 // A map mapping from VarRefs to its corresponding boxed type 46 46 private Map<VarRef, VarRefContainer> mutableVarRefContainerMap; 47 // A list of varRefs that are declared directly under entryNode and 48 // need to be rewriten into its corresponding boxed type; note that 49 // mutableVarRefContainerMap.keySet() is a superset of varRefsToRewrite 47 // A list of varRefs that are declared directly under entryNode and 48 // need to be rewriten into its corresponding boxed type; note that 49 // mutableVarRefContainerMap.keySet() is a superset of varRefsToRewrite 50 50 private List<VarRef> varRefsToRewrite; 51 51 52 public MutableVarRefRewriteVisitor(Node entryNode, 52 public MutableVarRefRewriteVisitor(Node entryNode, 53 53 Map<VarRef, VarRefContainer> mutableVarRefContainerMap, 54 54 List<VarRef> varRefsToRewrite) { … … 60 60 @Override 61 61 public Node forObjectDecl(ObjectDecl that) { 62 if( entryNode instanceof ObjectDecl && 63 (that.equals(entryNode) == false || 62 if( entryNode instanceof ObjectDecl && 63 (that.equals(entryNode) == false || 64 64 entryNode.getSpan().equals(that.getSpan()) == false) ) { 65 65 throw new DesugarerError("Wrong entry node for the rewriting " + 66 "pass! Expected: " + entryNode + " (" + entryNode.getSpan() + 66 "pass! Expected: " + entryNode + " (" + entryNode.getSpan() + 67 67 "); " + "found: " + that + " (" + that.getSpan() + ")."); 68 68 } 69 69 70 70 List<Decl> decls_result = recurOnListOfDecl( that.getDecls() ); 71 71 … … 73 73 VarRefContainer container = mutableVarRefContainerMap.get(var); 74 74 if( container == null ) { 75 throw new DesugarerError(var.getSpan(), 76 "VarRefContainer for " + var + 75 throw new DesugarerError(var.getSpan(), 76 "VarRefContainer for " + var + 77 77 " is not found in map while rewriting " + that); 78 78 } … … 81 81 if( origDeclNode instanceof Param ) { 82 82 decls_result.add( 0, container.containerField() ); 83 } else if( origDeclNode instanceof LValue Bind) {83 } else if( origDeclNode instanceof LValue ) { 84 84 insertAfterOrigDecl(decls_result, container); 85 85 } else { … … 102 102 return super.forLocalVarDecl(that); 103 103 } 104 104 105 105 LocalVarDecl newLocalVarDecl = null; 106 106 List<Expr> body_result = recurOnListOfExpr( that.getBody() ); … … 109 109 VarRefContainer container = mutableVarRefContainerMap.get(var); 110 110 if( container == null ) { 111 throw new DesugarerError(var.getSpan(), 112 "VarRefContainer for " + var + 111 throw new DesugarerError(var.getSpan(), 112 "VarRefContainer for " + var + 113 113 " is not found in map while rewriting " + that); 114 114 } 115 115 116 // Why does this sanity check fail? 116 // Why does this sanity check fail? 117 117 // It fails because this LocalVarDecl may have been rewritten if it refers 118 118 // to any var declared in ObjectDecl which is also captured by the object … … 121 121 // Node origDeclNode = container.origDeclNode(); 122 122 // if( origDeclNode.equals(that) == false ) { 123 // throw new DesugarerError(that.getSpan(), 123 // throw new DesugarerError(that.getSpan(), 124 124 // "Unexpected node in rewriteList when rewriting " + that); 125 125 // } else { 126 126 if( newLocalVarDecl == null ) { 127 newLocalVarDecl = 127 newLocalVarDecl = 128 128 container.containerLocalVarDecl(body_result); 129 129 } else { 130 130 List<Expr> newBody = new ArrayList<Expr>(1); 131 131 newBody.add(newLocalVarDecl); 132 newLocalVarDecl = 132 newLocalVarDecl = 133 133 container.containerLocalVarDecl(newBody); 134 134 } … … 139 139 new_body_result.add(newLocalVarDecl); 140 140 141 return super.forLocalVarDeclOnly( that, that.getExprType(), 141 return super.forLocalVarDeclOnly( that, that.getExprType(), 142 142 new_body_result, that.getLhs(), that.getRhs() ); 143 143 } 144 144 145 @Override 145 @Override 146 146 public Node forVarRef(VarRef that) { 147 147 if( varRefsToRewrite.contains(that) ) { … … 152 152 } 153 153 } 154 155 private void insertAfterOrigDecl(List<Decl> decl_result, 154 155 private void insertAfterOrigDecl(List<Decl> decl_result, 156 156 VarRefContainer container) { 157 157 int indexToInsert = 0; … … 159 159 indexToInsert = indexToInsert + 1; 160 160 if(decl instanceof VarDecl) { 161 VarDecl cast = (VarDecl) decl; 162 List<LValue Bind> lhs = cast.getLhs();161 VarDecl cast = (VarDecl) decl; 162 List<LValue> lhs = cast.getLhs(); 163 163 if( lhs.contains(container.origDeclNode()) ) { 164 164 decl_result.add(indexToInsert, container.containerField()); … … 176 176 177 177 } 178 179 -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/ObjectExpressionVisitor.java
r3078 r3082 85 85 * pair.first is the varRef 86 86 * pair.second is the decl node where the varRef is declared 87 * (which is either a Param, LValue Bind, or LocalVarDecl)87 * (which is either a Param, LValue, or LocalVarDecl) 88 88 * 89 89 * IMPORTANT: Need to use Pair of String & Span as key! -
trunk/ProjectFortress/src/com/sun/fortress/compiler/desugarer/VarRefContainer.java
r2714 r3082 27 27 import com.sun.fortress.nodes.Id; 28 28 import com.sun.fortress.nodes.LValue; 29 import com.sun.fortress.nodes.LValueBind;30 29 import com.sun.fortress.nodes.LocalVarDecl; 31 30 import com.sun.fortress.nodes.Modifier; … … 59 58 60 59 public VarRefContainer(VarRef origVar, 61 Node origDeclNode, 60 Node origDeclNode, 62 61 String uniqueSuffix) { 63 62 this.origVar = origVar; … … 113 112 114 113 public VarDecl containerField() { 115 List<LValue Bind> lhs = new LinkedList<LValueBind>();114 List<LValue> lhs = new LinkedList<LValue>(); 116 115 // set the field to be immutable 117 lhs.add( new LValue Bind(origDeclNode.getSpan(), containerVarId(),118 containerType(), false) );116 lhs.add( new LValue(origDeclNode.getSpan(), containerVarId(), 117 containerType(), false) ); 119 118 VarDecl field = new VarDecl( origDeclNode.getSpan(), 120 119 lhs, makeCallToContainerObj() ); … … 131 130 public FieldRef containerFieldRef(Span varRefSpan) { 132 131 return ExprFactory.makeFieldRef( varRefSpan, 133 this.containerVarRef(varRefSpan), 132 this.containerVarRef(varRefSpan), 134 133 origVar.getVar() ); 135 134 } … … 138 137 List<LValue> lhs = new LinkedList<LValue>(); 139 138 // set the field to be immutable 140 lhs.add( new LValue Bind(origDeclNode.getSpan(), containerVarId(),141 containerType(), false) );139 lhs.add( new LValue(origDeclNode.getSpan(), containerVarId(), 140 containerType(), false) ); 142 141 LocalVarDecl ret = ExprFactory.makeLocalVarDecl( origDeclNode.getSpan(), 143 142 lhs, makeCallToContainerObj(), bodyExprs ); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/disambiguator/ExprDisambiguator.java
r3077 r3082 59 59 import com.sun.fortress.nodes.IntParam; 60 60 import com.sun.fortress.nodes.LValue; 61 import com.sun.fortress.nodes.LValueBind;62 61 import com.sun.fortress.nodes.Label; 63 62 import com.sun.fortress.nodes.LetFn; … … 87 86 import com.sun.fortress.nodes.UnitDecl; 88 87 import com.sun.fortress.nodes.UnitParam; 89 import com.sun.fortress.nodes.UnpastingBind;90 import com.sun.fortress.nodes.UnpastingSplit;91 88 import com.sun.fortress.nodes.VarDecl; 92 89 import com.sun.fortress.nodes.VarRef; … … 354 351 for (LValue lv : lvalues) { 355 352 boolean valid = true; 356 if (lv instanceof LValueBind) { 357 Id id = ((LValueBind)lv).getName(); 358 valid = (result.add(id) || id.getText().equals("_")); 359 } 360 else if (lv instanceof UnpastingBind) { 361 Id id = ((UnpastingBind)lv).getName(); 362 valid = (result.add(id) || id.getText().equals("_")); 363 } 364 else { // lv instanceof UnpastingSplit 365 extractDefinedVarNames(((UnpastingSplit)lv).getElems(), result); 366 } 353 Id id = lv.getName(); 354 valid = (result.add(id) || id.getText().equals("_")); 367 355 if (!valid) { error("Duplicate local variable name", lv); } 368 356 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/environments/TopLevelEnvGen.java
r3078 r3082 275 275 if (v instanceof DeclaredVariable) { 276 276 DeclaredVariable dv = (DeclaredVariable) v; 277 LValue Bindlvb = dv.ast();277 LValue lvb = dv.ast(); 278 278 idString = WellKnownNames.tempForUnderscore(lvb.getName()); 279 279 } else { … … 346 346 // The interpreter rewrites a temporary for multiple assignment. 347 347 VarDecl vd = (VarDecl) decl; 348 List<LValue Bind> lhs = vd.getLhs();348 List<LValue> lhs = vd.getLhs(); 349 349 if (lhs.size() > 1) { 350 350 String idString = WellKnownNames.tempTupleName(vd); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/index/DeclaredVariable.java
r1083 r3082 18 18 package com.sun.fortress.compiler.index; 19 19 20 import com.sun.fortress.nodes.LValue Bind;20 import com.sun.fortress.nodes.LValue; 21 21 22 22 public class DeclaredVariable extends Variable { 23 24 private final LValue Bind_ast;25 26 public DeclaredVariable(LValue Bindast) { _ast = ast; }27 28 public LValue Bindast() { return _ast; }23 24 private final LValue _ast; 25 26 public DeclaredVariable(LValue ast) { _ast = ast; } 27 28 public LValue ast() { return _ast; } 29 29 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/InferenceVarInserter.java
r3077 r3082 26 26 import com.sun.fortress.nodes.Id; 27 27 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 28 import com.sun.fortress.nodes.LValue Bind;28 import com.sun.fortress.nodes.LValue; 29 29 import com.sun.fortress.nodes.Modifier; 30 30 import com.sun.fortress.nodes.Node; … … 48 48 49 49 @Override 50 public Node forLValue BindOnly(LValueBindthat, Id name_result,50 public Node forLValueOnly(LValue that, Id name_result, 51 51 Option<Type> type_result, List<Modifier> mods_result) { 52 52 if( type_result.isNone() ) { 53 53 Option<Type> new_type = Option.<Type>some(NodeFactory.make_InferenceVarType(that.getName().getSpan())); 54 return new LValue Bind(that.getSpan(),name_result,new_type,mods_result,that.isMutable());54 return new LValue(that.getSpan(),name_result,new_type,mods_result,that.isMutable()); 55 55 } 56 56 else { -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/LValueTypeEnv.java
r2466 r3082 26 26 27 27 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 28 import com.sun.fortress.nodes.LValue Bind;28 import com.sun.fortress.nodes.LValue; 29 29 import com.sun.fortress.nodes.Node; 30 30 import com.sun.fortress.nodes.StaticParam; … … 35 35 36 36 class LValueTypeEnv extends TypeEnv { 37 private final LValue Bind[] entries;37 private final LValue[] entries; 38 38 private final TypeEnv parent; 39 40 LValueTypeEnv(LValue Bind[] _entries, TypeEnv _parent) {39 40 LValueTypeEnv(LValue[] _entries, TypeEnv _parent) { 41 41 entries = _entries; 42 42 parent = _parent; 43 43 } 44 44 45 LValueTypeEnv(List<LValue Bind> _entries, TypeEnv _parent) {46 entries = _entries.toArray(new LValue Bind[_entries.size()]);45 LValueTypeEnv(List<LValue> _entries, TypeEnv _parent) { 46 entries = _entries.toArray(new LValue[_entries.size()]); 47 47 parent = _parent; 48 48 } 49 49 50 private Option<LValue Bind> findLVal(IdOrOpOrAnonymousName var) {50 private Option<LValue> findLVal(IdOrOpOrAnonymousName var) { 51 51 IdOrOpOrAnonymousName no_api_var = removeApi(var); 52 53 for (LValue Bindentry : entries) {52 53 for (LValue entry : entries) { 54 54 if (var.equals(entry.getName()) || no_api_var.equals(entry.getName())) { 55 55 return some(entry); … … 58 58 return none(); 59 59 } 60 60 61 61 /** 62 62 * Return a BindingLookup that binds the given IdOrOpOrAnonymousName to a type … … 64 64 */ 65 65 public Option<BindingLookup> binding(IdOrOpOrAnonymousName var) { 66 Option<LValue Bind> lval = findLVal(var);67 66 Option<LValue> lval = findLVal(var); 67 68 68 if( lval.isSome() ) 69 69 return some(new BindingLookup(lval.unwrap())); … … 75 75 public List<BindingLookup> contents() { 76 76 List<BindingLookup> result = new ArrayList<BindingLookup>(); 77 for (LValue Bindentry : entries) {77 for (LValue entry : entries) { 78 78 result.add(new BindingLookup(entry)); 79 79 } … … 84 84 @Override 85 85 public Option<Node> declarationSite(IdOrOpOrAnonymousName var) { 86 Option<LValue Bind> lval = findLVal(var);86 Option<LValue> lval = findLVal(var); 87 87 88 88 if( lval.isSome() ) … … 94 94 @Override 95 95 public TypeEnv replaceAllIVars(Map<_InferenceVarType, Type> ivars) { 96 LValue Bind[] new_entries = new LValueBind[entries.length];97 96 LValue[] new_entries = new LValue[entries.length]; 97 98 98 InferenceVarReplacer rep = new InferenceVarReplacer(ivars); 99 99 100 100 for( int i = 0; i<entries.length; i++ ) { 101 new_entries[i] = (LValue Bind)entries[i].accept(rep);101 new_entries[i] = (LValue)entries[i].accept(rep); 102 102 } 103 103 104 104 return new LValueTypeEnv(new_entries, parent.replaceAllIVars(ivars)); 105 105 } -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/LocalVarTypeEnv.java
r2466 r3082 42 42 } 43 43 44 private Option<LValue Bind> findLVal(IdOrOpOrAnonymousName var) {44 private Option<LValue> findLVal(IdOrOpOrAnonymousName var) { 45 45 IdOrOpOrAnonymousName no_api_var = removeApi(var); 46 46 47 47 for (LValue lval : decl.getLhs()) { 48 if (lval instanceof LValueBind) { 49 LValueBind _lval = (LValueBind) lval; 50 if (_lval.getName().equals(var) || _lval.getName().equals(no_api_var)) { 51 return some(_lval); 52 } 53 } else { 54 return NI.nyi(); 55 } 48 if (lval.getName().equals(var) || lval.getName().equals(no_api_var)) { 49 return some(lval); 50 } 56 51 } 57 52 return none(); 58 53 } 59 54 60 55 /** 61 56 * Return a BindingLookup that binds the given IdOrOpOrAnonymousName to a type … … 63 58 */ 64 59 public Option<BindingLookup> binding(IdOrOpOrAnonymousName var) { 65 Option<LValue Bind> lval = findLVal(var);66 60 Option<LValue> lval = findLVal(var); 61 67 62 if(lval.isSome()) 68 63 return some(new BindingLookup(lval.unwrap())); … … 75 70 List<BindingLookup> result = new ArrayList<BindingLookup>(); 76 71 for (LValue lval : decl.getLhs()) { 77 if (lval instanceof LValueBind) { 78 result.add(new BindingLookup((LValueBind) lval)); 79 } else { 80 return NI.nyi(); 81 } 72 result.add(new BindingLookup( lval)); 82 73 } 83 74 result.addAll(parent.contents()); … … 87 78 @Override 88 79 public Option<Node> declarationSite(IdOrOpOrAnonymousName var) { 89 Option<LValue Bind> lval = findLVal(var);90 80 Option<LValue> lval = findLVal(var); 81 91 82 if(lval.isSome()) 92 83 return Option.<Node>some(decl); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3078 r3082 132 132 } 133 133 static private Type getTypeOfLValue(LValue lval) { 134 // TODO Implement unpasting 135 return 136 lval.accept(new NodeDepthFirstVisitor<Type>(){ 137 @Override 138 public Type forLValueBind(LValueBind that) { 139 // All types must exist by the typechecker 140 return that.getType().unwrap(); 141 } 142 }); 134 return lval.getType().unwrap(); 143 135 } 144 136 private static boolean isExprMI(MathItem item) { … … 156 148 } 157 149 158 private static Type typeFromLValue Binds(List<LValueBind> bindings) {150 private static Type typeFromLValues(List<LValue> bindings) { 159 151 List<Type> results = new ArrayList<Type>(); 160 152 161 for (LValue Bindbinding: bindings) {153 for (LValue binding: bindings) { 162 154 if (binding.getType().isSome()) { 163 155 results.add(binding.getType().unwrap()); … … 460 452 } 461 453 462 private TypeChecker extend(List<LValue Bind> bindings) {454 private TypeChecker extend(List<LValue> bindings) { 463 455 return new TypeChecker(table, 464 456 typeEnv.extendWithLValues(bindings), … … 631 623 else if( field instanceof DeclaredVariable ) { 632 624 DeclaredVariable var = (DeclaredVariable)field; 633 LValue Bindbind = var.ast();625 LValue bind = var.ast(); 634 626 return Option.some(bind.getType().unwrap()); 635 627 } … … 1418 1410 } 1419 1411 1420 @Override public Pair<TypeCheckerResult, Type> forLValue Bind(LValueBindthat) {1412 @Override public Pair<TypeCheckerResult, Type> forLValue(LValue that) { 1421 1413 if( !that.isMutable() ) { 1422 1414 String err = "Left-hand side of assignment must be mutable."; … … 1963 1955 1964 1956 // bind id and check the body 1965 LValue Bindlval = NodeFactory.makeLValue(id_to_bind, that.getMatch());1957 LValue lval = NodeFactory.makeLValue(id_to_bind, that.getMatch()); 1966 1958 TypeChecker extend_tc = this.extend(Collections.singletonList(lval)); 1967 1959 TypeCheckerResult body_result = that.getBody().accept(extend_tc); … … 2573 2565 @Override 2574 2566 public TypeCheckerResult forFor(For that) { 2575 Pair<List<TypeCheckerResult>,List<LValue Bind>> pair = recurOnListsOfGeneratorClauseBindings(that.getGens());2567 Pair<List<TypeCheckerResult>,List<LValue>> pair = recurOnListsOfGeneratorClauseBindings(that.getGens()); 2576 2568 Option<TypeCheckerResult> type_result = recurOnOptionOfType(that.getExprType()); 2577 2569 TypeChecker extend = this.extend(pair.second()); … … 2606 2598 @Override 2607 2599 public TypeCheckerResult forGeneratedExpr(GeneratedExpr that) { 2608 Pair<List<TypeCheckerResult>,List<LValue Bind>> pair = recurOnListsOfGeneratorClauseBindings(that.getGens());2600 Pair<List<TypeCheckerResult>,List<LValue>> pair = recurOnListsOfGeneratorClauseBindings(that.getGens()); 2609 2601 TypeChecker extend = this.extend(pair.second()); 2610 2602 TypeCheckerResult body_result = that.getExpr().accept(extend); … … 2630 2622 } 2631 2623 2632 private Pair<TypeCheckerResult, List<LValue Bind>> forGeneratorClauseGetBindings(GeneratorClause that,2624 private Pair<TypeCheckerResult, List<LValue>> forGeneratorClauseGetBindings(GeneratorClause that, 2633 2625 boolean mustBeCondition) { 2634 2626 TypeCheckerResult init_result = that.getInit().accept(this); 2635 final Pair<TypeCheckerResult, List<LValue Bind>> p = forGeneratorClauseOnlyGetBindings(that, init_result, mustBeCondition);2627 final Pair<TypeCheckerResult, List<LValue>> p = forGeneratorClauseOnlyGetBindings(that, init_result, mustBeCondition); 2636 2628 2637 2629 if( postInference ) { 2638 2630 Boolean ok = true; 2639 List<LValue Bind> closed_binds = new ArrayList<LValueBind>();2640 for(LValue Bindb : p.second()){2631 List<LValue> closed_binds = new ArrayList<LValue>(); 2632 for(LValue b : p.second()){ 2641 2633 Pair<Boolean,Node> temp = TypesUtil.closeConstraints(b, subtypeChecker, p.first()); 2642 closed_binds.add((LValue Bind)temp.second());2634 closed_binds.add((LValue)temp.second()); 2643 2635 ok&=temp.first(); 2644 2636 } … … 2655 2647 } 2656 2648 2657 private Pair<TypeCheckerResult, List<LValue Bind>> forGeneratorClauseOnlyGetBindings(GeneratorClause that,2649 private Pair<TypeCheckerResult, List<LValue>> forGeneratorClauseOnlyGetBindings(GeneratorClause that, 2658 2650 TypeCheckerResult init_result, boolean mustBeCondition) { 2659 2651 … … 2670 2662 2671 2663 return Pair.make(TypeCheckerResult.compose(new_node, subtypeChecker, init_result, bool_result), 2672 Collections.<LValue Bind>emptyList());2664 Collections.<LValue>emptyList()); 2673 2665 } 2674 2666 … … 2676 2668 int bindings_count = that.getBind().size(); 2677 2669 2678 List<LValue Bind> result_bindings;2670 List<LValue> result_bindings; 2679 2671 Type lhstype; 2680 2672 // Now create the bindings … … 2683 2675 // Just one binding 2684 2676 lhstype = NodeFactory.make_InferenceVarType(that.getBind().get(0).getSpan()); 2685 LValue Bindlval = NodeFactory.makeLValue(that.getBind().get(0), lhstype);2677 LValue lval = NodeFactory.makeLValue(that.getBind().get(0), lhstype); 2686 2678 result_bindings = Collections.singletonList(lval); 2687 2679 } … … 2696 2688 // Now just create the lvalues with the newly created inference variable type 2697 2689 Iterator<Id> id_iter = that.getBind().iterator(); 2698 result_bindings = new ArrayList<LValue Bind>(bindings_count);2690 result_bindings = new ArrayList<LValue>(bindings_count); 2699 2691 for( Type inference_var : inference_vars ) { 2700 2692 result_bindings.add(NodeFactory.makeLValue(id_iter.next(), inference_var)); … … 2776 2768 private Pair<TypeCheckerResult, Option<Type>> forIfClauseWithType(IfClause that) { 2777 2769 // For generalized 'if' we must introduce new bindings. 2778 Pair<TypeCheckerResult, List<LValue Bind>> result_and_binds =2770 Pair<TypeCheckerResult, List<LValue>> result_and_binds = 2779 2771 this.forGeneratorClauseGetBindings(that.getTest(), true); 2780 2772 2781 2773 // Destruct result 2782 2774 TypeCheckerResult test_result = result_and_binds.first(); 2783 List<LValue Bind> bindings = result_and_binds.second();2775 List<LValue> bindings = result_and_binds.second(); 2784 2776 2785 2777 // Check body with new bindings … … 4279 4271 meet=this.subtypeChecker.meet(clause.getMatch().get(0),original_type); 4280 4272 } 4281 LValue Bindbind = NodeFactory.makeLValue(to_bind.get(0), meet);4273 LValue bind = NodeFactory.makeLValue(to_bind.get(0), meet); 4282 4274 extend=this.extend(Collections.singletonList(bind)); 4283 4275 }else{ … … 4286 4278 } 4287 4279 else{ 4288 List<LValue Bind> binds=new ArrayList<LValueBind>(to_bind.size());4280 List<LValue> binds=new ArrayList<LValue>(to_bind.size()); 4289 4281 Iterator<Type> mitr=clause.getMatch().iterator(); 4290 4282 assert(original_type instanceof TupleType); … … 4310 4302 @Override 4311 4303 public TypeCheckerResult forVarDecl(VarDecl that) { 4312 List<LValue Bind> lhs = that.getLhs();4304 List<LValue> lhs = that.getLhs(); 4313 4305 Expr init = that.getInit(); 4314 4306 … … 4317 4309 TypeCheckerResult subtype_result; 4318 4310 if (lhs.size() == 1) { // We have a single variable binding, not a tuple binding 4319 LValue Bindvar = lhs.get(0);4311 LValue var = lhs.get(0); 4320 4312 Option<Type> varType = var.getType(); 4321 4313 if (varType.isSome()) { … … 4338 4330 } 4339 4331 } else { // lhs.size() >= 2 4340 Type varType = typeFromLValue Binds(lhs);4332 Type varType = typeFromLValues(lhs); 4341 4333 if (initResult.type().isNone()) { 4342 4334 // The right hand side could not be typed, which must have resulted in a … … 4390 4382 @Override 4391 4383 public TypeCheckerResult forWhile(While that) { 4392 Pair<TypeCheckerResult,List<LValue Bind>> res = this.forGeneratorClauseGetBindings(that.getTest(), true);4384 Pair<TypeCheckerResult,List<LValue>> res = this.forGeneratorClauseGetBindings(that.getTest(), true); 4393 4385 TypeChecker extended = this.extend(res.second()); 4394 4386 TypeCheckerResult body_result = that.getBody().accept(extended); … … 4622 4614 // Finally, return all of the bindings so that they can be put in scope in some larger expression, like the 4623 4615 // body of a for loop, for example. 4624 private Pair<List<TypeCheckerResult>, List<LValue Bind>> recurOnListsOfGeneratorClauseBindings(List<GeneratorClause> gens) {4616 private Pair<List<TypeCheckerResult>, List<LValue>> recurOnListsOfGeneratorClauseBindings(List<GeneratorClause> gens) { 4625 4617 if( gens.isEmpty() ) 4626 return Pair.make(Collections.<TypeCheckerResult>emptyList(), Collections.<LValue Bind>emptyList());4618 return Pair.make(Collections.<TypeCheckerResult>emptyList(), Collections.<LValue>emptyList()); 4627 4619 else if( gens.size() == 1 ) { 4628 Pair<TypeCheckerResult,List<LValue Bind>> pair = forGeneratorClauseGetBindings(IterUtil.first(gens), false);4620 Pair<TypeCheckerResult,List<LValue>> pair = forGeneratorClauseGetBindings(IterUtil.first(gens), false); 4629 4621 return Pair.make(Collections.singletonList(pair.first()), pair.second()); 4630 4622 } 4631 4623 else { 4632 Pair<TypeCheckerResult,List<LValue Bind>> pair = forGeneratorClauseGetBindings(IterUtil.first(gens), false);4624 Pair<TypeCheckerResult,List<LValue>> pair = forGeneratorClauseGetBindings(IterUtil.first(gens), false); 4633 4625 TypeChecker new_checker = this.extend(pair.second()); 4634 4626 // recur 4635 Pair<List<TypeCheckerResult>, List<LValue Bind>> recur_result =4627 Pair<List<TypeCheckerResult>, List<LValue>> recur_result = 4636 4628 new_checker.recurOnListsOfGeneratorClauseBindings(CollectUtil.makeList(IterUtil.skipFirst(gens))); 4637 4629 return Pair.make( Useful.cons(pair.first(), recur_result.first()), -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeEnv.java
r3077 r3082 58 58 import com.sun.fortress.nodes.IntersectionType; 59 59 import com.sun.fortress.nodes.KeywordType; 60 import com.sun.fortress.nodes.LValue Bind;60 import com.sun.fortress.nodes.LValue; 61 61 import com.sun.fortress.nodes.LocalVarDecl; 62 62 import com.sun.fortress.nodes.Modifier; … … 119 119 * Construct a new TypeEnv from the given bindings. 120 120 */ 121 public static TypeEnv make(LValue Bind... entries) {121 public static TypeEnv make(LValue... entries) { 122 122 return EmptyTypeEnv.ONLY.extend(entries); 123 123 } … … 369 369 * compiler to distinguish them from other variants with the same _erased_ signature. 370 370 */ 371 public final TypeEnv extend(LValue Bind... entries) {371 public final TypeEnv extend(LValue... entries) { 372 372 if (entries.length == 0) { return this; } 373 373 else { return new LValueTypeEnv(entries, this); } 374 374 } 375 375 376 public final TypeEnv extendWithLValues(List<LValue Bind> entries) {376 public final TypeEnv extendWithLValues(List<LValue> entries) { 377 377 if (entries.size() == 0) { return this; } 378 378 else { return new LValueTypeEnv(entries, this); } … … 437 437 /** 438 438 * A wrapper around the binding found in the TypeEnv. Since some bindings 439 * do not have an Id to be indexed, there is no way to create the LValue Bind439 * do not have an Id to be indexed, there is no way to create the LValue 440 440 * node to represent the binding. In the case of operators, for example, 441 441 * only a IdOrOpOrAnonymousName exists, so the BindingLookup exports the same methods 442 * that LValue Bind does, since an LValueBindcannot be created.442 * that LValue does, since an LValue cannot be created. 443 443 */ 444 444 public static class BindingLookup { … … 449 449 private final boolean mutable; 450 450 451 public BindingLookup(LValue Bindbinding) {451 public BindingLookup(LValue binding) { 452 452 var = binding.getName(); 453 453 type = binding.getType(); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/Driver.java
r3078 r3082 81 81 import com.sun.fortress.nodes.ImportStar; 82 82 import com.sun.fortress.nodes.ImportedNames; 83 import com.sun.fortress.nodes.LValueBind;84 83 import com.sun.fortress.nodes.NodeAbstractVisitor_void; 85 84 import com.sun.fortress.nodes.NodeVisitor_void; -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildApiEnvironment.java
r3053 r3082 34 34 import com.sun.fortress.nodes.Id; 35 35 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 36 import com.sun.fortress.nodes.LValue Bind;36 import com.sun.fortress.nodes.LValue; 37 37 import com.sun.fortress.nodes_util.NodeUtil; 38 38 39 39 public class BuildApiEnvironment extends BuildTopLevelEnvironments { 40 40 41 41 @Override 42 42 public Boolean forAbsFnDecl(AbsFnDecl x) { … … 73 73 FValue fv = exporter.getEnvironment().getValueRaw(fname); 74 74 FType ft = exporter.getEnvironment().getRootTypeNull(fname); // toplevel 75 75 76 76 // This is overloadable if the object is NOT a singleton. 77 77 if (x.getParams().isSome()) { 78 78 overloadNames.add(fname); 79 exporter.overloadableExportedFunction.add(fname); 80 api.overloadableExportedFunction.add(fname); 79 exporter.overloadableExportedFunction.add(fname); 80 api.overloadableExportedFunction.add(fname); 81 81 } 82 82 83 83 if (fv != null) { 84 84 bindInto.putValueRaw(fname, fv); … … 98 98 } 99 99 handlePossibleFM(x.getDecls()); 100 100 101 101 } 102 102 return change; … … 127 127 // super.forAbsVarDecl(x); 128 128 Boolean change = Boolean.FALSE; 129 129 130 130 if (getPass() == 1) { 131 List<LValue Bind> lhs = x.getLhs();132 LValue Bindlvb = lhs.get(0); // Have desugared to single vars131 List<LValue> lhs = x.getLhs(); 132 LValue lvb = lhs.get(0); // Have desugared to single vars 133 133 Id name = lvb.getName(); 134 134 String sname = NodeUtil.stringName(name); … … 149 149 CUWrapper exporter; 150 150 CUWrapper api; 151 151 152 152 @Override 153 153 public void setExporterAndApi(CUWrapper exporter, CUWrapper api) { … … 155 155 this.api = api; 156 156 } 157 157 158 158 public BuildApiEnvironment(Environment within, 159 159 Map<String, ComponentWrapper> linker) { … … 161 161 // TODO Auto-generated constructor stub 162 162 } 163 163 164 164 private void handlePossibleFM(List<? extends AbsDeclOrDecl> tdecls) { 165 165 for (AbsDeclOrDecl adod : tdecls) { … … 179 179 } else { 180 180 // TODO not handling this quite yet. 181 181 182 182 //exporter.missingExportedVars.put(s); 183 183 } … … 187 187 } 188 188 189 189 190 190 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildEnvironments.java
r3077 r3082 662 662 663 663 private void forVarDecl1(VarDecl x) { 664 List<LValue Bind> lhs = x.getLhs();664 List<LValue> lhs = x.getLhs(); 665 665 666 666 // List<Modifier> mods; … … 668 668 // Option<Type> type = x.getType(); 669 669 Expr init = x.getInit(); 670 LValue Bindlvb = lhs.get(0);670 LValue lvb = lhs.get(0); 671 671 672 672 Option<Type> type = lvb.getType(); … … 689 689 690 690 // for (LValue lv : lhs) { 691 // if (lv instanceof LValue Bind) {692 // LValue Bind lvb = (LValueBind) lv;691 // if (lv instanceof LValue) { 692 // LValue lvb = (LValue) lv; 693 693 // Option<Type> type = lvb.getType(); 694 694 // Id name = lvb.getName(); … … 731 731 private void forVarDecl4(VarDecl x) { 732 732 733 List<LValue Bind> lhs = x.getLhs();733 List<LValue> lhs = x.getLhs(); 734 734 735 735 // List<Modifier> mods; … … 738 738 Expr init = x.getInit(); 739 739 // int index = 0; 740 LValue Bindlvb = lhs.get(0);740 LValue lvb = lhs.get(0); 741 741 742 742 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildLetEnvironments.java
r3077 r3082 36 36 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 37 37 import com.sun.fortress.nodes.LValue; 38 import com.sun.fortress.nodes.LValueBind;39 38 import com.sun.fortress.nodes.LetExpr; 40 39 import com.sun.fortress.nodes.LetFn; … … 128 127 } else { 129 128 EvalType eval_type = new EvalType(containing); 130 for (LValue lval : lhs) { 131 if (lval instanceof LValueBind) { 132 LValueBind lvb = (LValueBind) lval; 133 if (lvb.isMutable() && lvb.getType().isSome()) { 134 FValue fv = lval.accept(new_eval); 135 FType fvt = lvb.getType().unwrap().accept(eval_type); 136 containing.putVariable(fv.getString(),fvt); 137 } else { 138 containing.putValue(lval.accept(new_eval), new IndirectionCell()); 139 140 } 129 for (LValue lvb : lhs) { 130 if (lvb.isMutable() && lvb.getType().isSome()) { 131 FValue fv = lvb.accept(new_eval); 132 FType fvt = lvb.getType().unwrap().accept(eval_type); 133 containing.putVariable(fv.getString(),fvt); 141 134 } else { 142 containing.putValue(lv al.accept(new_eval), new IndirectionCell());135 containing.putValue(lvb.accept(new_eval), new IndirectionCell()); 143 136 } 144 137 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/BuildTraitEnvironment.java
r3077 r3082 31 31 import com.sun.fortress.nodes.FnAbsDeclOrDecl; 32 32 import com.sun.fortress.nodes.Id; 33 import com.sun.fortress.nodes.LValue Bind;33 import com.sun.fortress.nodes.LValue; 34 34 import com.sun.fortress.nodes.StaticParam; 35 35 import com.sun.fortress.nodes.VarDecl; … … 84 84 public Boolean forVarDecl(VarDecl x) { 85 85 if (fields != null) { 86 List<LValue Bind> lhs = x.getLhs();87 for (LValue Bindlvb : lhs) {86 List<LValue> lhs = x.getLhs(); 87 for (LValue lvb : lhs) { 88 88 Id name = lvb.getName(); 89 89 String s = NodeUtil.nameString(name); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/Evaluator.java
r3053 r3082 107 107 import com.sun.fortress.nodes.Juxt; 108 108 import com.sun.fortress.nodes.KeywordExpr; 109 import com.sun.fortress.nodes.LValue Bind;109 import com.sun.fortress.nodes.LValue; 110 110 import com.sun.fortress.nodes.Label; 111 111 import com.sun.fortress.nodes.LetExpr; … … 138 138 import com.sun.fortress.nodes.Typecase; 139 139 import com.sun.fortress.nodes.TypecaseClause; 140 import com.sun.fortress.nodes.UnpastingBind;141 import com.sun.fortress.nodes.UnpastingSplit;142 140 import com.sun.fortress.nodes.VarRef; 143 141 import com.sun.fortress.nodes.VoidLiteralExpr; … … 886 884 } 887 885 888 public FValue forLValue Bind(LValueBindx) {886 public FValue forLValue(LValue x) { 889 887 Id name = x.getName(); 890 888 return FString.make(NodeUtil.nameString(name)); … … 1652 1650 } 1653 1651 1654 public FValue forUnpastingBind(UnpastingBind x) {1655 return NI("forUnpastingBind");1656 }1657 1658 public FValue forUnpastingSplit(UnpastingSplit x) {1659 return NI("forUnpastingSplit");1660 }1661 1662 1652 public FValue forVarRef(VarRef x) { 1663 1653 // Id id = x.getVar(); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSEvaluator.java
r2741 r3082 49 49 import com.sun.fortress.nodes.FieldRef; 50 50 import com.sun.fortress.nodes.Id; 51 import com.sun.fortress.nodes.LValue Bind;51 import com.sun.fortress.nodes.LValue; 52 52 import com.sun.fortress.nodes.SubscriptExpr; 53 53 import com.sun.fortress.nodes.Enclosing; … … 55 55 import com.sun.fortress.nodes.TupleExpr; 56 56 import com.sun.fortress.nodes.Type; 57 import com.sun.fortress.nodes.Unpasting;58 import com.sun.fortress.nodes.UnpastingBind;59 import com.sun.fortress.nodes.UnpastingSplit;60 57 import com.sun.fortress.nodes.VarRef; 61 58 import com.sun.fortress.nodes._RewriteFieldRef; … … 129 126 public Voidoid forVarRef(VarRef x) { 130 127 String s = x.getVar().getText(); 131 128 132 129 Environment e = evaluator.e.getHomeEnvironment(x.getVar()); 133 130 e = BaseEnv.toContainingObjectEnv(e, x.getLexicalDepth()); 134 131 135 132 FType ft = e.getVarTypeNull(s); 136 133 if (ft != null) { … … 146 143 } 147 144 148 /* (non-Javadoc) 149 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forUnpastingBind(com.sun.fortress.interpreter.nodes.UnpastingBind) 150 */ 151 @Override 152 public Voidoid forUnpastingBind(UnpastingBind x) { 153 return super.forUnpastingBind(x); 154 } 155 156 /* (non-Javadoc) 157 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forUnpastingSplit(com.sun.fortress.interpreter.nodes.UnpastingSplit) 158 */ 159 @Override 160 public Voidoid forUnpastingSplit(UnpastingSplit x) { 161 return super.forUnpastingSplit(x); 162 } 163 164 public Voidoid forLValueBind(LValueBind x) { 145 public Voidoid forLValue(LValue x) { 165 146 Id name = x.getName(); 166 147 Option<Type> type = x.getType(); … … 201 182 if (Glue.extendsGenericTrait(outerType, aname)) { 202 183 bestGuess = Glue.typeFromGeneric(outerType, aname, WellKnownNames.arrayElementTypeName); 203 184 204 185 // Find and invoke the generic factory arrayK[\ T, size1, ..., sizeK \] () 205 186 String genericName = WellKnownNames.arrayMaker(rank); -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/LHSToLValue.java
r2649 r3082 30 30 import com.sun.fortress.nodes.Id; 31 31 import com.sun.fortress.nodes.Lhs; 32 import com.sun.fortress.nodes.LValue Bind;32 import com.sun.fortress.nodes.LValue; 33 33 import com.sun.fortress.nodes.SubscriptExpr; 34 34 import com.sun.fortress.nodes.ArgExpr; 35 35 import com.sun.fortress.nodes.TupleExpr; 36 import com.sun.fortress.nodes.Unpasting;37 import com.sun.fortress.nodes.UnpastingBind;38 import com.sun.fortress.nodes.UnpastingSplit;39 36 import com.sun.fortress.nodes.VarRef; 40 37 import com.sun.fortress.nodes._RewriteFieldRef; … … 123 120 } 124 121 125 /* (non-Javadoc) 126 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forUnpastingBind(com.sun.fortress.interpreter.nodes.UnpastingBind) 127 */ 128 @Override 129 public Lhs forUnpastingBind(UnpastingBind x) { 130 Id name = x.getName(); 131 List<ExtentRange> dim = x.getDim(); 132 return super.forUnpastingBind(x); 133 } 134 135 /* (non-Javadoc) 136 * @see com.sun.fortress.interpreter.nodes.NodeVisitor#forUnpastingSplit(com.sun.fortress.interpreter.nodes.UnpastingSplit) 137 */ 138 @Override 139 public Lhs forUnpastingSplit(UnpastingSplit x) { 140 int dim = x.getDim(); 141 List<Unpasting> elems = x.getElems(); 142 return super.forUnpastingSplit(x); 143 } 144 145 public Lhs forLValueBind(LValueBind x) { 122 public Lhs forLValue(LValue x) { 146 123 return x; 147 124 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/evaluator/types/FTypeObject.java
r2969 r3082 31 31 import com.sun.fortress.nodes.Id; 32 32 import com.sun.fortress.nodes.IdOrOpOrAnonymousName; 33 import com.sun.fortress.nodes.LValue Bind;33 import com.sun.fortress.nodes.LValue; 34 34 import com.sun.fortress.nodes.Param; 35 35 import com.sun.fortress.nodes.VarAbsDeclOrDecl; … … 66 66 for(AbsDeclOrDecl v : members) { 67 67 if (v instanceof VarAbsDeclOrDecl) { 68 for (LValue Bindlhs : ((VarAbsDeclOrDecl)v).getLhs()) {68 for (LValue lhs : ((VarAbsDeclOrDecl)v).getLhs()) { 69 69 fields.add(lhs.getName()); 70 70 } -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/DesugarerVisitor.java
r3078 r3082 83 83 import com.sun.fortress.nodes.Juxt; 84 84 import com.sun.fortress.nodes.LValue; 85 import com.sun.fortress.nodes.LValueBind;86 85 import com.sun.fortress.nodes.LetFn; 87 86 import com.sun.fortress.nodes.LocalVarDecl; … … 113 112 import com.sun.fortress.nodes.TypeArg; 114 113 import com.sun.fortress.nodes.Typecase; 115 import com.sun.fortress.nodes.Unpasting;116 import com.sun.fortress.nodes.UnpastingBind;117 import com.sun.fortress.nodes.UnpastingSplit;118 114 import com.sun.fortress.nodes.VarDecl; 119 115 import com.sun.fortress.nodes.VarRef; … … 752 748 } 753 749 @Override 754 public Node forLValue Bind(LValueBindlvb) {750 public Node forLValue(LValue lvb) { 755 751 Id id = lvb.getName(); 756 752 if ("_".equals(id.getText())) { … … 875 871 public Node forVarDecl(VarDecl vd) { 876 872 atTopLevelInsideTraitOrObject = false; 877 List<LValue Bind> lhs = vd.getLhs();873 List<LValue> lhs = vd.getLhs(); 878 874 879 875 if (lhs.size() > 1) { … … 882 878 Expr init = vd.getInit(); 883 879 init = (Expr) visitNode(init); 884 lhs = (List<LValue Bind>) recurOnListOfLValueBind(lhs);880 lhs = (List<LValue>) recurOnListOfLValue(lhs); 885 881 ArrayList<VarDecl> newdecls = new ArrayList<VarDecl>(1+lhs.size()); 886 882 String temp = WellKnownNames.tempTupleName(vd); … … 889 885 newdecls.add(new_vd); 890 886 int element_index = 0; 891 for (LValue Bindlv : lhs) {887 for (LValue lv : lhs) { 892 888 Id newName = new Id(at, "$" + element_index); 893 889 newdecls.add(new VarDecl(at, Useful.list(lv), … … 1364 1360 1365 1361 @Override 1366 public void forLValue Bind(LValueBindthat) {1362 public void forLValue(LValue that) { 1367 1363 that.getName().accept(this); 1368 1364 } … … 1372 1368 String s = that.getText(); 1373 1369 rewrites_put(s, new Local()); 1374 }1375 1376 @Override1377 public void forUnpastingBind(UnpastingBind that) {1378 that.getName().accept(this);1379 for (ExtentRange er : that.getDim())1380 er.accept(this);1381 }1382 1383 @Override1384 public void forUnpastingSplit(UnpastingSplit that) {1385 for (Unpasting up : that.getElems())1386 up.accept(this);1387 1370 } 1388 1371 -
trunk/ProjectFortress/src/com/sun/fortress/interpreter/rewrite/IsAnArrowName.java
r3077 r3082 20 20 import com.sun.fortress.nodes.ArrowType; 21 21 import com.sun.fortress.nodes.FnDecl; 22 import com.sun.fortress.nodes.LValue Bind;22 import com.sun.fortress.nodes.LValue; 23 23 import com.sun.fortress.nodes.Node; 24 24 import com.sun.fortress.nodes.NodeAbstractVisitor; … … 45 45 46 46 /* (non-Javadoc) 47 * @see com.sun.fortress.nodes.NodeAbstractVisitor#forLValue Bind(com.sun.fortress.nodes.LValueBind)47 * @see com.sun.fortress.nodes.NodeAbstractVisitor#forLValue(com.sun.fortress.nodes.LValue) 48 48 */ 49 49 @Override 50 public ArrowOrFunctional forLValue Bind(LValueBindthat) {50 public ArrowOrFunctional forLValue(LValue that) { 51 51 return optionTypeIsArrow(that.getType()); 52 52 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ApiMaker.java
r3077 r3082 71 71 72 72 @Override public Boolean forVarDecl(VarDecl that) { 73 List<LValue Bind> lhs = that.getLhs();73 List<LValue> lhs = that.getLhs(); 74 74 boolean result = false; 75 for (LValue Bindlv : lhs) {75 for (LValue lv : lhs) { 76 76 if ( containsPrivate(lv.getMods()) ) 77 77 result = true; … … 154 154 public Option<Node> forVarDecl(VarDecl that) { 155 155 if ( ! isPrivate(that) ) { 156 List<LValue Bind> lhs = new ArrayList<LValueBind>();157 for (LValue Bindlvb : that.getLhs()) {156 List<LValue> lhs = new ArrayList<LValue>(); 157 for (LValue lvb : that.getLhs()) { 158 158 if ( lvb.getType().isNone() ) 159 159 log(lvb, "The type of " + lvb.getName() + " is required."); -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ErrorMsgMaker.java
r3081 r3082 301 301 } 302 302 303 public String forLValue Bind(LValueBindnode) {303 public String forLValue(LValue node) { 304 304 String r = ""; 305 305 if (node.getType().isSome()) { -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/ExprFactory.java
r3081 r3082 607 607 Option<Expr> _rhs = Option.some(_r); 608 608 _body.add(_body_expr); 609 _lhs.add(new LValue Bind(p.getSpan(), p,false));609 _lhs.add(new LValue(p.getSpan(), p,false)); 610 610 return new LocalVarDecl(FortressUtil.spanTwo(p, _r), _body, _lhs, _rhs); 611 611 } … … 616 616 Option<Expr> _rhs = Option.some(_r); 617 617 _body.add(_body_expr); 618 _lhs.add(new LValue Bind(sp, p,false));618 _lhs.add(new LValue(sp, p,false)); 619 619 return new LocalVarDecl(sp, _body, _lhs, _rhs); 620 620 } -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeFactory.java
r3081 r3082 718 718 } 719 719 720 public static LValue BindmakeLValue(Id id) {721 return new LValue Bind(id.getSpan(), id);722 } 723 724 public static LValue BindmakeLValue(String name, String type) {720 public static LValue makeLValue(Id id) { 721 return new LValue(id.getSpan(), id); 722 } 723 724 public static LValue makeLValue(String name, String type) { 725 725 return makeLValue(name, makeVarType(type)); 726 726 } 727 727 728 public static LValue BindmakeLValue(Id name, Id type) {729 return new LValue Bind(new Span(name.getSpan(), type.getSpan()),728 public static LValue makeLValue(Id name, Id type) { 729 return new LValue(new Span(name.getSpan(), type.getSpan()), 730 730 name, 731 731 Option.some((Type)makeVarType(type.getSpan(),type)), … … 734 734 } 735 735 736 public static LValue BindmakeLValue(Id name, Type type) {737 return new LValue Bind(new Span(name.getSpan(), type.getSpan()),736 public static LValue makeLValue(Id name, Type type) { 737 return new LValue(new Span(name.getSpan(), type.getSpan()), 738 738 name, 739 739 Option.some(type), … … 742 742 } 743 743 744 public static LValue BindmakeLValue(Id name, Option<Type> type) {745 return new LValue Bind(name.getSpan(),744 public static LValue makeLValue(Id name, Option<Type> type) { 745 return new LValue(name.getSpan(), 746 746 name, 747 747 type, … … 750 750 } 751 751 752 public static LValue BindmakeLValue(String name, Type type) {753 return new LValue Bind(type.getSpan(), makeId(name), Option.some(type),752 public static LValue makeLValue(String name, Type type) { 753 return new LValue(type.getSpan(), makeId(name), Option.some(type), 754 754 Collections.<Modifier>emptyList(), false); 755 755 } 756 756 757 public static LValue BindmakeLValue(String name, Type type, List<Modifier> mods) {758 LValue Bindresult = makeLValue(name, type);757 public static LValue makeLValue(String name, Type type, List<Modifier> mods) { 758 LValue result = makeLValue(name, type); 759 759 return makeLValue(result, mods); 760 760 } 761 761 762 public static LValue Bind makeLValue(LValueBindlvb, Id name) {763 return new LValue Bind(lvb.getSpan(), name, lvb.getType(), lvb.getMods(),762 public static LValue makeLValue(LValue lvb, Id name) { 763 return new LValue(lvb.getSpan(), name, lvb.getType(), lvb.getMods(), 764 764 lvb.isMutable()); 765 765 } 766 766 767 public static LValue Bind makeLValue(LValueBindlvb, boolean mutable) {768 return new LValue Bind(lvb.getSpan(), lvb.getName(), lvb.getType(),767 public static LValue makeLValue(LValue lvb, boolean mutable) { 768 return new LValue(lvb.getSpan(), lvb.getName(), lvb.getType(), 769 769 lvb.getMods(), mutable); 770 770 } 771 771 772 public static LValue Bind makeLValue(LValueBindlvb, List<Modifier> mods) {772 public static LValue makeLValue(LValue lvb, List<Modifier> mods) { 773 773 boolean mutable = lvb.isMutable(); 774 774 for (Modifier m : mods) { … … 776 776 mutable = true; 777 777 } 778 return new LValue Bind(lvb.getSpan(), lvb.getName(), lvb.getType(),778 return new LValue(lvb.getSpan(), lvb.getName(), lvb.getType(), 779 779 mods, mutable); 780 780 } 781 781 782 public static LValue Bind makeLValue(LValueBindlvb, List<Modifier> mods,782 public static LValue makeLValue(LValue lvb, List<Modifier> mods, 783 783 boolean mutable) { 784 return new LValue Bind(lvb.getSpan(), lvb.getName(), lvb.getType(),784 return new LValue(lvb.getSpan(), lvb.getName(), lvb.getType(), 785 785 mods, mutable); 786 786 } 787 787 788 public static LValue Bind makeLValue(LValueBindlvb, Type ty) {789 return new LValue Bind(lvb.getSpan(), lvb.getName(),788 public static LValue makeLValue(LValue lvb, Type ty) { 789 return new LValue(lvb.getSpan(), lvb.getName(), 790 790 Option.some(ty), lvb.getMods(), 791 791 lvb.isMutable()); 792 792 } 793 793 794 public static LValue Bind makeLValue(LValueBindlvb, Type ty,794 public static LValue makeLValue(LValue lvb, Type ty, 795 795 boolean mutable) { 796 return new LValue Bind(lvb.getSpan(), lvb.getName(),796 return new LValue(lvb.getSpan(), lvb.getName(), 797 797 Option.some(ty), lvb.getMods(), mutable); 798 798 } 799 799 800 public static LValue Bind makeLValue(LValueBindlvb, Type ty,800 public static LValue makeLValue(LValue lvb, Type ty, 801 801 List<Modifier> mods) { 802 802 boolean mutable = lvb.isMutable(); … … 805 805 mutable = true; 806 806 } 807 return new LValue Bind(lvb.getSpan(), lvb.getName(),807 return new LValue(lvb.getSpan(), lvb.getName(), 808 808 Option.some(ty), mods, mutable); 809 809 } 810 810 811 public static LValue BindmakeLValue(NormalParam param) {812 return new LValue Bind(param.getSpan(), param.getName(),811 public static LValue makeLValue(NormalParam param) { 812 return new LValue(param.getSpan(), param.getName(), 813 813 param.getType(), param.getMods(), false); 814 814 } … … 1093 1093 } 1094 1094 1095 public static AbsVarDecl makeAbsVarDecl(Span span, List<LValue Bind> lvals) {1095 public static AbsVarDecl makeAbsVarDecl(Span span, List<LValue> lvals) { 1096 1096 FortressUtil.validId(lvals); 1097 1097 return new AbsVarDecl(span, lvals); 1098 1098 } 1099 1099 1100 public static VarDecl makeVarDecl(Span span, List<LValue Bind> lvals, Expr init) {1100 public static VarDecl makeVarDecl(Span span, List<LValue> lvals, Expr init) { 1101 1101 FortressUtil.validId(lvals); 1102 1102 return new VarDecl(span, lvals, init); … … 1105 1105 public static VarDecl makeVarDecl(Span span, Id name, Expr init) { 1106 1106 FortressUtil.validId(name); 1107 LValue Bind bind = new LValueBind(span, name, Option.<Type>none(),1107 LValue bind = new LValue(span, name, Option.<Type>none(), 1108 1108 Collections.<Modifier>emptyList(), true); 1109 return new VarDecl(span, Useful.<LValue Bind>list(bind), init);1109 return new VarDecl(span, Useful.<LValue>list(bind), init); 1110 1110 } 1111 1111 … … 1113 1113 Id id = new Id(span, name); 1114 1114 FortressUtil.validId(id); 1115 LValue Bind bind = new LValueBind(span, id,1115 LValue bind = new LValue(span, id, 1116 1116 Option.<Type>none(), 1117 1117 Collections.<Modifier>emptyList(), true); 1118 return new VarDecl(span, Useful.<LValue Bind>list(bind), init);1118 return new VarDecl(span, Useful.<LValue>list(bind), init); 1119 1119 } 1120 1120 -
trunk/ProjectFortress/src/com/sun/fortress/nodes_util/NodeUtil.java
r3078 r3082 422 422 /* stringNames *********************************************************/ 423 423 public static IterableOnce<String> stringNames(LValue lv) { 424 return lv.accept(new NodeAbstractVisitor<IterableOnce<String>>() { 425 public IterableOnce<String> forLValueBind(LValueBind d) { 426 return new UnitIterable<String>(d.getName().getText()); 427 } 428 public IterableOnce<String> forUnpastingBind(UnpastingBind d) { 429 return new UnitIterable<String>(d.getName().getText()); 430 } 431 public IterableOnce<String> forUnpastingSplit(UnpastingSplit d) { 432 return new IterableOnceForLValueList(d.getElems()); 433 } 434 }); 424 return new UnitIterable<String>(lv.getName().getText()); 435 425 } 436 426 -
trunk/ProjectFortress/src/com/sun/fortress/parser/AbsField.rats
r2855 r3082 49 49 } 50 50 / a1:ApiFldMods? a2:BindIdOrBindIdTuple w colon w a3:NoNewlineType w ellipses 51 { List<LValue Bind> lvs;51 { List<LValue> lvs; 52 52 if (a1 != null) lvs = FortressUtil.ids2Lvs(a2, a1, a3, false); 53 53 else lvs = FortressUtil.ids2Lvs(a2, a3, false); … … 60 60 if (a2.size() != tys.size()) 61 61 syntaxError(span, "Mismatched numbers of variables and types."); 62 List<LValue Bind> lvs;62 List<LValue> lvs; 63 63 if (a1 != null) lvs = FortressUtil.ids2Lvs(a2, a1, tys, false); 64 64 else lvs = FortressUtil.ids2Lvs(a2, tys, false); -
trunk/ProjectFortress/src/com/sun/fortress/parser/LocalDecl.rats
r3077 r3082 116 116 a2 = FortressUtil.setMutable(a2, createSpan(yyStart,3)); 117 117 } 118 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), 119 FortressUtil.toLValueList(a2), a3); 118 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), a2, a3); 120 119 } 121 120 / a1:(var w)? a2:NoNewlineVarWTypes s colonequals w a3:NoNewlineExpr 122 121 { a2 = FortressUtil.setMutable(a2, createSpan(yyStart,3)); 123 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), 124 FortressUtil.toLValueList(a2), a3); 122 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), a2, a3); 125 123 } 126 124 / a1:(var w)? a2:NoNewlineVarWTypes 127 125 { if (a1 != null) a2 = FortressUtil.setMutable(a2, createSpan(yyStart,3)); 128 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), 129 FortressUtil.toLValueList(a2)); 126 yyValue = FortressUtil.mkLocalVarDecl(createSpan(yyStart,yyCount), a2); 130 127 } 131 128 / a1:VarWoTypes s equals w a2:NoNewlineExpr … … 177 174 }; 178 175 179 LValue BindVarMayType := a1:BindId a2:(s void:colon s NoNewlineType)?176 LValue VarMayType := a1:BindId a2:(s void:colon s NoNewlineType)? 180 177 { if (a2 == null) 181 yyValue = FortressUtil.mkLValue Bind(createSpan(yyStart,yyCount),a1);178 yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount),a1); 182 179 else 183 yyValue = FortressUtil.mkLValue Bind(createSpan(yyStart,yyCount),a1,a2);180 yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount),a1,a2); 184 181 }; 185 182 … … 196 193 LValue VarWoType = 197 194 a1:BindId 198 { yyValue = FortressUtil.mkLValueBind(createSpan(yyStart,yyCount), a1); } 199 / Unpasting ; 195 { yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount), a1); } 196 / Unpasting 197 { Span span = createSpan(yyStart,yyCount); 198 yyValue = FortressUtil.mkLValue(span, new Id(span, "_")); 199 }; 200 200 201 201 /* Unpasting ::= [ w UnpastingElems w ] */ 202 private UnpastingUnpasting =202 private void Unpasting = 203 203 void:opensquare w UnpastingElems w void:closesquare ; 204 204 … … 207 207 | UnpastingElem 208 208 */ 209 private Unpasting UnpastingElems = 210 a1:UnpastingElem a2:RectSeparator a3:UnpastingElems 211 { yyValue = FortressUtil.unpastingCons(createSpan(yyStart,yyCount), 212 a1, a2, a3); 213 } 209 private void UnpastingElems = 210 UnpastingElem RectSeparator UnpastingElems 214 211 / UnpastingElem ; 215 212 … … 218 215 | Unpasting 219 216 */ 220 private Unpasting UnpastingElem = 221 a1:BindId a2:(void:opensquare w UnpastingDim w void:closesquare)? 222 { if (a2 == null) 223 yyValue = new UnpastingBind(createSpan(yyStart,yyCount), a1, 224 Collections.<ExtentRange>emptyList()); 225 else 226 yyValue = new UnpastingBind(createSpan(yyStart,yyCount), a1, a2); 227 } 217 private void UnpastingElem = 218 BindId (void:opensquare w UnpastingDim w void:closesquare)? 228 219 / Unpasting ; 229 220 … … 231 222 // due to the Rats! module system 232 223 /* UnpastingDim ::= NoNewlineExtentRange (w BY w NoNewlineExtentRange)+ */ 233 private List<ExtentRange> UnpastingDim = 234 a1:NoNewlineExtentRange a2s:(w cross w NoNewlineExtentRange)+ 235 { yyValue = FortressUtil.mkList(a1, a2s.list()); }; 224 private void UnpastingDim = 225 NoNewlineExtentRange (w cross w NoNewlineExtentRange)+ ; 236 226 237 227 /* CaseClause ::= NoNewlineExpr w => w BlockElems */ -
trunk/ProjectFortress/src/com/sun/fortress/parser/NoNewlineExpr.rats
r2808 r3082 196 196 | ( w NoNewlineVarWType (w , w NoNewlineVarWType)+ w ) 197 197 */ 198 List<LValue Bind> NoNewlineVarWTypes =198 List<LValue> NoNewlineVarWTypes = 199 199 a1:NoNewlineVarWType 200 200 { yyValue = FortressUtil.mkList(a1); } … … 204 204 205 205 /* NoNewlineVarWType ::= BindId s NoNewlineIsType */ 206 LValue BindNoNewlineVarWType = a1:BindId s a2:NoNewlineIsType207 { yyValue = FortressUtil.mkLValue Bind(createSpan(yyStart,yyCount),a1,a2); };206 LValue NoNewlineVarWType = a1:BindId s a2:NoNewlineIsType 207 { yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount),a1,a2); }; 208 208 209 209 /* NoNewlineIsType ::= : w NoNewlineType */ -
trunk/ProjectFortress/src/com/sun/fortress/parser/Variable.rats
r2829 r3082 59 59 } 60 60 / a1:VarImmutableMods? a2:BindIdOrBindIdTuple w equals w a3:NoNewlineExpr 61 { List<LValue Bind> lvs;61 { List<LValue> lvs; 62 62 if (a1 != null) lvs = FortressUtil.ids2Lvs(a2, a1); 63 63 else lvs = FortressUtil.ids2Lvs(a2); … … 66 66 } 67 67 / a1:VarMods? a2:BindIdOrBindIdTuple w colon w a3:NoNewlineType w ellipses w a4:InitVal 68 { List<LValue Bind> lvs;68 { List<LValue> lvs; 69 69 if (a1 != null) { 70 70 if (a4.getB()) lvs = FortressUtil.ids2Lvs(a2, a1, a3, true); … … 82 82 if (a2.size() != tys.size()) 83 83 syntaxError(span, "Mismatched numbers of variables and types."); 84 List<LValue Bind> lvs;84 List<LValue> lvs; 85 85 if (a1 != null) { 86 86 if (a4.getB()) lvs = FortressUtil.ids2Lvs(a2, a1, tys, true); … … 130 130 | ( w VarMayType (w , w VarMayType)+ w ) 131 131 */ 132 List<LValue Bind> VarMayTypes =132 List<LValue> VarMayTypes = 133 133 a1:VarMayType 134 134 { yyValue = FortressUtil.mkList(a1); } … … 137 137 138 138 /* VarMayType ::= BindId (w IsType)? */ 139 LValue BindVarMayType = a1:BindId a2:(w IsType)139 LValue VarMayType = a1:BindId a2:(w IsType) 140 140 { if (a2 == null) 141 yyValue = FortressUtil.mkLValue Bind(createSpan(yyStart,yyCount),a1);141 yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount),a1); 142 142 else 143 yyValue = FortressUtil.mkLValue Bind(createSpan(yyStart,yyCount),a1,a2);143 yyValue = FortressUtil.mkLValue(createSpan(yyStart,yyCount),a1,a2); 144 144 }; 145 145 … … 163 163 } 164 164 / a1:AbsVarMods? a2:BindIdOrBindIdTuple w colon w a3:NoNewlineType w ellipses 165 { List<LValue Bind> lvs;165 { List<LValue> lvs; 166 166 if (a1 != null) lvs = FortressUtil.ids2Lvs(a2, a1, a3, false); 167 167 else lvs = FortressUtil.ids2Lvs(a2, a3, false); … … 174 174 if (a2.size() != tys.size()) 175 175 syntaxError(span, "Mismatched numbers of variables and types."); 176 List<LValue Bind> lvs;176 List<LValue> lvs; 177 177 if (a1 != null) lvs = FortressUtil.ids2Lvs(a2, a1, tys, false); 178 178 else lvs = FortressUtil.ids2Lvs(a2, tys, false); -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/FortressUtil.java
r3077 r3082 132 132 l.add(last); 133 133 return l; 134 }135 136 public static List<LValue> toLValueList(List<LValueBind> lvbs) {137 List<LValue> result = new ArrayList<LValue>();138 for (LValueBind lvb : lvbs) {139 result.add((LValue)lvb);140 }141 return result;142 134 } 143 135 … … 347 339 public static void validId(List<? extends LValue> lvs) { 348 340 for (LValue lv : lvs) { 349 if (lv instanceof LValueBind) { 350 validId(((LValueBind)lv).getName()); 351 } else if (lv instanceof UnpastingBind) { 352 validId(((UnpastingBind)lv).getName()); 353 } else // if (lv instanceof UnpastingSplit) 354 validId(((UnpastingSplit)lv).getElems()); 341 validId(lv.getName()); 355 342 } 356 343 } … … 408 395 } 409 396 410 public static void allHaveTypes(List<LValue Bind> vars) {411 for (LValue Bindl : vars) {397 public static void allHaveTypes(List<LValue> vars) { 398 for (LValue l : vars) { 412 399 if (l.getType().isNone()) 413 400 syntaxError(l.getSpan(), … … 416 403 } 417 404 418 public static List<LValue Bind> setMutable(List<LValueBind> vars) {419 List<LValue Bind> result = new ArrayList<LValueBind>();420 for (LValue Bindl : vars) {405 public static List<LValue> setMutable(List<LValue> vars) { 406 List<LValue> result = new ArrayList<LValue>(); 407 for (LValue l : vars) { 421 408 result.add(NodeFactory.makeLValue(l, true)); 422 409 } … … 424 411 } 425 412 426 public static List<LValue Bind> setMutable(List<LValueBind> vars, Span span) {427 List<LValue Bind> result = new ArrayList<LValueBind>();428 for (LValue Bindl : vars) {413 public static List<LValue> setMutable(List<LValue> vars, Span span) { 414 List<LValue> result = new ArrayList<LValue>(); 415 for (LValue l : vars) { 429 416 List<Modifier> mods = new ArrayList<Modifier>(); 430 417 mods.add(new ModifierVar(span)); … … 434 421 } 435 422 436 public static List<LValue Bind> setMods(List<LValueBind> vars,423 public static List<LValue> setMods(List<LValue> vars, 437 424 List<Modifier> mods) { 438 List<LValue Bind> result = new ArrayList<LValueBind>();439 for (LValue Bindl : vars) {425 List<LValue> result = new ArrayList<LValue>(); 426 for (LValue l : vars) { 440 427 result.add(NodeFactory.makeLValue(l, mods)); 441 428 } … … 443 430 } 444 431 445 public static List<LValue Bind> setModsAndMutable(List<LValueBind> vars,432 public static List<LValue> setModsAndMutable(List<LValue> vars, 446 433 List<Modifier> mods) { 447 List<LValue Bind> result = new ArrayList<LValueBind>();448 for (LValue Bindl : vars) {434 List<LValue> result = new ArrayList<LValue>(); 435 for (LValue l : vars) { 449 436 result.add(NodeFactory.makeLValue(l, mods, true)); 450 437 } … … 455 442 List<LValue> result = new ArrayList<LValue>(); 456 443 for (LValue l : vars) { 457 if (l instanceof LValueBind) { 458 List<Modifier> mods = new ArrayList<Modifier>(); 459 mods.add(new ModifierVar(span)); 460 result.add(NodeFactory.makeLValue((LValueBind)l, mods)); 461 } else syntaxError(l.getSpan(), "Unpasting cannot be mutable."); 444 List<Modifier> mods = new ArrayList<Modifier>(); 445 mods.add(new ModifierVar(span)); 446 result.add(NodeFactory.makeLValue(l, mods)); 462 447 } 463 448 return result; … … 467 452 List<LValue> result = new ArrayList<LValue>(); 468 453 for (LValue l : vars) { 469 if (l instanceof LValueBind) 470 result.add(NodeFactory.makeLValue((LValueBind)l, ty)); 471 else syntaxError(l.getSpan(), "Unpasting cannot be set types."); 454 result.add(NodeFactory.makeLValue(l, ty)); 472 455 } 473 456 return result; … … 478 461 int ind = 0; 479 462 for (LValue l : vars) { 480 if (l instanceof LValueBind) { 481 result.add(NodeFactory.makeLValue((LValueBind)l, tys.get(ind))); 482 ind += 1; 483 } else syntaxError(l.getSpan(), "Unpasting cannot be set types."); 463 result.add(NodeFactory.makeLValue(l, tys.get(ind))); 464 ind += 1; 484 465 } 485 466 return result; … … 489 470 List<LValue> result = new ArrayList<LValue>(); 490 471 for (LValue l : vars) { 491 if (l instanceof LValueBind) { 492 result.add(NodeFactory.makeLValue((LValueBind)l, ty, true)); 493 } else syntaxError(l.getSpan(), "Unpasting cannot be mutable."); 472 result.add(NodeFactory.makeLValue(l, ty, true)); 494 473 } 495 474 return result; … … 500 479 List<LValue> result = new ArrayList<LValue>(); 501 480 for (LValue l : vars) { 502 if (l instanceof LValueBind) { 503 List<Modifier> mods = new ArrayList<Modifier>(); 504 mods.add(new ModifierVar(span)); 505 result.add(NodeFactory.makeLValue((LValueBind)l, ty, mods)); 506 } else syntaxError(l.getSpan(), "Unpasting cannot be mutable."); 481 List<Modifier> mods = new ArrayList<Modifier>(); 482 mods.add(new ModifierVar(span)); 483 result.add(NodeFactory.makeLValue(l, ty, mods)); 507 484 } 508 485 return result; … … 514 491 int ind = 0; 515 492 for (LValue l : vars) { 516 if (l instanceof LValueBind) { 517 result.add(NodeFactory.makeLValue((LValueBind)l, tys.get(ind), 518 true)); 519 ind += 1; 520 } else syntaxError(l.getSpan(), "Unpasting cannot be mutable."); 493 result.add(NodeFactory.makeLValue(l, tys.get(ind), true)); 494 ind += 1; 521 495 } 522 496 return result; … … 528 502 int ind = 0; 529 503 for (LValue l : vars) { 530 if (l instanceof LValueBind) { 531 List<Modifier> mods = new ArrayList<Modifier>(); 532 mods.add(new ModifierVar(span)); 533 result.add(NodeFactory.makeLValue((LValueBind)l, tys.get(ind), 534 mods)); 535 ind += 1; 536 } else syntaxError(l.getSpan(), "Unpasting cannot be mutable."); 537 } 538 return result; 539 } 540 541 public static List<LValueBind> ids2Lvs(List<Id> ids, List<Modifier> mods, 504 List<Modifier> mods = new ArrayList<Modifier>(); 505 mods.add(new ModifierVar(span)); 506 result.add(NodeFactory.makeLValue(l, tys.get(ind), mods)); 507 ind += 1; 508 } 509 return result; 510 } 511 512 public static List<LValue> ids2Lvs(List<Id> ids, List<Modifier> mods, 542 513 Option<Type> ty, boolean mutable) { 543 List<LValue Bind> lvs = new ArrayList<LValueBind>();514 List<LValue> lvs = new ArrayList<LValue>(); 544 515 for (Id id : ids) { 545 lvs.add(new LValue Bind(id.getSpan(), id, ty, mods, mutable));516 lvs.add(new LValue(id.getSpan(), id, ty, mods, mutable)); 546 517 } 547 518 return lvs; 548 519 } 549 520 550 public static List<LValue Bind> ids2Lvs(List<Id> ids, List<Modifier> mods,521 public static List<LValue> ids2Lvs(List<Id> ids, List<Modifier> mods, 551 522 Type ty, boolean mutable) { 552 523 return ids2Lvs(ids, mods, Option.some(ty), mutable); 553 524 } 554 525 555 public static List<LValue Bind> ids2Lvs(List<Id> ids, Type ty,526 public static List<LValue> ids2Lvs(List<Id> ids, Type ty, 556 527 boolean mutable) { 557 528 return ids2Lvs(ids, emptyModifiers(), Option.some(ty), mutable); 558 529 } 559 530 560 public static List<LValue Bind> ids2Lvs(List<Id> ids, List<Modifier> mods) {531 public static List<LValue> ids2Lvs(List<Id> ids, List<Modifier> mods) { 561 532 return ids2Lvs(ids, mods, Option.<Type>none(), false); 562 533 } 563 534 564 public static List<LValue Bind> ids2Lvs(List<Id> ids) {535 public static List<LValue> ids2Lvs(List<Id> ids) { 565 536 return ids2Lvs(ids, emptyModifiers(), Option.<Type>none(), false); 566 537 } 567 538 568 public static List<LValue Bind> ids2Lvs(List<Id> ids, List<Modifier> mods,539 public static List<LValue> ids2Lvs(List<Id> ids, List<Modifier> mods, 569 540 List<Type> tys, boolean mutable) { 570 List<LValue Bind> lvs = new ArrayList<LValueBind>();541 List<LValue> lvs = new ArrayList<LValue>(); 571 542 int ind = 0; 572 543 for (Id id : ids) { 573 lvs.add(new LValue Bind(id.getSpan(), id, Option.some(tys.get(ind)),544 lvs.add(new LValue(id.getSpan(), id, Option.some(tys.get(ind)), 574 545 mods, mutable)); 575 546 ind += 1; … … 578 549 } 579 550 580 public static List<LValue Bind> ids2Lvs(List<Id> ids, List<Type> tys,551 public static List<LValue> ids2Lvs(List<Id> ids, List<Type> tys, 581 552 boolean mutable) { 582 553 return ids2Lvs(ids, emptyModifiers(), tys, mutable); … … 655 626 } 656 627 657 public static LValue Bind mkLValueBind(Span span, Id id, Type ty) {658 return new LValue Bind(span, id, Option.some(ty), emptyModifiers(),false);659 } 660 public static LValue Bind mkLValueBind(Span span, Id id) {661 return new LValue Bind(span, id, Option.<Type>none(),628 public static LValue mkLValue(Span span, Id id, Type ty) { 629 return new LValue(span, id, Option.some(ty), emptyModifiers(),false); 630 } 631 public static LValue mkLValue(Span span, Id id) { 632 return new LValue(span, id, Option.<Type>none(), 662 633 emptyModifiers(), false); 663 634 } 664 public static LValue Bind mkLValueBind(Id id, Type ty,635 public static LValue mkLValue(Id id, Type ty, 665 636 List<Modifier> mods) { 666 return new LValue Bind(id.getSpan(), id, Option.some(ty), mods,637 return new LValue(id.getSpan(), id, Option.some(ty), mods, 667 638 getMutable(mods)); 668 639 } 669 public static LValue Bind mkLValueBind(Id id, Type ty) {670 return mkLValue Bind(id, ty, emptyModifiers());640 public static LValue mkLValue(Id id, Type ty) { 641 return mkLValue(id, ty, emptyModifiers()); 671 642 } 672 643 … … 786 757 // unpasting_split span dim (one :: elems) 787 758 // | _ -> Errors.internal_error span "Empty unpasting.") 759 /* 788 760 public static Unpasting unpastingCons(Span span, Unpasting one, int sep, 789 761 Unpasting two) { … … 816 788 } 817 789 } 790 */ 818 791 819 792 // let join (one : span) (two : span) : span = -
trunk/ProjectFortress/src/com/sun/fortress/parser_util/SyntaxChecker.java
r3077 r3082 149 149 150 150 public void forAbsVarDeclOnly(AbsVarDecl that) { 151 for (LValue Bindlvb : that.getLhs()) {151 for (LValue lvb : that.getLhs()) { 152 152 if ( lvb.getType().isNone() ) 153 153 log(lvb, "The type of " + lvb.getName() + " is required."); -
trunk/ProjectFortress/src/com/sun/fortress/syntax_abstractions/phases/Transform.java
r3077 r3082 126 126 127 127 /* Support renaming for these nodes 128 * LValueBind ( only for LocalVarDecl ) - done 129 * UnpastingBind ( only for LocalVarDecl ) - done 128 * LValue ( only for LocalVarDecl ) - done 130 129 * FnDecl ( only for local function decls ) - done 131 130 * NormalParam ( only for FnExpr and local function decls ) - done … … 372 371 public LValue apply(LValue value){ 373 372 return (LValue) value.accept( new TemplateUpdateVisitor(){ 374 public Node forLValue BindOnly(LValueBindthat, Id name_result, Option<Type> type_result, List<Modifier> mods_result) {373 public Node forLValueOnly(LValue that, Id name_result, Option<Type> type_result, List<Modifier> mods_result) { 375 374 Id old = (Id) name_result.accept(transformer); 376 375 Id generatedId = generateId(old); 377 376 Debug.debug( Debug.Type.SYNTAX, 2, "Generate new binding for " + old + " = " + generatedId ); 378 377 extendSyntaxEnvironment(old, generatedId); 379 return new LValueBind(that.getSpan(), generatedId, type_result, mods_result); 380 } 381 public Node forUnpastingBindOnly(UnpastingBind that, Id name_result, List<ExtentRange> dim_result) { 382 Id old = (Id) name_result.accept(transformer); 383 Id generatedId = generateId(old); 384 Debug.debug( Debug.Type.SYNTAX, 2, "Generate new binding for " + old + " = " + generatedId ); 385 extendSyntaxEnvironment(old, generatedId); 386 return new UnpastingBind(that.getSpan(), generatedId, dim_result); 378 return new LValue(that.getSpan(), generatedId, type_result, mods_result); 387 379 } 388 380 }); -
trunk/ProjectFortress/src/com/sun/fortress/tools/FortressAstToConcrete.java
r3081 r3082 603 603 return Useful.applyToAll( lhs, new Fn<LValue,Boolean>(){ 604 604 public Boolean apply( LValue value ){ 605 return value.accept( new NodeDepthFirstVisitor<Boolean>(){ 606 @Override public Boolean forLValueBind(LValueBind that) { 607 return that.isMutable(); 608 } 609 610 @Override public Boolean forUnpastingBind(UnpastingBind that) { 611 return false; 612 } 613 614 @Override public Boolean forUnpastingSplit(UnpastingSplit that) { 615 return false; 616 } 617 }); 605 return value.isMutable(); 618 606 } 619 607 }); … … 627 615 628 616 List<LValue> lhs = new ArrayList<LValue>(); 629 for ( LValue Bindlv : that.getLhs() ) {630 lhs.add( (LValue)lv );617 for ( LValue lv : that.getLhs() ) { 618 lhs.add( lv ); 631 619 }
