summaryrefslogtreecommitdiff
path: root/sources/scalac/ast/TreeGen.java
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2005-03-27 09:55:28 +0000
committerschinz <schinz@epfl.ch>2005-03-27 09:55:28 +0000
commit9602bf11e93ac5a449f0ab492f3c74f2fa45fa56 (patch)
tree7a14cc6a3ff3110b3fca75f1da33b4627562d2a1 /sources/scalac/ast/TreeGen.java
parenta274f949c3aa9db16bd5addd0eed4f85388e74ed (diff)
downloadscala-9602bf11e93ac5a449f0ab492f3c74f2fa45fa56.tar.gz
scala-9602bf11e93ac5a449f0ab492f3c74f2fa45fa56.tar.bz2
scala-9602bf11e93ac5a449f0ab492f3c74f2fa45fa56.zip
- changed pattern matcher to use the erased ver...
- changed pattern matcher to use the erased versions of asInstanceOf when possible, to gain some speed when run time types are enabled; i.e. instead of generating code like this: if (x.isInstanceOf[List[Int]]) { val temp$ = x.asInstanceOf[List[Int]]; ... } the pattern matcher now generates code like that: if (x.isInstanceOf[List[Int]]) { val temp$ = x.asInstanceOf$erased[List[Int]]; ... }
Diffstat (limited to 'sources/scalac/ast/TreeGen.java')
-rw-r--r--sources/scalac/ast/TreeGen.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java
index 43d1fc1ed5..9167a4cf94 100644
--- a/sources/scalac/ast/TreeGen.java
+++ b/sources/scalac/ast/TreeGen.java
@@ -640,23 +640,29 @@ public class TreeGen implements Kinds, Modifiers, TypeTags {
}
/** Builds an instance test with given value and type. */
- public Tree mkIsInstanceOf(int pos, Tree value, Type type) {
- Symbol sym = global.currentPhase.id >= global.PHASE.TYPESASVALUES.id()
- ? definitions.ANY_IS_ERASED
- : definitions.ANY_IS;
+ public Tree mkIsInstanceOf(int pos, Tree value, Type type, boolean erased) {
+ Symbol sym = erased ? definitions.ANY_IS_ERASED : definitions.ANY_IS;
return mkApplyT_(pos, Select(value, sym), new Type[]{type});
}
+ public Tree mkIsInstanceOf(int pos, Tree value, Type type) {
+ boolean afterTAV =
+ global.currentPhase.id >= global.PHASE.TYPESASVALUES.id();
+ return mkIsInstanceOf(pos, value, type, afterTAV);
+ }
public Tree mkIsInstanceOf(Tree value, Type type) {
return mkIsInstanceOf(value.pos, value, type);
}
/** Builds a cast with given value and type. */
- public Tree mkAsInstanceOf(int pos, Tree value, Type type) {
- Symbol sym = global.currentPhase.id >= global.PHASE.TYPESASVALUES.id()
- ? definitions.ANY_AS_ERASED
- : definitions.ANY_AS;
+ public Tree mkAsInstanceOf(int pos, Tree value, Type type, boolean erased) {
+ Symbol sym = erased ? definitions.ANY_AS_ERASED : definitions.ANY_AS;
return mkApplyT_(pos, Select(value, sym), new Type[]{type});
}
+ public Tree mkAsInstanceOf(int pos, Tree value, Type type) {
+ boolean afterTAV =
+ global.currentPhase.id >= global.PHASE.TYPESASVALUES.id();
+ return mkAsInstanceOf(pos, value, type, afterTAV);
+ }
public Tree mkAsInstanceOf(Tree value, Type type) {
return mkAsInstanceOf(value.pos, value, type);
}