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.
18 class TypeTestFtsNestingGenerator
21 fun clanit
(i
: Int): String
23 var s
= new FlatBuffer
24 s
.append
("{classes[i]}[")
25 s
.append
("{classes.first}[" * (dept-1
))
31 redef fun initnit
(res
)
34 res
.add
"new {clanit(i)}"
41 return "a isa {clanit(middle)}"
44 fun clajava
(i
: Int): String
46 var s
= new FlatBuffer
47 s
.append
("{classes[i]}<")
48 s
.append
("{classes.first}<" * (dept-1
))
54 redef fun initcsharp
(res
, interfaces
)
57 if interfaces
then tagc
= "X"
59 res
.add
"new {tagc}{clajava(i)}()"
63 redef fun testcsharp
(interfaces
)
65 return "a is {clajava(middle)}"
68 fun clacpp
(i
: Int): String
70 var s
= new FlatBuffer
71 s
.append
("{classes[i]}<")
72 s
.append
("{classes.first}<" * (dept-1
))
78 redef fun initcpp
(res
)
81 res
.add
"new {clacpp(i)}()"
87 write
"\t\t\t{clacpp(middle)} *to = dynamic_cast<{clacpp(middle)}*>(a);"
91 fun clae
(i
: Int): String
93 var s
= new FlatBuffer
94 s
.append
("{classes[i]}[")
95 s
.append
("{classes.first}[" * (dept-1
))
101 redef fun inite
(res
, se
)
103 for i
in [0..dept
[ do
104 res
.add
"create \{{clae(i)}\}"
110 write
"\t\t\t\t\tto ?= a"
116 write
"\t\t\tto: detachable {clae(middle)}"
120 var g
= new TypeTestFtsNestingGenerator