git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@5604 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
e723ff3b19
commit
a899c83d2f
|
@ -74,8 +74,46 @@ x = <html><title>title</title><body></body></html>
|
||||||
y = <html><title>title</title><body></body></html>
|
y = <html><title>title</title><body></body></html>
|
||||||
x equals y: true - y equals x: true
|
x equals y: true - y equals x: true
|
||||||
|
|
||||||
x = <html><body><table cellspacing="0" cellpadding="2"><tr><th>Last Name</th><th>First Name</th></tr><tr><td>Tom</td><td>20</td></tr><tr><td>Bob</td><td>22</td></tr><tr><td>James</td><td>19</td></tr></table></body></html>
|
x = <html>
|
||||||
y = <html><body><table cellspacing="0" cellpadding="2"><tr><th>Last Name</th><th>First Name</th></tr><tr><td>Tom</td><td>20</td></tr><tr><td>Bob</td><td>22</td></tr><tr><td>James</td><td>19</td></tr></table></body></html>
|
<body>
|
||||||
|
<table cellpadding="2" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<th>Last Name</th>
|
||||||
|
<th>First Name</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Tom </td>
|
||||||
|
<td> 20 </td>
|
||||||
|
</tr> <tr>
|
||||||
|
<td> Bob </td>
|
||||||
|
<td> 22 </td>
|
||||||
|
</tr> <tr>
|
||||||
|
<td> James </td>
|
||||||
|
<td> 19 </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
y = <html>
|
||||||
|
<body>
|
||||||
|
<table cellpadding="2" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<th>Last Name</th>
|
||||||
|
<th>First Name</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td> Tom </td>
|
||||||
|
<td> 20 </td>
|
||||||
|
</tr> <tr>
|
||||||
|
<td> Bob </td>
|
||||||
|
<td> 22 </td>
|
||||||
|
</tr> <tr>
|
||||||
|
<td> James </td>
|
||||||
|
<td> 19 </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
x equals y: true - y equals x: true
|
x equals y: true - y equals x: true
|
||||||
|
|
||||||
x = Tim
|
x = Tim
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
trait Lang1 {
|
trait Lang1 {
|
||||||
trait Exp;
|
trait Exp;
|
||||||
trait Visitor { def f(left: Exp): unit; }
|
trait Visitor { def f(left: Exp): unit; }
|
||||||
class Eval1: Visitor extends Visitor {
|
class Eval1 requires Visitor extends Visitor {
|
||||||
def f(left: Exp) = ();
|
def f(left: Exp) = ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Lang2 extends Lang1 {
|
trait Lang2 extends Lang1 {
|
||||||
class Eval2: Visitor extends Eval1;
|
class Eval2 requires Visitor extends Eval1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
object Main with Application {
|
object Main with Application {
|
||||||
|
|
|
@ -13,7 +13,7 @@ abstract class SymbolWrapper {
|
||||||
val context: Context;
|
val context: Context;
|
||||||
import context._;
|
import context._;
|
||||||
|
|
||||||
class Symbols: context.symbols.type {
|
class Symbols requires context.symbols.type {
|
||||||
abstract class Symbol {
|
abstract class Symbol {
|
||||||
def typ: types.Type;
|
def typ: types.Type;
|
||||||
def sym: Symbol = typ.sym;
|
def sym: Symbol = typ.sym;
|
||||||
|
@ -25,7 +25,7 @@ abstract class TypeWrapper {
|
||||||
val context: Context;
|
val context: Context;
|
||||||
import context._;
|
import context._;
|
||||||
|
|
||||||
class Types: context.types.type {
|
class Types requires context.types.type {
|
||||||
abstract class Type {
|
abstract class Type {
|
||||||
def sym: symbols.Symbol;
|
def sym: symbols.Symbol;
|
||||||
def typ: Type = sym.typ;
|
def typ: Type = sym.typ;
|
||||||
|
|
|
@ -15,7 +15,7 @@ abstract class Lang {
|
||||||
def visit(v: visitor): unit = v.caseNum(n);
|
def visit(v: visitor): unit = v.caseNum(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Eval(result: Ref[int]): visitor extends Visitor {
|
class Eval(result: Ref[int]) requires visitor extends Visitor {
|
||||||
def caseNum(n: int) = result.elem = n;
|
def caseNum(n: int) = result.elem = n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,12 @@ abstract class Lang2 extends Lang {
|
||||||
def visit(v: visitor): unit = v.casePlus(l, r);
|
def visit(v: visitor): unit = v.casePlus(l, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Eval2(result: Ref[int]): visitor extends Eval(result) with Visitor2 {
|
class Eval2(result: Ref[int]) requires visitor extends Eval(result) with Visitor2 {
|
||||||
def casePlus(l: Exp, r: Exp) =
|
def casePlus(l: Exp, r: Exp) =
|
||||||
result.elem = { l.visit(this); result.elem } + { r.visit(this); result.elem }
|
result.elem = { l.visit(this); result.elem } + { r.visit(this); result.elem }
|
||||||
}
|
}
|
||||||
|
|
||||||
class Show2(result: Ref[String]): visitor extends Visitor2 {
|
class Show2(result: Ref[String]) requires visitor extends Visitor2 {
|
||||||
def caseNum(n: int) = result.elem = n.toString();
|
def caseNum(n: int) = result.elem = n.toString();
|
||||||
def casePlus(l: Exp, r: Exp) =
|
def casePlus(l: Exp, r: Exp) =
|
||||||
result.elem =
|
result.elem =
|
||||||
|
|
|
@ -220,7 +220,7 @@ test_run_jvm() {
|
||||||
rm -rf "$dstbase".obj &&
|
rm -rf "$dstbase".obj &&
|
||||||
mkdir -p "$dstbase".obj &&
|
mkdir -p "$dstbase".obj &&
|
||||||
$SOCOS -d "$os_dstbase".obj "$@" "$os_srcbase".scala &&
|
$SOCOS -d "$os_dstbase".obj "$@" "$os_srcbase".scala &&
|
||||||
$SCALA -classpath "$os_dstbase".obj Test "jvm" &&
|
$SCALA -classpath "$os_dstbase".obj:$CLASSPATH Test "jvm" &&
|
||||||
rm -rf "$dstbase".obj;
|
rm -rf "$dstbase".obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue