Groundwork for closure lowering, run raw function pointer type
This commit is contained in:
@@ -40,12 +40,8 @@ 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): *type return type_ptr(parameters, return_type, 0, false, false);
|
||||
fun type_ptr(parameters: vector<*type>, return_type: *type, indirection: int): *type return type_ptr(parameters, return_type, indirection, false, false)
|
||||
fun type_ptr(parameters: vector<*type>, return_type: *type, indirection: int, is_ref: bool): *type
|
||||
return new<type>()->construct(parameters, return_type, indirection, is_ref, false)
|
||||
fun type_ptr(parameters: vector<*type>, return_type: *type, indirection: int, is_ref: bool, is_variadic: bool): *type
|
||||
return new<type>()->construct(parameters, return_type, indirection, is_ref, is_variadic)
|
||||
fun type_ptr(parameters: vector<*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 {
|
||||
return new<type>()->construct(traits)
|
||||
@@ -55,6 +51,7 @@ obj type (Object) {
|
||||
var base: base_type
|
||||
var parameter_types: vector<*type>
|
||||
var is_variadic: bool
|
||||
var is_raw: bool
|
||||
var return_type: *type
|
||||
var indirection: int
|
||||
var type_def: *ast_node
|
||||
@@ -69,6 +66,7 @@ obj type (Object) {
|
||||
traits.construct()
|
||||
is_ref = false
|
||||
is_variadic = false
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(traits_in: set<string>): *type {
|
||||
@@ -80,6 +78,7 @@ obj type (Object) {
|
||||
traits.copy_construct(&traits_in)
|
||||
is_ref = false
|
||||
is_variadic = false
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(base_in: base_type, indirection_in: int, is_ref_in: bool): *type {
|
||||
@@ -91,6 +90,7 @@ obj type (Object) {
|
||||
traits.construct()
|
||||
is_ref = is_ref_in
|
||||
is_variadic = false
|
||||
is_raw = false
|
||||
return this
|
||||
}
|
||||
fun construct(type_def_in: *ast_node, traits_in: set<string>): *type {
|
||||
@@ -102,9 +102,10 @@ obj type (Object) {
|
||||
traits.copy_construct(&traits_in)
|
||||
is_ref = false
|
||||
is_variadic = false
|
||||
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): *type {
|
||||
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 {
|
||||
base.copy_construct(&base_type::function())
|
||||
parameter_types.copy_construct(¶meter_types_in)
|
||||
return_type = return_type_in
|
||||
@@ -113,6 +114,7 @@ obj type (Object) {
|
||||
traits.construct()
|
||||
is_ref = is_ref_in
|
||||
is_variadic = is_variadic_in
|
||||
is_raw = is_raw_in
|
||||
return this
|
||||
}
|
||||
fun copy_construct(old: *type) {
|
||||
@@ -124,6 +126,7 @@ obj type (Object) {
|
||||
traits.copy_construct(&old->traits)
|
||||
is_ref = old->is_ref
|
||||
is_variadic = old->is_variadic
|
||||
is_raw = old->is_raw
|
||||
}
|
||||
fun operator=(other: ref type) {
|
||||
destruct()
|
||||
@@ -138,7 +141,7 @@ obj type (Object) {
|
||||
fun operator==(other: ref type):bool return equality(other, true);
|
||||
fun equality(other: *type, care_about_ref: bool):bool return equality(*other, care_about_ref);
|
||||
fun equality(other: ref type, care_about_ref: bool):bool {
|
||||
if (parameter_types.size != other.parameter_types.size || is_variadic != other.is_variadic)
|
||||
if (parameter_types.size != other.parameter_types.size || is_variadic != other.is_variadic || is_raw != other.is_raw)
|
||||
return false
|
||||
for (var i = 0; i < parameter_types.size; i++;)
|
||||
if (!deref_equality(parameter_types[i], other.parameter_types[i]))
|
||||
@@ -162,6 +165,8 @@ obj type (Object) {
|
||||
indr_string += " ref "
|
||||
if (is_variadic)
|
||||
indr_string += " variadic "
|
||||
if (is_raw)
|
||||
indr_string += " raw "
|
||||
for (var i = 0; i < indirection; i++;) indr_string += "*"
|
||||
match (base) {
|
||||
base_type::none() return indr_string + string("none") + trait_string
|
||||
|
||||
Reference in New Issue
Block a user