Commit 3fe3f8b7 authored by Rico Tzschichholz's avatar Rico Tzschichholz

Use type-check to determine a GenericType

parent 84c85848
......@@ -991,7 +991,7 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (node is ValueType && ((ValueType) node).nullable) {
return "POINTER";
} else if (node is PointerType || ((DataType) node).type_parameter != null) {
} else if (node is PointerType || node is GenericType) {
return "POINTER";
} else if (node is ErrorType) {
return "POINTER";
......
......@@ -2678,7 +2678,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
return new CCodeIdentifier (dup_function);
} else if (type.type_parameter != null) {
} else if (type is GenericType) {
string func_name = "%s_dup_func".printf (type.type_parameter.name.down ());
if (type.type_parameter.parent_symbol is Interface) {
......@@ -3176,7 +3176,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return new CCodeConstant ("NULL");
}
return new CCodeIdentifier (unref_function);
} else if (type.type_parameter != null) {
} else if (type is GenericType) {
string func_name = "%s_destroy_func".printf (type.type_parameter.name.down ());
if (type.type_parameter.parent_symbol is Interface) {
......@@ -3382,7 +3382,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
*/
var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new CCodeConstant ("NULL"));
if (type.type_parameter != null) {
if (type is GenericType) {
var parent = type.type_parameter.parent_symbol;
var cl = parent as Class;
if ((!(parent is Method) && !(parent is ObjectTypeSymbol)) || (cl != null && cl.is_compact)) {
......@@ -4118,7 +4118,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return false;
}
if (type.type_parameter != null) {
if (type is GenericType) {
if (is_limited_generic_type (type)) {
return false;
}
......@@ -4144,7 +4144,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return false;
}
if (type.type_parameter != null) {
if (type is GenericType) {
if (is_limited_generic_type (type)) {
return false;
}
......@@ -4287,13 +4287,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return store_temp_value (new GLibValue (type, ccall), node);
} else {
var cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, cexpr, new CCodeConstant ("NULL"));
if (type.type_parameter != null) {
if (type is GenericType) {
// dup functions are optional for type parameters
var cdupnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_dup_func_expression (type, node.source_reference), new CCodeConstant ("NULL"));
cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.AND, cnotnull, cdupnotnull);
}
if (type.type_parameter != null) {
if (type is GenericType) {
// cast from gconstpointer to gpointer as GBoxedCopyFunc expects gpointer
ccall.add_argument (new CCodeCastExpression (cexpr, "gpointer"));
} else {
......@@ -6054,7 +6054,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
|| type is PointerType || type is DelegateType
|| (array_type != null && !array_type.fixed_length)) {
return new CCodeConstant ("NULL");
} else if (type.type_parameter != null) {
} else if (type is GenericType) {
return new CCodeConstant ("NULL");
} else if (type is ErrorType) {
return new CCodeConstant ("NULL");
......
......@@ -50,7 +50,7 @@ public class Vala.GSignalModule : GObjectModule {
}
private string? get_value_type_name_from_type_reference (DataType t) {
if (t is PointerType || t.type_parameter != null) {
if (t is PointerType || t is GenericType) {
return "gpointer";
} else if (t is VoidType) {
return "void";
......@@ -281,7 +281,7 @@ public class Vala.GSignalModule : GObjectModule {
} else {
get_value_function = "g_value_get_pointer";
}
} else if (p.variable_type is PointerType || p.variable_type.type_parameter != null) {
} else if (p.variable_type is PointerType || p.variable_type is GenericType) {
get_value_function = "g_value_get_pointer";
} else if (p.variable_type is ErrorType) {
get_value_function = "g_value_get_pointer";
......@@ -315,7 +315,7 @@ public class Vala.GSignalModule : GObjectModule {
} else {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
}
} else if (return_type.type_parameter != null) {
} else if (return_type is GenericType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
} else if (return_type is ErrorType) {
set_fc = new CCodeFunctionCall (new CCodeIdentifier ("g_value_set_pointer"));
......@@ -400,7 +400,7 @@ public class Vala.GSignalModule : GObjectModule {
csignew.add_argument (marshal_arg);
var params = sig.get_parameters ();
if (sig.return_type is PointerType || sig.return_type.type_parameter != null) {
if (sig.return_type is PointerType || sig.return_type is GenericType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (sig.return_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
......@@ -431,7 +431,7 @@ public class Vala.GSignalModule : GObjectModule {
for (var i = 0; i < ((ArrayType) param.variable_type).rank; i++) {
csignew.add_argument (new CCodeConstant ("G_TYPE_INT"));
}
} else if (param.variable_type is PointerType || param.variable_type.type_parameter != null || param.direction != ParameterDirection.IN) {
} else if (param.variable_type is PointerType || param.variable_type is GenericType || param.direction != ParameterDirection.IN) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
} else if (param.variable_type is ErrorType) {
csignew.add_argument (new CCodeConstant ("G_TYPE_POINTER"));
......
......@@ -212,7 +212,7 @@ public class Vala.ArrayType : ReferenceType {
}
/* temporarily ignore type parameters */
if (target_type.type_parameter != null) {
if (target_type is GenericType) {
return true;
}
......
......@@ -48,7 +48,7 @@ public class Vala.ErrorType : ReferenceType {
public override bool compatible (DataType target_type) {
/* temporarily ignore type parameters */
if (target_type.type_parameter != null) {
if (target_type is GenericType) {
return true;
}
......
......@@ -36,12 +36,12 @@ public class Vala.NullType : ReferenceType {
return target_type.nullable;
}
if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type == null && target_type.type_parameter == null))) {
if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type == null && !(target_type is GenericType)))) {
return true;
}
/* null can be cast to any reference or array type or pointer type */
if (target_type.type_parameter != null ||
if (target_type is GenericType ||
target_type is PointerType ||
target_type.nullable ||
target_type.data_type.get_attribute ("PointerType") != null) {
......
......@@ -74,7 +74,7 @@ public class Vala.PointerType : DataType {
}
/* temporarily ignore type parameters */
if (target_type.type_parameter != null) {
if (target_type is GenericType) {
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment