diff options
author | buraq <buraq@epfl.ch> | 2005-05-30 15:26:21 +0000 |
---|---|---|
committer | buraq <buraq@epfl.ch> | 2005-05-30 15:26:21 +0000 |
commit | 29f5328623037f1130993b0c85edbd3ceac5951a (patch) | |
tree | 48df8b820b07dd8453d8ddf2730ce04f7c206abd /sources/scala/tools/nsc/ast/TreeGen.scala | |
parent | 23f5623d548ab080a7e89938396ae48854580be6 (diff) | |
download | scala-29f5328623037f1130993b0c85edbd3ceac5951a.tar.gz scala-29f5328623037f1130993b0c85edbd3ceac5951a.tar.bz2 scala-29f5328623037f1130993b0c85edbd3ceac5951a.zip |
added >= method to Phase,
added mkAsInstanceOf and mkIsInstanceOf to TreeGen
Diffstat (limited to 'sources/scala/tools/nsc/ast/TreeGen.scala')
-rwxr-xr-x | sources/scala/tools/nsc/ast/TreeGen.scala | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sources/scala/tools/nsc/ast/TreeGen.scala b/sources/scala/tools/nsc/ast/TreeGen.scala index 4f4550fae1..39c504f626 100755 --- a/sources/scala/tools/nsc/ast/TreeGen.scala +++ b/sources/scala/tools/nsc/ast/TreeGen.scala @@ -74,4 +74,46 @@ abstract class TreeGen { if (qual.tpe != null) result setType atPhase(phase.next)(qual.tpe.memberType(sym)); result } + + + /** Builds an instance test with given value and type. */ + def mkIsInstanceOf(value: Tree, tpe: Type, erased: Boolean): Tree = { + val sym = + if(erased) + definitions.Any_isInstanceOfErased + else + definitions.Any_isInstanceOf; + + Apply( + TypeApply( + Select(value, sym), + List(TypeTree(tpe))), + List()) + } + + def mkIsInstanceOf(value: Tree, tpe: Type): Tree = { + val afterTAV = global.phase >= global.typesAsValuesPhase; + mkIsInstanceOf(value, tpe, afterTAV); + } + + /** Builds a cast with given value and type. */ + def mkAsInstanceOf(value: Tree, tpe: Type, erased: Boolean): Tree = { + val sym = + if(erased) + definitions.Any_asInstanceOfErased + else + definitions.Any_asInstanceOf; + + Apply( + TypeApply( + Select(value, sym), + List(TypeTree(tpe))), + List()) + } + + def mkAsInstanceOf(value: Tree, tpe: Type): Tree = { + val afterTAV = global.phase >= global.typesAsValuesPhase; + mkAsInstanceOf(value, tpe, afterTAV); + } + } |