Changeset 3877
- Timestamp:
- 06/19/09 20:52:17 (5 months ago)
- Location:
- trunk/ProjectFortress
- Files:
-
- 4 added
- 4 modified
- 12 moved
-
compiler_tests/AfterTypeChecking.test (modified) (1 diff)
-
compiler_tests/AsIfInterface.fsi (moved) (moved from trunk/ProjectFortress/not_working_static_tests/AsIfInterface.fsi)
-
compiler_tests/Compiled5.ac.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXEqualityTesting.fss) (2 diffs)
-
compiler_tests/Compiled5.ad.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXChainTest1.fss) (2 diffs)
-
compiler_tests/Compiled5.ae.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXChainTest2.fss) (2 diffs)
-
compiler_tests/Compiled5.af.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXStaticParamFunctionCall.fss) (2 diffs)
-
compiler_tests/Compiled5.ag.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/DXXInvertedAsExpr.fss) (2 diffs)
-
compiler_tests/Compiled5.ah.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/AsExpr.fss) (2 diffs)
-
compiler_tests/Compiled5.ai.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/AsIf.fss) (2 diffs)
-
compiler_tests/Compiled5.aj.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/LocalVarRef.fss) (2 diffs)
-
compiler_tests/Compiled5.ak.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/GenericSingleton.fss) (2 diffs)
-
compiler_tests/Compiled5.al.fss (moved) (moved from trunk/ProjectFortress/not_working_static_tests/SimpleObject.fss) (2 diffs)
-
compiler_tests/MyOwnLiterals.fsi (moved) (moved from trunk/ProjectFortress/not_working_static_tests/MyOwnLiterals.fsi)
-
compiler_tests/XXX5ac.test (added)
-
compiler_tests/XXX5ad.test (added)
-
compiler_tests/XXX5ae.test (added)
-
compiler_tests/XXX5af.test (added)
-
src/com/sun/fortress/scala_src/typechecker/OverloadingChecker.scala (modified) (1 diff)
-
src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala (modified) (4 diffs)
-
src/com/sun/fortress/scala_src/useful/SExprUtil.scala (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ProjectFortress/compiler_tests/AfterTypeChecking.test
r3875 r3877 14 14 # trademarks of Sun Microsystems, Inc. in the U.S. and other countries. 15 15 16 tests=Compiled1.ag Compiled1.ah Compiled1.ai Compiled1.aj Compiled1.ak Compiled1.as Compiled1.au Compiled1.av Compiled2.g Compiled2.t Compiled3.b Compiled3.c Compiled3.d Compiled3.e Compiled3.f Compiled3.h Compiled3.i Compiled3.j Compiled3.k Compiled3.m Compiled3.p Compiled3.q Compiled3.t Compiled3.v Compiled3.x Compiled5.e Compiled5.o Compiled5.q Compiled 6 Compiled7 Compiled816 tests=Compiled1.ag Compiled1.ah Compiled1.ai Compiled1.aj Compiled1.ak Compiled1.as Compiled1.au Compiled1.av Compiled2.g Compiled2.t Compiled3.b Compiled3.c Compiled3.d Compiled3.e Compiled3.f Compiled3.h Compiled3.i Compiled3.j Compiled3.k Compiled3.m Compiled3.p Compiled3.q Compiled3.t Compiled3.v Compiled3.x Compiled5.e Compiled5.o Compiled5.q Compiled5.ah Compiled5.ai Compiled5.aj Compiled5.ak Compiled5.al Compiled6 Compiled7 Compiled8 17 17 desugar -
trunk/ProjectFortress/compiler_tests/Compiled5.ac.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component DXXEqualityTesting19 18 export Executable 20 19 … … 27 26 28 27 run():() = () 29 30 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ad.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component DXXChainTest119 18 export Executable 20 19 … … 25 24 26 25 run():() = () 27 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ae.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component DXXChainTest219 18 export Executable 20 19 … … 30 29 31 30 run():() = () 32 end -
trunk/ProjectFortress/compiler_tests/Compiled5.af.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component DXXStaticParamFunctionCall19 18 export Executable 20 19 … … 28 27 29 28 run():() = ignore(foo(A)) 30 31 32 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ag.fss
r3775 r3877 16 16 ******************************************************************************) 17 17 18 component DXXInvertedAsExpr19 18 export Executable 20 19 … … 25 24 y:ZZ32 = x typed ZZ32 26 25 end 27 28 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ah.fss
r3775 r3877 16 16 ******************************************************************************) 17 17 18 component AsExpr19 18 export Executable 20 19 … … 25 24 y:Any = x typed Any 26 25 end 27 28 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ai.fss
r2688 r3877 16 16 ******************************************************************************) 17 17 18 component AsIf19 18 import MyOwnLiterals.{...} 20 19 export AsIfInterface … … 25 24 26 25 foo():MyOwnZZ32 = (MyOwn0 asif MyOwnZZ32) 27 28 end -
trunk/ProjectFortress/compiler_tests/Compiled5.aj.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component LocalVarRef19 18 export Executable 20 19 … … 29 28 () 30 29 end 31 32 end -
trunk/ProjectFortress/compiler_tests/Compiled5.ak.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component GenericSingleton19 18 export Executable 20 19 … … 29 28 v3 = C[\Boolean\] 30 29 end 31 32 end -
trunk/ProjectFortress/compiler_tests/Compiled5.al.fss
r3550 r3877 16 16 ******************************************************************************) 17 17 18 component SimpleObject19 18 export Executable 20 19 … … 28 27 p2 = Point(1.0, 1.0) 29 28 end 30 31 end -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/OverloadingChecker.scala
r3875 r3877 261 261 * check comprises clauses 262 262 * - if "elements" are all tuple types 263 * simplif "t"263 * simplify "t" 264 264 */ 265 265 private def reduce(t: Type, exclusionOracle: ExclusionOracle): Type = t match { -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/typechecker/STypeChecker.scala
r3875 r3877 119 119 private def extend(ids: List[Id], types: List[Type]): STypeChecker = 120 120 extend(ids.zip(types).map((p:(Id,Type)) => NodeFactory.makeLValue(p._1,p._2))) 121 122 private def extend(decl: LocalVarDecl): STypeChecker = 123 STypeCheckerFactory.make(current, traits, env.extend(decl), analyzer, errors) 121 124 122 125 private def extendWithFunctions(methods: Relation[IdOrOpOrAnonymousName, JavaFunctionalMethod]) = … … 1117 1120 newLoc, false, withinDo, exprs) 1118 1121 case last::rest => 1119 val allButLast = rest.map((e: Expr) => checkExpr(e, Some(Types.VOID),1120 errorString("Non-last expression in a block")))1122 val allButLast = rest.map((e: Expr) => checkExpr(e, Some(Types.VOID), 1123 errorString("Non-last expression in a block"))) 1121 1124 val lastExpr = checkExpr(last) 1122 1125 val newExprs = (lastExpr::allButLast).reverse … … 1124 1127 newLoc, false, withinDo, newExprs) 1125 1128 } 1129 } 1130 1131 case d@SLocalVarDecl(SExprInfo(span,paren,_), body, lhs, rhs) => { 1132 val newRhs = rhs.map(checkExpr) 1133 val newLhs = newRhs match { 1134 case Some(e) => getType(e) match { 1135 case Some(typ@STupleType(_,elts,_,_)) => 1136 if ( lhs.size != elts.size ) { 1137 signal(expr, errorMsg("The size of right-hand side, ", typ, 1138 ", does not match with the size of left-hand side.")) 1139 return expr 1140 } 1141 lhs.zip(elts).map( (p:(LValue,Type)) => p._1 match { 1142 case SLValue(i,n,m,None,mt) => 1143 SLValue(i,n,m,Some(p._2),mt) 1144 case SLValue(i,n,m,Some(t),mt) => 1145 isSubtype(p._2, t, p._1, 1146 errorMsg("Right-hand side, ", p._2, 1147 ", must be a subtype of left-hand side, ", 1148 t, ".")) 1149 p._1 } ) 1150 case Some(typ) => lhs match { 1151 case List(SLValue(i,name,mods,Some(idType),mutable)) => 1152 isSubtype(typ, idType, expr, 1153 errorMsg("Right-hand side, ", typ, 1154 ", must be a subtype of left-hand side, ", idType, ".")) 1155 lhs 1156 case List(SLValue(i,name,mods,None,mutable)) => 1157 List(SLValue(i,name,mods,Some(typ),mutable)) 1158 case _ => 1159 signal(expr, errorMsg("Right-hand side, ", typ, 1160 ", is not a tuple type but left-hand side ", 1161 "declares multiple variables.")) 1162 return expr 1163 } 1164 case _ => return expr 1165 } 1166 case _ => lhs 1167 } 1168 1169 // Extend typechecker with new bindings from the RHS types 1170 val newChecker = this.extend(d) 1171 // A LocalVarDecl is like a let. It has a body, and its type is the type of the body 1172 val newBody = body.map(newChecker.checkExpr) 1173 if (!haveTypes(newBody)) { return expr } 1174 newBody.foreach(e => isSubtype(getType(e).get, Types.VOID, e, 1175 errorString("Non-last expression in a block"))) 1176 val newType = body.size match { 1177 case 0 => Some(Types.VOID) 1178 case _ => getType(newBody.last) 1179 } 1180 SLocalVarDecl(SExprInfo(span,paren,newType), newBody, newLhs, newRhs) 1126 1181 } 1127 1182 … … 1615 1670 case Some(ty) => 1616 1671 isSubtype(ty, Types.BOOLEAN, expr, 1617 errorMsg("The chained expression ", expr,1672 errorMsg("The chained expression ", 1618 1673 " should have type Boolean, but had type ", normalize(ty), ".")) 1619 1674 case _ => false -
trunk/ProjectFortress/src/com/sun/fortress/scala_src/useful/SExprUtil.scala
r3827 r3877 38 38 def haveTypes(exprs: List[Expr]): Boolean = 39 39 exprs.forall((e:Expr) => getType(e).isDefined) 40 41 42 40 43 41 /** 44 42 * Given an expression, return an identical expression with the given type … … 51 49 case SExprInfo(a, b, _) if !swap => 52 50 swap = true 53 SExprInfo(a, b, Some(typ)) 51 SExprInfo(a, b, Some(typ)) 54 52 case _ if(!swap) => super.walk(node) 55 53 case _ => node … … 58 56 adder(expr).asInstanceOf[Expr] 59 57 } 60 58 61 59 /** 62 60 * Replaces the overloadings in a FunctionalRef with the given overloadings … … 68 66 case _ => NI.nyi() 69 67 } 70 68 71 69 /** 72 70 * Replaces the static args in a FunctionalRef with the given ones. … … 78 76 case _ => NI.nyi() 79 77 } 80 81 78 79 82 80 }

