2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 class TypeTestDepthNotGenerator
22 redef fun initnit
(res
)
24 res
.add
"new {classes.last}[Root]"
25 for c
in classes
.iterator
.skip_tail
(1) do
26 res
.add
"new {c}[Root]"
32 return "not a isa {classes.last}[Root]"
35 redef fun initjava
(res
, interfaces
)
39 if interfaces
then tagc
= "X"
40 res
.add
"new {tagc}{classes.last}<Root>()"
41 for c
in classes
.iterator
.skip_tail
(1) do
42 res
.add
"new {tagc}{c}<Root>()"
46 redef fun testjava
(interfaces
)
48 return "!(a instanceof {classes.last})"
51 redef fun initcsharp
(res
, interfaces
)
54 if interfaces
then tagc
= "X"
55 res
.add
"new {tagc}{classes.last}<Root>()"
56 for c
in classes
.iterator
.skip_tail
(1) do
57 res
.add
"new {tagc}{c}<Root>()"
61 redef fun testcsharp
(interfaces
)
63 return "!(a is {classes.last}<Root>)"
66 redef fun initscala
(res
, interfaces
)
69 if interfaces
then tagc
= "X"
70 res
.add
"new {tagc}{classes.last}[Root]()"
71 for c
in classes
.iterator
.skip_tail
(1) do
72 res
.add
"new {tagc}{c}[Root]()"
76 redef fun testscala
(interfaces
)
78 return "!a.isInstanceOf[{classes.last}[Root]]"
81 redef fun initcpp
(res
)
83 res
.add
"new {classes.last}<Root>()"
84 for c
in classes
.iterator
.skip_tail
(1) do
85 res
.add
"new {c}<Root>()"
91 write
"\t\t\t{classes.last}<Root> *to = dynamic_cast<{classes.last}<Root>*>(a);"
95 redef fun inite
(res
, se
)
97 res
.add
"create \{{classes.last}[ROOT]\}"
98 for c
in classes
.iterator
.skip_tail
(1) do
99 res
.add
"create \{{c}[ROOT]\}"
105 write
"\t\t\t\t\tto ?= a"
111 write
"\t\t\tto: detachable {classes.last}[ROOT]"
114 redef fun initpython
(res
)
116 res
.add
"{classes.last}()"
117 for c
in classes
.iterator
.skip_tail
(1) do
123 return "not isinstance(a, {classes.last})"
127 var g
= new TypeTestDepthNotGenerator