shortening of str and vec
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import mem:*
|
||||
import string:*
|
||||
import vector:*
|
||||
import str:*
|
||||
import vec:*
|
||||
import set:*
|
||||
import ast_nodes:*
|
||||
import io:*
|
||||
@@ -31,8 +31,8 @@ adt base_type {
|
||||
fun type_ptr(): *type {
|
||||
return new<type>()->construct()
|
||||
}
|
||||
fun type_ptr(definition: *ast_node): *type return type_ptr(definition, set<string>());
|
||||
fun type_ptr(definition: *ast_node, traits: set<string>): *type {
|
||||
fun type_ptr(definition: *ast_node): *type return type_ptr(definition, set<str>());
|
||||
fun type_ptr(definition: *ast_node, traits: set<str>): *type {
|
||||
return new<type>()->construct(definition, traits)
|
||||
}
|
||||
fun type_ptr(base: base_type): *type return type_ptr(base, 0, false);
|
||||
@@ -40,22 +40,22 @@ fun type_ptr(base: base_type, indirection: int): *type return type_ptr(base, ind
|
||||
fun type_ptr(base: base_type, indirection: int, is_ref: bool): *type {
|
||||
return new<type>()->construct(base, indirection, is_ref)
|
||||
}
|
||||
fun type_ptr(parameters: vector<*type>, return_type: *type, indirection: int, is_ref: bool, is_variadic: bool, is_raw: bool): *type
|
||||
fun type_ptr(parameters: vec<*type>, return_type: *type, indirection: int, is_ref: bool, is_variadic: bool, is_raw: bool): *type
|
||||
return new<type>()->construct(parameters, return_type, indirection, is_ref, is_variadic, is_raw)
|
||||
|
||||
fun type_ptr(traits: set<string>): *type {
|
||||
fun type_ptr(traits: set<str>): *type {
|
||||
return new<type>()->construct(traits)
|
||||
}
|
||||
|
||||
obj type (Object) {
|
||||
var base: base_type
|
||||
var parameter_types: vector<*type>
|
||||
var parameter_types: vec<*type>
|
||||
var is_variadic: bool
|
||||
var is_raw: bool
|
||||
var return_type: *type
|
||||
var indirection: int
|
||||
var type_def: *ast_node
|
||||
var traits: set<string>
|
||||
var traits: set<str>
|
||||
var is_ref: bool
|
||||
fun construct(): *type {
|
||||
base.copy_construct(&base_type::none())
|
||||
@@ -69,7 +69,7 @@ obj type (Object) {
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(traits_in: set<string>): *type {
|
||||
fun construct(traits_in: set<str>): *type {
|
||||
base.copy_construct(&base_type::template_type())
|
||||
parameter_types.construct()
|
||||
indirection = 0
|
||||
@@ -93,7 +93,7 @@ obj type (Object) {
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(type_def_in: *ast_node, traits_in: set<string>): *type {
|
||||
fun construct(type_def_in: *ast_node, traits_in: set<str>): *type {
|
||||
base.copy_construct(&base_type::object())
|
||||
parameter_types.construct()
|
||||
indirection = 0
|
||||
@@ -105,7 +105,7 @@ obj type (Object) {
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(parameter_types_in: vector<*type>, return_type_in: *type, indirection_in: int, is_ref_in: bool, is_variadic_in: bool, is_raw_in: bool): *type {
|
||||
fun construct(parameter_types_in: vec<*type>, return_type_in: *type, indirection_in: int, is_ref_in: bool, is_variadic_in: bool, is_raw_in: bool): *type {
|
||||
base.copy_construct(&base_type::function())
|
||||
parameter_types.copy_construct(¶meter_types_in)
|
||||
return_type = return_type_in
|
||||
@@ -151,16 +151,16 @@ obj type (Object) {
|
||||
return base == other.base && deref_equality(return_type, other.return_type) &&
|
||||
indirection == other.indirection && deref_equality(type_def, other.type_def) && traits == other.traits
|
||||
}
|
||||
fun to_string(): string return to_string(true);
|
||||
fun to_string(include_traits: bool): string {
|
||||
var trait_string = string()
|
||||
fun to_string(): str return to_string(true);
|
||||
fun to_string(include_traits: bool): str {
|
||||
var trait_string = str()
|
||||
if (include_traits) {
|
||||
trait_string = string(":[")
|
||||
traits.for_each(fun(t: string) trait_string += t;)
|
||||
trait_string = str(":[")
|
||||
traits.for_each(fun(t: str) trait_string += t;)
|
||||
trait_string += "] "
|
||||
}
|
||||
|
||||
var indr_string = string("")
|
||||
var indr_string = str("")
|
||||
if (is_ref)
|
||||
indr_string += " ref "
|
||||
if (is_variadic)
|
||||
@@ -169,30 +169,30 @@ obj type (Object) {
|
||||
indr_string += " raw "
|
||||
for (var i = 0; i < indirection; i++;) indr_string += "*"
|
||||
match (base) {
|
||||
base_type::none() return indr_string + string("none") + trait_string
|
||||
base_type::none() return indr_string + str("none") + trait_string
|
||||
base_type::object() return indr_string + get_ast_name(type_def) + trait_string
|
||||
base_type::no_type_adt_option() return indr_string + "no_type_adt_option" + trait_string
|
||||
base_type::template() return indr_string + string("template") + trait_string
|
||||
base_type::template_type() return indr_string + string("template_type") + trait_string
|
||||
base_type::void_return() return indr_string + string("void_return") + trait_string
|
||||
base_type::boolean() return indr_string + string("boolean") + trait_string
|
||||
base_type::character() return indr_string + string("character") + trait_string
|
||||
base_type::short_int() return indr_string + string("short") + trait_string
|
||||
base_type::integer() return indr_string + string("integer") + trait_string
|
||||
base_type::long_int() return indr_string + string("long") + trait_string
|
||||
base_type::ucharacter() return indr_string + string("ucharacter") + trait_string
|
||||
base_type::ushort_int() return indr_string + string("ushort") + trait_string
|
||||
base_type::uinteger() return indr_string + string("uinteger") + trait_string
|
||||
base_type::ulong_int() return indr_string + string("ulong") + trait_string
|
||||
base_type::floating() return indr_string + string("floating") + trait_string
|
||||
base_type::double_precision() return indr_string + string("double_precision") + trait_string
|
||||
base_type::template() return indr_string + str("template") + trait_string
|
||||
base_type::template_type() return indr_string + str("template_type") + trait_string
|
||||
base_type::void_return() return indr_string + str("void_return") + trait_string
|
||||
base_type::boolean() return indr_string + str("boolean") + trait_string
|
||||
base_type::character() return indr_string + str("character") + trait_string
|
||||
base_type::short_int() return indr_string + str("short") + trait_string
|
||||
base_type::integer() return indr_string + str("integer") + trait_string
|
||||
base_type::long_int() return indr_string + str("long") + trait_string
|
||||
base_type::ucharacter() return indr_string + str("ucharacter") + trait_string
|
||||
base_type::ushort_int() return indr_string + str("ushort") + trait_string
|
||||
base_type::uinteger() return indr_string + str("uinteger") + trait_string
|
||||
base_type::ulong_int() return indr_string + str("ulong") + trait_string
|
||||
base_type::floating() return indr_string + str("floating") + trait_string
|
||||
base_type::double_precision() return indr_string + str("double_precision") + trait_string
|
||||
base_type::function() {
|
||||
var temp = indr_string + string("fun(")
|
||||
var temp = indr_string + str("fun(")
|
||||
parameter_types.for_each(fun(parameter_type: *type) temp += parameter_type->to_string() + ", ";)
|
||||
return temp + ")" + return_type->to_string() + trait_string
|
||||
}
|
||||
}
|
||||
return string("impossible type, indirection:") + indirection
|
||||
return str("impossible type, indirection:") + indirection
|
||||
}
|
||||
fun rank(): int {
|
||||
if (indirection > 0)
|
||||
|
||||
Reference in New Issue
Block a user