Changeset 3835
- Timestamp:
- 06/10/09 19:56:03 (5 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 2 added
- 4 modified
- 2 moved
-
compiler_tests/Compiled1.j.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXDoubleExponentiation.fss) (1 diff)
-
compiler_tests/Compiled1.k.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXExpThenSubscript.fss) (1 diff)
-
compiler_tests/XXX1j.test (added)
-
compiler_tests/XXX1k.test (added)
-
src/com/sun/fortress/compiler/StaticChecker.java (modified) (1 diff)
-
src/com/sun/fortress/compiler/typechecker/TypeChecker.java (modified) (2 diffs)
-
src/com/sun/fortress/exceptions/FortressException.java (modified) (2 diffs)
-
src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/compiler_tests/Compiled1.j.fss
r3550 r3835 16 16 ******************************************************************************) 17 17 18 component DXXDoubleExponentiation18 component Compiled1.j 19 19 export Executable 20 20 run():() = () -
trunk/ProjectFortress/compiler_tests/Compiled1.k.fss
r3550 r3835 16 16 ******************************************************************************) 17 17 18 component DXXExpThenSubscript18 component Compiled1.k 19 19 export Executable 20 20 run():() = () -
trunk/ProjectFortress/src/com/sun/fortress/compiler/StaticChecker.java
r3829 r3835 222 222 ConstraintUtil.useScalaFormulas(); 223 223 STypeChecker typeChecker = STypeCheckerFactory.make(component, traitTable, typeEnv, typeAnalyzer); 224 component_ast = typeChecker. check(component_ast);224 component_ast = typeChecker.typecheck(component_ast); 225 225 component = IndexBuilder.builder.buildComponentIndex((Component)component_ast, 226 226 System.currentTimeMillis()); -
trunk/ProjectFortress/src/com/sun/fortress/compiler/typechecker/TypeChecker.java
r3829 r3835 432 432 } 433 433 else{ 434 String err_message = "Two consecutive ^s ";434 String err_message = "Two consecutive ^s."; 435 435 StaticError err=TypeError.make(err_message, 436 new Span(NodeUtil.getSpan((ASTNode)exponent.unwrap()), 437 NodeUtil.getSpan(that)).toString()); 436 NodeUtil.getSpan(that).toString()); 438 437 return new TypeCheckerResult(that,err); 439 438 } … … 446 445 } 447 446 else{ 448 String err_message = "Exponentiation followed by subscripting is illegal ";447 String err_message = "Exponentiation followed by subscripting is illegal."; 449 448 StaticError err=TypeError.make(err_message, 450 new Span(NodeUtil.getSpan((ASTNode)exponent.unwrap()), 451 NodeUtil.getSpan(that)).toString()); 449 NodeUtil.getSpan(that).toString()); 452 450 exponent = Option.none(); 453 451 return new TypeCheckerResult(that,err); -
trunk/ProjectFortress/src/com/sun/fortress/exceptions/FortressException.java
r3586 r3835 23 23 import java.util.ArrayList; 24 24 25 import edu.rice.cs.plt.tuple.Option; 25 26 import com.sun.fortress.interpreter.evaluator.Environment; 26 27 import com.sun.fortress.nodes_util.ErrorMsgMaker; … … 111 112 public FortressException(Iterable<? extends StaticError> errors) { 112 113 this.staticErrors = errors; 114 } 115 116 public Option<HasAt> getLoc() { 117 if ( this.where.isEmpty() ) 118 return Option.none(); 119 else return Option.wrap(this.where.get(0)); 120 } 121 122 public String getOriginalMessage() { 123 return super.getMessage(); 113 124 } 114 125 -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala
r3834 r3835 44 44 import com.sun.fortress.exceptions.StaticError 45 45 import com.sun.fortress.exceptions.StaticError.errorMsg 46 import com.sun.fortress.exceptions.TypeError 46 import com.sun.fortress.exceptions.ProgramError 47 import com.sun.fortress.exceptions.ProgramError.error 47 48 import com.sun.fortress.nodes._ 48 49 import com.sun.fortress.nodes_util.NodeFactory … … 131 132 protected def signal(hasAt:HasAt, msg:String) = 132 133 errors.signal(msg, hasAt) 134 135 private def syntaxError(hasAt:HasAt, msg:String) = 136 error(hasAt, msg) 133 137 134 138 /** … … 642 646 // ------------------------------------------------------------------------ 643 647 644 645 def check(node:Node):Node = node match { 648 def typecheck(node:Node):Node = 649 try { check(node) } 650 catch { case e:ProgramError => 651 errors.errors = List[StaticError]() 652 errors.signal(e.getOriginalMessage, e.getLoc.unwrap) 653 node 654 } 655 656 private def check(node:Node):Node = node match { 646 657 case SComponent(info, name, imports, decls, isNative, exports) => 647 658 SComponent(info, name, imports, … … 1143 1154 case SExponentiationMI(_,_,_) => exponent match { 1144 1155 case None => exponent = Some(item) 1145 case Some(e) => s ignal(item, "Two consecutive ^s.")1156 case Some(e) => syntaxError(item, "Two consecutive ^s.") 1146 1157 } 1147 1158 case SSubscriptingMI(_,_,_,_) => exponent match { 1148 1159 case Some(e) => 1149 s ignal(item, "Exponentiation followed by subscripting is illegal.")1160 syntaxError(item, "Exponentiation followed by subscripting is illegal.") 1150 1161 case None => 1151 1162 } … … 1169 1180 case SParenthesisDelimitedMI(_,e) => isArrows(checkExpr(e)) 1170 1181 case SNonParenthesisDelimitedMI(_,e) => isArrows(checkExpr(e)) 1171 case _ => 1182 case _ => false 1172 1183 } 1173 1184 def expectParenedExprItem(item: MathItem) = 1174 1185 if ( ! isParenedExprItem(item) ) 1175 s ignal(item, "Argument to function must be parenthesized.")1186 syntaxError(item, "Argument to function must be parenthesized.") 1176 1187 def expectExprMI(item: MathItem) = 1177 1188 if ( ! isExprMI(item) ) 1178 s ignal(item, "Item at this location must be an expression, not an operator.")1189 syntaxError(item, "Item at this location must be an expression, not an operator.") 1179 1190 // items is not an empty list. 1180 1191 def associateMathItems(first: Expr, … … 1188 1199 // find the left-most function 1189 1200 val (prefix, others) = items.span((e:MathItem) => 1190 !isFunctionItem(e) .asInstanceOf[Boolean])1201 !isFunctionItem(e)) 1191 1202 others match { 1192 1203 case fn::arg::suffix => arg match { 1193 1204 // It is a static error if either the argument is not parenthesized, 1194 1205 case SNonParenthesisDelimitedMI(_,e) => 1195 s ignal(e, "Tightly juxtaposed expression should be parenthesized.")1206 syntaxError(e, "Tightly juxtaposed expression should be parenthesized.") 1196 1207 (first, Nil) 1197 1208 case SParenthesisDelimitedMI(i,e) => { … … 1200 1211 case third::more => 1201 1212 if ( ! isExprMI(third) ) 1202 s ignal(third, "An expression is expected.")1213 syntaxError(third, "An expression is expected.") 1203 1214 case _ => 1204 1215 } … … 1227 1238 left.last.asInstanceOf[ExprMI].getExpr 1228 1239 else { 1229 s ignal(left.last, "An expression is expected.")1240 syntaxError(left.last, "An expression is expected.") 1230 1241 first 1231 1242 } … … 1248 1259 toJavaList(sargs)) 1249 1260 case _ => 1250 s ignal(item, "Non-expression element is expected.")1261 syntaxError(item, "Non-expression element is expected.") 1251 1262 head 1252 1263 } … … 1289 1300 val newTail = tail.map( (e:MathItem) => 1290 1301 if ( ! isExprMI(e) ) { 1291 s ignal(e, "An expression is expected.")1302 syntaxError(e, "An expression is expected.") 1292 1303 ExprFactory.makeVoidLiteralExpr(span) 1293 1304 } else e.asInstanceOf[ExprMI].getExpr )

