core :: Sys :: generate_functypes
# Writes all functional types
fun generate_functypes(n: Int, writer: Writer)
do
writer.write("""
# This file is part of NIT ( http://www.nitlanguage.org ).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This module provides functional type to represents various function forms.
# Function types can hold up to 20 arguments. The type `Fun` is for function
# (input and output) and `Proc` is for procedure (input but no output).
# This file is automatically generated, do not edit it manually.
module functional_types
interface Routine
end
interface Fun
super Routine
end
interface Proc
super Routine
end
""")
var templates = new Array[String]
var templates2 = new Array[String]
for i in [0..n[ do
var t1 = new RoutineTemplate("interface", "Fun{i}", i, ["Fun"], true)
var t2 = new RoutineTemplate("interface", "Proc{i}", i, ["Proc"], false)
templates.push(t1.to_s)
templates.push(t2.to_s)
# We want routine ref to be at the end of the file
var t3 = new RoutineTemplate("universal", "FunRef{i}", i, ["Fun{i}{t1.classparams}"], true)
var procsuper = "Proc{i}"
if i > 0 then procsuper = "Proc{i}{t2.classparams}"
var t4 = new RoutineTemplate("universal", "ProcRef{i}", i, [procsuper], false)
t3.annotation = "is intern"
t3.is_redef = true
t4.annotation = "is intern"
t4.is_redef = true
templates2.push(t3.to_s)
templates2.push(t4.to_s)
end
templates.add_all(templates2)
templates.add(
"""
universal RoutineRef
end
""")
writer.write(templates.join("\n"))
end
lib/functional/functional_gen.nit:85,1--145,3