}
public override bool compatible (DataType target_type) {
- if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
- if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type) && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null) {
+ if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol) && element_type.type_symbol == CodeContext.get ().root.scope.lookup ("string")) {
// allow implicit conversion from string[] to GValue
return true;
}
- if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.data_type)) {
+ if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.type_symbol)) {
// allow implicit conversion to GVariant
return true;
}
}
- if (target_type is PointerType || (target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) {
+ if (target_type is PointerType || (target_type.type_symbol != null && target_type.type_symbol.get_attribute ("PointerType") != null)) {
/* any array type can be cast to a generic pointer */
return true;
}
} else if (left is ElementAccess) {
var ea = (ElementAccess) left;
- if (ea.container.value_type.data_type == context.analyzer.string_type.data_type) {
+ if (ea.container.value_type.type_symbol == context.analyzer.string_type.type_symbol) {
error = true;
Report.error (ea.source_reference, "strings are immutable");
return false;
return false;
} else {
foreach (var base_type in context.analyzer.current_class.get_base_types ()) {
- if (base_type.data_type is Class) {
+ if (base_type.type_symbol is Class) {
value_type = base_type.copy ();
value_type.value_owned = false;
}
}
}
- symbol_reference = value_type.data_type;
+ symbol_reference = value_type.type_symbol;
return !error;
}
}
// enum-type inference
- if (target_type != null && target_type.data_type is Enum
+ if (target_type != null && target_type.type_symbol is Enum
&& (operator == BinaryOperator.BITWISE_AND || operator == BinaryOperator.BITWISE_OR)) {
left.target_type = target_type.copy ();
right.target_type = target_type.copy ();
}
left.check (context);
- if (left.value_type != null && left.value_type.data_type is Enum
+ if (left.value_type != null && left.value_type.type_symbol is Enum
&& (operator == BinaryOperator.EQUALITY || operator == BinaryOperator.INEQUALITY)) {
right.target_type = left.value_type.copy ();
}
right.check (context);
- if (right.value_type != null && right.value_type.data_type is Enum
+ if (right.value_type != null && right.value_type.type_symbol is Enum
&& (operator == BinaryOperator.EQUALITY || operator == BinaryOperator.INEQUALITY)) {
left.target_type = right.value_type.copy ();
//TODO bug 666035 -- re-check left how?
right.target_type = right.value_type.copy ();
right.target_type.value_owned = false;
- if (left.value_type.data_type == context.analyzer.string_type.data_type
+ if (left.value_type.type_symbol == context.analyzer.string_type.type_symbol
&& operator == BinaryOperator.PLUS) {
// string concatenation
- if (right.value_type == null || right.value_type.data_type != context.analyzer.string_type.data_type) {
+ if (right.value_type == null || right.value_type.type_symbol != context.analyzer.string_type.type_symbol) {
error = true;
Report.error (source_reference, "Operands must be strings");
return false;
return false;
}
- var offset_type = right.value_type.data_type as Struct;
+ var offset_type = right.value_type.type_symbol as Struct;
if (offset_type != null && offset_type.is_integer_type ()) {
if (operator == BinaryOperator.PLUS
|| operator == BinaryOperator.MINUS) {
if (context.profile == Profile.GOBJECT) {
// Implicit cast for comparsion expression of GValue with other type
- var gvalue_type = context.analyzer.gvalue_type.data_type;
- if ((left.target_type.data_type == gvalue_type && right.target_type.data_type != gvalue_type)
- || (left.target_type.data_type != gvalue_type && right.target_type.data_type == gvalue_type)) {
+ var gvalue_type = context.analyzer.gvalue_type.type_symbol;
+ if ((left.target_type.type_symbol == gvalue_type && right.target_type.type_symbol != gvalue_type)
+ || (left.target_type.type_symbol != gvalue_type && right.target_type.type_symbol == gvalue_type)) {
Expression gvalue_expr;
DataType target_type;
- if (left.target_type.data_type == gvalue_type) {
+ if (left.target_type.type_symbol == gvalue_type) {
gvalue_expr = left;
target_type = right.target_type;
} else {
*/
public class Vala.BooleanType : ValueType {
public BooleanType (Struct type_symbol) {
- base (type_symbol);
+ this.type_symbol = type_symbol;
}
public override DataType copy () {
}
bool is_gvariant (CodeContext context, DataType type) {
- return type.data_type != null && type.data_type.is_subtype_of (context.analyzer.gvariant_type.data_type);
+ return type.type_symbol != null && type.type_symbol.is_subtype_of (context.analyzer.gvariant_type.type_symbol);
}
public override void emit (CodeGenerator codegen) {
}
foreach (DataType base_type in base_types) {
- if (base_type.data_type != null && base_type.data_type.is_subtype_of (t)) {
+ if (base_type.type_symbol != null && base_type.type_symbol.is_subtype_of (t)) {
return true;
}
}
private void get_all_prerequisites (Interface iface, List<TypeSymbol> list) {
foreach (DataType prereq in iface.get_prerequisites ()) {
- TypeSymbol type = prereq.data_type;
+ TypeSymbol type = prereq.type_symbol;
/* skip on previous errors */
if (type == null) {
continue;
}
foreach (DataType base_type in cl.get_base_types ()) {
- if (base_type.data_type is Class) {
- if (class_is_a ((Class) base_type.data_type, t)) {
+ if (base_type.type_symbol is Class) {
+ if (class_is_a ((Class) base_type.type_symbol, t)) {
return true;
}
- } else if (base_type.data_type == t) {
+ } else if (base_type.type_symbol == t) {
return true;
}
}
}
int n_type_args = base_type_reference.get_type_arguments ().size;
- int n_type_params = ((ObjectTypeSymbol) base_type_reference.data_type).get_type_parameters ().size;
+ int n_type_params = ((ObjectTypeSymbol) base_type_reference.type_symbol).get_type_parameters ().size;
if (n_type_args < n_type_params) {
error = true;
Report.error (base_type_reference.source_reference, "too few type arguments");
/* compact classes cannot implement interfaces */
if (is_compact) {
foreach (DataType base_type in get_base_types ()) {
- if (base_type.data_type is Interface) {
+ if (base_type.type_symbol is Interface) {
error = true;
Report.error (source_reference, "compact classes `%s' may not implement interfaces".printf (get_full_name ()));
}
/* gather all prerequisites */
List<TypeSymbol> prerequisites = new ArrayList<TypeSymbol> ();
foreach (DataType base_type in get_base_types ()) {
- if (base_type.data_type is Interface) {
- get_all_prerequisites ((Interface) base_type.data_type, prerequisites);
+ if (base_type.type_symbol is Interface) {
+ get_all_prerequisites ((Interface) base_type.type_symbol, prerequisites);
}
}
/* check whether all prerequisites are met */
if (source_type == SourceFileType.SOURCE) {
/* all abstract symbols defined in base types have to be at least defined (or implemented) also in this type */
foreach (DataType base_type in get_base_types ()) {
- if (base_type.data_type is Interface) {
- Interface iface = (Interface) base_type.data_type;
+ if (base_type.type_symbol is Interface) {
+ Interface iface = (Interface) base_type.type_symbol;
if (base_class != null && base_class.is_subtype_of (iface)) {
// reimplementation of interface, class is not required to reimplement all methods
foreach (var impl in base_class.get_methods ()) {
if (impl.base_interface_method == m || (base_class != this
&& impl.base_interface_method == null && impl.name == m.name
- && (impl.base_interface_type == null || impl.base_interface_type.data_type == iface)
+ && (impl.base_interface_type == null || impl.base_interface_type.type_symbol == iface)
&& impl.compatible_no_error (m))) {
// method is used as interface implementation, so it is not unused
impl.version.check (source_reference);
} else if (type is ArrayType) {
var array_type = type as ArrayType;
return check_const_type (array_type.element_type, context);
- } else if (type.data_type.is_subtype_of (context.analyzer.string_type.data_type)) {
+ } else if (type.type_symbol.is_subtype_of (context.analyzer.string_type.type_symbol)) {
return true;
} else {
return false;
public bool nullable { get; set; }
/**
- * The referred data type.
+ * The referred type symbol.
*/
- public weak TypeSymbol data_type { get; set; }
+ public weak TypeSymbol type_symbol { get; set; }
/**
* Specifies that the expression transfers a floating reference.
string s;
- if (data_type != null) {
- Symbol global_symbol = data_type;
+ if (type_symbol != null) {
+ Symbol global_symbol = type_symbol;
while (global_symbol.parent_symbol.name != null) {
global_symbol = global_symbol.parent_symbol;
}
}
if (sym != null && global_symbol != sym) {
- s = "global::" + data_type.get_full_name ();;
+ s = "global::" + type_symbol.get_full_name ();;
} else {
- s = data_type.get_full_name ();
+ s = type_symbol.get_full_name ();
}
} else {
s = "null";
if (type2.nullable != nullable) {
return false;
}
- if (type2.data_type != data_type) {
+ if (type2.type_symbol != type_symbol) {
return false;
}
if (type2 is GenericType || this is GenericType) {
return true;
}
- if (type2.data_type != data_type) {
+ if (type2.type_symbol != type_symbol) {
// FIXME: allow this type reference to refer to a
// subtype of the type type2 is referring to
return false;
return false;
}
- if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
- if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type)) {
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null) {
+ if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol)) {
// allow implicit conversion to GValue
return true;
}
- if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.data_type)) {
+ if (target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvariant_type.type_symbol)) {
// allow implicit conversion to GVariant
return true;
}
if (target_type is PointerType) {
/* any reference or array type or pointer type can be cast to a generic pointer */
if (this is GenericType ||
- (data_type != null && (
- data_type.is_reference_type () ||
+ (type_symbol != null && (
+ type_symbol.is_reference_type () ||
this is DelegateType))) {
return true;
}
return false;
}
- if (data_type is Enum && target_type.data_type is Struct && ((Struct) target_type.data_type).is_integer_type ()) {
+ if (type_symbol is Enum && target_type.type_symbol is Struct && ((Struct) target_type.type_symbol).is_integer_type ()) {
return true;
}
}
}
- if (data_type != null && target_type.data_type != null && data_type.is_subtype_of (target_type.data_type)) {
- var base_type = SemanticAnalyzer.get_instance_base_type_for_member(this, target_type.data_type, this);
+ if (type_symbol != null && target_type.type_symbol != null && type_symbol.is_subtype_of (target_type.type_symbol)) {
+ var base_type = SemanticAnalyzer.get_instance_base_type_for_member(this, target_type.type_symbol, this);
// check compatibility of generic type arguments
var base_type_args = base_type.get_type_arguments();
if (base_type_args.size == target_type_args.size) {
return true;
}
- if (data_type is Struct && target_type.data_type is Struct) {
- var expr_struct = (Struct) data_type;
- var expect_struct = (Struct) target_type.data_type;
+ if (type_symbol is Struct && target_type.type_symbol is Struct) {
+ var expr_struct = (Struct) type_symbol;
+ var expect_struct = (Struct) target_type.type_symbol;
/* integer types may be implicitly cast to floating point types */
if (expr_struct.is_integer_type () && expect_struct.is_floating_type ()) {
}
public virtual bool is_reference_type_or_type_parameter () {
- return (data_type != null &&
- data_type.is_reference_type ()) ||
+ return (type_symbol != null &&
+ type_symbol.is_reference_type ()) ||
this is GenericType;
}
return false;
}
}
- if (data_type != null) {
- return data_type.is_accessible (sym);
+ if (type_symbol != null) {
+ return type_symbol.is_accessible (sym);
}
return true;
}
public virtual Symbol? get_member (string member_name) {
- if (data_type != null) {
- return SemanticAnalyzer.symbol_lookup_inherited (data_type, member_name);
+ if (type_symbol != null) {
+ return SemanticAnalyzer.symbol_lookup_inherited (type_symbol, member_name);
}
return null;
}
* is a struct which is not a simple (fundamental) type.
*/
public virtual bool is_real_struct_type () {
- var s = data_type as Struct;
+ unowned Struct? s = type_symbol as Struct;
if (s != null && !s.is_simple_type ()) {
return true;
}
}
public bool is_non_null_simple_type () {
- unowned Struct s = data_type as Struct;
+ unowned Struct? s = type_symbol as Struct;
if (s != null && s.is_simple_type ()) {
return !nullable;
}
}
return string.nfill (array_type.rank, 'a') + element_type_signature;
- } else if (data_type != null && data_type is Enum && data_type.get_attribute_bool ("DBus", "use_string_marshalling")) {
+ } else if (type_symbol != null && type_symbol is Enum && type_symbol.get_attribute_bool ("DBus", "use_string_marshalling")) {
return "s";
- } else if (data_type != null) {
- string sig = data_type.get_attribute_string ("CCode", "type_signature");
+ } else if (type_symbol != null) {
+ string sig = type_symbol.get_attribute_string ("CCode", "type_signature");
- unowned Struct? st = data_type as Struct;
- unowned Enum? en = data_type as Enum;
+ unowned Struct? st = type_symbol as Struct;
+ unowned Enum? en = type_symbol as Enum;
if (sig == null && st != null) {
var str = new StringBuilder ();
str.append_c ('(');
}
if (sig == null &&
- (data_type.get_full_name () == "GLib.UnixInputStream" ||
- data_type.get_full_name () == "GLib.UnixOutputStream" ||
- data_type.get_full_name () == "GLib.Socket")) {
+ (type_symbol.get_full_name () == "GLib.UnixInputStream" ||
+ type_symbol.get_full_name () == "GLib.UnixOutputStream" ||
+ type_symbol.get_full_name () == "GLib.Socket")) {
return "h";
}
private Method? to_string_method;
public EnumValueType (Enum type_symbol) {
- base (type_symbol);
+ this.type_symbol = type_symbol;
}
public override DataType copy () {
public ErrorType (ErrorDomain? error_domain, ErrorCode? error_code, SourceReference? source_reference = null) {
this.error_domain = error_domain;
- this.data_type = error_domain;
+ this.type_symbol = error_domain;
this.error_code = error_code;
this.source_reference = source_reference;
}
*/
public class Vala.FloatingType : ValueType {
public FloatingType (Struct type_symbol) {
- base (type_symbol);
+ this.type_symbol = type_symbol;
}
public override DataType copy () {
node.get_error_types (error_types);
foreach (DataType error_data_type in error_types) {
var error_type = error_data_type as ErrorType;
- var error_class = error_data_type.data_type as Class;
+ var error_class = error_data_type.type_symbol as Class;
current_block = last_block;
unreachable_reported = true;
if (catch_clause.error_type != null) {
if (context.profile == Profile.GOBJECT) {
var error_type = (ErrorType) catch_clause.error_type;
- jump_stack.add (new JumpTarget.error_target (error_block, catch_clause, catch_clause.error_type.data_type as ErrorDomain, error_type.error_code, null));
+ jump_stack.add (new JumpTarget.error_target (error_block, catch_clause, catch_clause.error_type.type_symbol as ErrorDomain, error_type.error_code, null));
} else {
- var error_class = catch_clause.error_type.data_type as Class;
+ var error_class = catch_clause.error_type.type_symbol as Class;
jump_stack.add (new JumpTarget.error_target (error_block, catch_clause, null, null, error_class));
}
} else {
var unresolved_symbol = ((UnresolvedType) prereq).unresolved_symbol;
sym = resolve_symbol (iface_node.parent, unresolved_symbol);
} else {
- sym = prereq.data_type;
+ sym = prereq.type_symbol;
}
if (sym is Class) {
has_instantiable_prereq = true;
simple_type = true;
} else {
base_type = alias.base_type;
- type_sym = base_type.data_type;
+ type_sym = base_type.type_symbol;
if (type_sym != null) {
base_node = resolve_node (alias.parent, parse_symbol_from_string (type_sym.get_full_name (), alias.source_reference));
}
if (type is UnresolvedType) {
st = resolve_symbol (node.parent, ((UnresolvedType) type).unresolved_symbol) as Struct;
} else if (type is ValueType) {
- st = type.data_type as Struct;
+ st = type.type_symbol as Struct;
}
if (st != null && st.is_simple_type ()) {
type.nullable = false;
}
if (!(parent_node is ArrayCreationExpression) && !requires_constants_only
- && (!(parent_node is InitializerList) || ((InitializerList) parent_node).target_type.data_type is Struct)) {
+ && (!(parent_node is InitializerList) || ((InitializerList) parent_node).target_type.type_symbol is Struct)) {
// transform shorthand form
// int[] array = { 42 };
// into
foreach (Expression e in get_initializers ()) {
e.target_type = inner_target_type;
}
- } else if (target_type.data_type is Struct) {
+ } else if (target_type.type_symbol is Struct) {
/* initializer is used as struct initializer */
- var st = (Struct) target_type.data_type;
+ var st = (Struct) target_type.type_symbol;
while (st.base_struct != null) {
st = st.base_struct;
}
string? literal_type_name;
public IntegerType (Struct type_symbol, string? literal_value = null, string? literal_type_name = null) {
- base (type_symbol);
+ this.type_symbol = type_symbol;
this.literal_value = literal_value;
this.literal_type_name = literal_type_name;
}
}
public override bool compatible (DataType target_type) {
- if (target_type.data_type is Struct && literal_type_name == "int") {
+ if (target_type.type_symbol is Struct && literal_type_name == "int") {
// int literals are implicitly convertible to integer types
// of a lower rank if the value of the literal is within
// the range of the target type
- var target_st = (Struct) target_type.data_type;
+ var target_st = (Struct) target_type.type_symbol;
if (target_st.is_integer_type ()) {
var int_attr = target_st.get_attribute ("IntegerType");
if (int_attr != null && int_attr.has_argument ("min") && int_attr.has_argument ("max")) {
return true;
}
}
- } else if (target_type.data_type is Enum && (literal_type_name == "int" || literal_type_name == "uint")) {
+ } else if (target_type.type_symbol is Enum && (literal_type_name == "int" || literal_type_name == "uint")) {
// allow implicit conversion from 0 to enum and flags types
if (int.parse (literal_value) == 0) {
return true;
}
foreach (DataType prerequisite in prerequisites) {
- if (prerequisite.data_type != null && prerequisite.data_type.is_subtype_of (t)) {
+ if (prerequisite.type_symbol != null && prerequisite.type_symbol.is_subtype_of (t)) {
return true;
}
}
/* check prerequisites */
Class prereq_class = null;
foreach (DataType prereq in get_prerequisites ()) {
- TypeSymbol class_or_interface = prereq.data_type;
+ TypeSymbol class_or_interface = prereq.type_symbol;
/* skip on previous errors */
if (class_or_interface == null) {
error = true;
var block = new Block (source_reference);
block.scope.parent_scope = method.scope;
- if (method.return_type.data_type != null) {
+ if (method.return_type.type_symbol != null) {
block.add_statement (new ReturnStatement (expression_body, source_reference));
} else {
block.add_statement (new ExpressionStatement (expression_body, source_reference));
if (pointer_member_access) {
symbol_reference = inner.value_type.get_pointer_member (member_name);
} else {
- if (inner.value_type.data_type != null) {
- base_symbol = inner.value_type.data_type;
+ if (inner.value_type.type_symbol != null) {
+ base_symbol = inner.value_type.type_symbol;
}
symbol_reference = inner.value_type.get_member (member_name);
}
var prop = new DynamicProperty (inner.value_type, member_name, source_reference);
prop.access = SymbolAccessibility.PUBLIC;
prop.set_accessor = new PropertyAccessor (false, true, false, null, null, prop.source_reference);
- prop.owner = inner.value_type.data_type.scope;
+ prop.owner = inner.value_type.type_symbol.scope;
dynamic_object_type.type_symbol.scope.add (null, prop);
symbol_reference = prop;
}
}
prop.access = SymbolAccessibility.PUBLIC;
prop.get_accessor = new PropertyAccessor (true, false, false, prop.property_type.copy (), null, prop.source_reference);
- prop.owner = inner.value_type.data_type.scope;
+ prop.owner = inner.value_type.type_symbol.scope;
dynamic_object_type.type_symbol.scope.add (null, prop);
symbol_reference = prop;
}
}
// enum-type inference
- if (inner == null && symbol_reference == null && target_type != null && target_type.data_type is Enum) {
- var enum_type = (Enum) target_type.data_type;
+ if (inner == null && symbol_reference == null && target_type != null && target_type.type_symbol is Enum) {
+ var enum_type = (Enum) target_type.type_symbol;
foreach (var val in enum_type.get_values ()) {
if (member_name == val.name) {
symbol_reference = val;
unowned Symbol? base_type = null;
if (inner != null && inner.value_type != null) {
base_type_name = inner.value_type.to_string ();
- base_type = inner.value_type.data_type;
+ base_type = inner.value_type.type_symbol;
} else if (base_symbol != null) {
base_type_name = base_symbol.get_full_name ();
base_type = base_symbol;
// instance type might be a subtype of the parent symbol of the member
// that subtype might not be generic, so do not report an error in that case
var object_type = instance_type as ObjectType;
- if (object_type != null && object_type.type_symbol.has_type_parameters ()
+ if (object_type != null && object_type.object_type_symbol.has_type_parameters ()
&& !instance_type.has_type_arguments ()) {
error = true;
Report.error (inner.source_reference, "missing generic type arguments");
ObjectType object_type = null;
if (parent_symbol is ObjectTypeSymbol) {
object_type = new ObjectType ((ObjectTypeSymbol) parent_symbol);
- foreach (TypeParameter type_parameter in object_type.type_symbol.get_type_parameters ()) {
+ foreach (TypeParameter type_parameter in object_type.object_type_symbol.get_type_parameters ()) {
var type_arg = new GenericType (type_parameter);
type_arg.value_owned = true;
object_type.add_type_argument (type_arg);
Method? invalid_base_match = null;
foreach (DataType type in cl.get_base_types ()) {
- if (type.data_type is Interface) {
- if (base_interface_type != null && base_interface_type.data_type != type.data_type) {
+ if (type.type_symbol is Interface) {
+ if (base_interface_type != null && base_interface_type.type_symbol != type.type_symbol) {
continue;
}
- var sym = type.data_type.scope.lookup (name);
+ var sym = type.type_symbol.scope.lookup (name);
if (sym is Signal) {
var sig = (Signal) sym;
sym = sig.default_handler;
error = true;
Report.error (param.source_reference, "Reference parameters are not supported for async methods");
}
- if (!external_package && coroutine && (param.ellipsis || param.variable_type.data_type == context.analyzer.va_list_type.data_type)) {
+ if (!external_package && coroutine && (param.ellipsis || param.variable_type.type_symbol == context.analyzer.va_list_type.type_symbol)) {
error = true;
Report.error (param.source_reference, "Variadic parameters are not supported for async methods");
return false;
}
if (return_type is VoidType) {
- } else if (return_type.data_type == context.analyzer.int_type.data_type) {
+ } else if (return_type.type_symbol == context.analyzer.int_type.type_symbol) {
} else {
// return type must be void or int
return false;
}
var array_type = (ArrayType) param.variable_type;
- if (array_type.element_type.data_type != context.analyzer.string_type.data_type) {
+ if (array_type.element_type.type_symbol != context.analyzer.string_type.type_symbol) {
// parameter must be an array of strings
return false;
}
/* Check for constructv chain up */
if (base_cm != null && base_cm.is_variadic () && args.size == base_cm.get_parameters ().size) {
var this_last_arg = args[args.size-1];
- if (this_last_arg.value_type is StructValueType && this_last_arg.value_type.data_type == context.analyzer.va_list_type.data_type) {
+ if (this_last_arg.value_type is StructValueType && this_last_arg.value_type.type_symbol == context.analyzer.va_list_type.type_symbol) {
is_constructv_chainup = true;
}
}
return target_type.nullable;
}
- if (!(target_type is PointerType) && (target_type is NullType || (target_type.data_type == null && !(target_type is GenericType)))) {
+ if (!(target_type is PointerType) && (target_type is NullType || (target_type.type_symbol == null && !(target_type is GenericType)))) {
return true;
}
if (target_type is GenericType ||
target_type is PointerType ||
target_type.nullable ||
- target_type.data_type.get_attribute ("PointerType") != null) {
+ target_type.type_symbol.get_attribute ("PointerType") != null) {
return true;
}
- if (target_type.data_type.is_reference_type () ||
+ if (target_type.type_symbol.is_reference_type () ||
target_type is ArrayType ||
target_type is DelegateType) {
return true;
type_reference.add_type_argument (type_arg);
}
} else {
- type = type_reference.data_type;
+ type = type_reference.type_symbol;
}
value_type = type_reference.copy ();
/**
* The referred class or interface.
*/
- public weak ObjectTypeSymbol type_symbol { get; set; }
+ public weak ObjectTypeSymbol object_type_symbol { get; set; }
public ObjectType (ObjectTypeSymbol type_symbol) {
this.type_symbol = type_symbol;
- data_type = type_symbol;
+ this.object_type_symbol = type_symbol;
}
public override DataType copy () {
- var result = new ObjectType (type_symbol);
+ var result = new ObjectType (object_type_symbol);
result.source_reference = source_reference;
result.value_owned = value_owned;
result.nullable = nullable;
}
int n_type_args = get_type_arguments ().size;
- if (n_type_args > 0 && n_type_args < type_symbol.get_type_parameters ().size) {
+ if (n_type_args > 0 && n_type_args < object_type_symbol.get_type_parameters ().size) {
Report.error (source_reference, "too few type arguments");
return false;
- } else if (n_type_args > 0 && n_type_args > type_symbol.get_type_parameters ().size) {
+ } else if (n_type_args > 0 && n_type_args > object_type_symbol.get_type_parameters ().size) {
Report.error (source_reference, "too many type arguments");
return false;
}
return base_type.compatible (tt.base_type);
}
- if ((target_type.data_type != null && target_type.data_type.get_attribute ("PointerType") != null)) {
+ if ((target_type.type_symbol != null && target_type.type_symbol.get_attribute ("PointerType") != null)) {
return true;
}
return base_type.compatible (target_type);
}
- if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null && target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type)) {
+ if (CodeContext.get ().profile == Profile.GOBJECT && target_type.type_symbol != null && target_type.type_symbol.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.type_symbol)) {
// allow implicit conversion to GValue
return true;
}
}
public override Symbol? get_pointer_member (string member_name) {
- Symbol base_symbol = base_type.data_type;
+ Symbol base_symbol = base_type.type_symbol;
if (base_symbol == null) {
return null;
private void find_base_interface_property (Class cl) {
// FIXME report error if multiple possible base properties are found
foreach (DataType type in cl.get_base_types ()) {
- if (type.data_type is Interface) {
- var sym = type.data_type.scope.lookup (name);
+ if (type.type_symbol is Interface) {
+ var sym = type.type_symbol.scope.lookup (name);
if (sym is Property) {
var base_property = (Property) sym;
if (base_property.is_abstract || base_property.is_virtual) {
// first check interfaces without prerequisites
// (prerequisites can be assumed to be met already)
foreach (DataType base_type in cl.get_base_types ()) {
- if (base_type.data_type is Interface) {
- result = base_type.data_type.scope.lookup (name);
+ if (base_type.type_symbol is Interface) {
+ result = base_type.type_symbol.scope.lookup (name);
if (result != null) {
return result;
}
} else if (sym is Struct) {
var st = (Struct) sym;
if (st.base_type != null) {
- result = symbol_lookup_inherited (st.base_type.data_type, name);
+ result = symbol_lookup_inherited (st.base_type.type_symbol, name);
if (result != null) {
return result;
}
var iface = (Interface) sym;
// first check interface prerequisites recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
- if (prerequisite.data_type is Interface) {
- result = symbol_lookup_inherited (prerequisite.data_type, name);
+ if (prerequisite.type_symbol is Interface) {
+ result = symbol_lookup_inherited (prerequisite.type_symbol, name);
if (result != null) {
return result;
}
}
// then check class prerequisite recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
- if (prerequisite.data_type is Class) {
- result = symbol_lookup_inherited (prerequisite.data_type, name);
+ if (prerequisite.type_symbol is Class) {
+ result = symbol_lookup_inherited (prerequisite.type_symbol, name);
if (result != null) {
return result;
}
}
public bool is_gobject_property_type (DataType property_type) {
- var st = property_type.data_type as Struct;
+ var st = property_type.type_symbol as Struct;
if (st != null) {
if (!st.is_simple_type () && st.get_attribute_bool ("CCode", "has_type_id", true)) {
// Allow GType-based struct types
}
}
- if (property_type is ArrayType && ((ArrayType) property_type).element_type.data_type != string_type.data_type) {
+ if (property_type is ArrayType && ((ArrayType) property_type).element_type.type_symbol != string_type.type_symbol) {
return false;
}
private static DataType? get_instance_base_type (DataType instance_type, DataType base_type, CodeNode node_reference) {
// construct a new type reference for the base type with correctly linked type arguments
DataType instance_base_type;
- if (base_type.data_type is ObjectTypeSymbol) {
- instance_base_type = new ObjectType ((ObjectTypeSymbol) base_type.data_type);
- } else if (base_type.data_type is Struct) {
- instance_base_type = new StructValueType ((Struct) base_type.data_type);
+ if (base_type.type_symbol is ObjectTypeSymbol) {
+ instance_base_type = new ObjectType ((ObjectTypeSymbol) base_type.type_symbol);
+ } else if (base_type.type_symbol is Struct) {
+ instance_base_type = new StructValueType ((Struct) base_type.type_symbol);
} else {
assert_not_reached ();
}
if (instance_type is DelegateType && ((DelegateType) instance_type).delegate_symbol == type_symbol) {
return instance_type;
- } else if (instance_type.data_type == type_symbol) {
+ } else if (instance_type.type_symbol == type_symbol) {
return instance_type;
}
DataType instance_base_type = null;
// use same algorithm as symbol_lookup_inherited
- if (instance_type.data_type is Class) {
- var cl = (Class) instance_type.data_type;
+ if (instance_type.type_symbol is Class) {
+ unowned Class cl = (Class) instance_type.type_symbol;
// first check interfaces without prerequisites
// (prerequisites can be assumed to be met already)
foreach (DataType base_type in cl.get_base_types ()) {
- if (base_type.data_type is Interface) {
+ if (base_type.type_symbol is Interface) {
instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
// then check base class recursively
if (instance_base_type == null) {
foreach (DataType base_type in cl.get_base_types ()) {
- if (base_type.data_type is Class) {
+ if (base_type.type_symbol is Class) {
instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
}
}
- } else if (instance_type.data_type is Struct) {
- var st = (Struct) instance_type.data_type;
+ } else if (instance_type.type_symbol is Struct) {
+ unowned Struct st = (Struct) instance_type.type_symbol;
if (st.base_type != null) {
instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, st.base_type, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
}
}
- } else if (instance_type.data_type is Interface) {
- var iface = (Interface) instance_type.data_type;
+ } else if (instance_type.type_symbol is Interface) {
+ unowned Interface iface = (Interface) instance_type.type_symbol;
// first check interface prerequisites recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
- if (prerequisite.data_type is Interface) {
+ if (prerequisite.type_symbol is Interface) {
instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
if (instance_base_type == null) {
// then check class prerequisite recursively
foreach (DataType prerequisite in iface.get_prerequisites ()) {
- if (prerequisite.data_type is Class) {
+ if (prerequisite.type_symbol is Class) {
instance_base_type = get_instance_base_type_for_member (get_instance_base_type (instance_type, prerequisite, node_reference), type_symbol, node_reference);
if (instance_base_type != null) {
return instance_base_type;
if (instance_type is DelegateType) {
param_index = ((DelegateType) instance_type).delegate_symbol.get_type_parameter_index (generic_type.type_parameter.name);
} else {
- param_index = instance_type.data_type.get_type_parameter_index (generic_type.type_parameter.name);
+ param_index = instance_type.type_symbol.get_type_parameter_index (generic_type.type_parameter.name);
}
if (param_index == -1) {
if (node_reference != null) {
}
public void visit_member_initializer (MemberInitializer init, DataType type) {
- init.symbol_reference = symbol_lookup_inherited (type.data_type, init.name);
+ init.symbol_reference = symbol_lookup_inherited (type.type_symbol, init.name);
if (!(init.symbol_reference is Field || init.symbol_reference is Property)) {
init.error = true;
- Report.error (init.source_reference, "Invalid member `%s' in `%s'".printf (init.name, type.data_type.get_full_name ()));
+ Report.error (init.source_reference, "Invalid member `%s' in `%s'".printf (init.name, type.type_symbol.get_full_name ()));
return;
}
if (init.symbol_reference.access != SymbolAccessibility.PUBLIC) {
}
Struct? get_arithmetic_struct (DataType type) {
- var result = type.data_type as Struct;
+ unowned Struct? result = type.type_symbol as Struct;
if (result == null && type is EnumValueType) {
- return (Struct) int_type.data_type;
+ return (Struct) int_type.type_symbol;
}
return result;
}
}
public bool is_reference_type_argument (DataType type_arg) {
- if (type_arg is ErrorType || (type_arg.data_type != null && type_arg.data_type.is_reference_type ())) {
+ if (type_arg is ErrorType || (type_arg.type_symbol != null && type_arg.type_symbol.is_reference_type ())) {
return true;
} else {
return false;
}
public bool is_signed_integer_type_argument (DataType type_arg) {
- var st = type_arg.data_type as Struct;
+ unowned Struct? st = type_arg.type_symbol as Struct;
if (type_arg is EnumValueType) {
return true;
} else if (type_arg.nullable) {
return false;
} else if (st == null) {
return false;
- } else if (st.is_subtype_of (bool_type.data_type)) {
+ } else if (st.is_subtype_of (bool_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (char_type.data_type)) {
+ } else if (st.is_subtype_of (char_type.type_symbol)) {
return true;
- } else if (unichar_type != null && st.is_subtype_of (unichar_type.data_type)) {
+ } else if (unichar_type != null && st.is_subtype_of (unichar_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (short_type.data_type)) {
+ } else if (st.is_subtype_of (short_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (int_type.data_type)) {
+ } else if (st.is_subtype_of (int_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (long_type.data_type)) {
+ } else if (st.is_subtype_of (long_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (int8_type.data_type)) {
+ } else if (st.is_subtype_of (int8_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (int16_type.data_type)) {
+ } else if (st.is_subtype_of (int16_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (int32_type.data_type)) {
+ } else if (st.is_subtype_of (int32_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (type_type.data_type)) {
+ } else if (st.is_subtype_of (type_type.type_symbol)) {
return true;
} else {
return false;
}
public bool is_unsigned_integer_type_argument (DataType type_arg) {
- var st = type_arg.data_type as Struct;
+ unowned Struct? st = type_arg.type_symbol as Struct;
if (st == null) {
return false;
} else if (type_arg.nullable) {
return false;
- } else if (st.is_subtype_of (uchar_type.data_type)) {
+ } else if (st.is_subtype_of (uchar_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (ushort_type.data_type)) {
+ } else if (st.is_subtype_of (ushort_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (uint_type.data_type)) {
+ } else if (st.is_subtype_of (uint_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (ulong_type.data_type)) {
+ } else if (st.is_subtype_of (ulong_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (uint8_type.data_type)) {
+ } else if (st.is_subtype_of (uint8_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (uint16_type.data_type)) {
+ } else if (st.is_subtype_of (uint16_type.type_symbol)) {
return true;
- } else if (st.is_subtype_of (uint32_type.data_type)) {
+ } else if (st.is_subtype_of (uint32_type.type_symbol)) {
return true;
} else {
return false;
if (parent_cl != null) {
foreach (DataType base_type in parent_cl.get_base_types ()) {
- if (SemanticAnalyzer.symbol_lookup_inherited (base_type.data_type, name) is Signal) {
+ if (SemanticAnalyzer.symbol_lookup_inherited (base_type.type_symbol, name) is Signal) {
error = true;
Report.error (source_reference, "Signals with the same name as a signal in a base type are not supported");
return false;
public Struct? base_struct {
get {
if (_base_type != null) {
- return _base_type.data_type as Struct;
+ return _base_type.type_symbol as Struct;
}
return null;
}
}
if (base_type != null) {
- if (base_type.data_type != null && base_type.data_type.is_subtype_of (t)) {
+ if (base_type.type_symbol != null && base_type.type_symbol.is_subtype_of (t)) {
return true;
}
}
*/
public class Vala.StructValueType : ValueType {
public StructValueType (Struct type_symbol) {
- base (type_symbol);
+ this.type_symbol = type_symbol;
}
public override bool is_invokable () {
// enum-type inference
var condition_target_type = switch_statement.expression.target_type;
- if (expression.symbol_reference == null && condition_target_type != null && condition_target_type.data_type is Enum) {
- var enum_type = (Enum) condition_target_type.data_type;
+ if (expression.symbol_reference == null && condition_target_type != null && condition_target_type.type_symbol is Enum) {
+ var enum_type = (Enum) condition_target_type.type_symbol;
foreach (var val in enum_type.get_values ()) {
if (expression.to_string () == val.name) {
expression.target_type = condition_target_type.copy ();
cl.base_class = null;
foreach (DataType type in cl.get_base_types ()) {
- if (type.data_type is Class) {
+ if (type.type_symbol is Class) {
if (cl.base_class != null) {
cl.error = true;
- Report.error (type.source_reference, "%s: Classes cannot have multiple base classes (`%s' and `%s')".printf (cl.get_full_name (), cl.base_class.get_full_name (), type.data_type.get_full_name ()));
+ Report.error (type.source_reference, "%s: Classes cannot have multiple base classes (`%s' and `%s')".printf (cl.get_full_name (), cl.base_class.get_full_name (), type.type_symbol.get_full_name ()));
return;
}
- cl.base_class = (Class) type.data_type;
+ cl.base_class = (Class) type.type_symbol;
if (cl.base_class.is_subtype_of (cl)) {
cl.error = true;
Report.error (type.source_reference, "Base class cycle (`%s' and `%s')".printf (cl.get_full_name (), cl.base_class.get_full_name ()));
iface.accept_children (this);
foreach (DataType type in iface.get_prerequisites ()) {
- if (type.data_type != null && type.data_type.is_subtype_of (iface)) {
+ if (type.type_symbol != null && type.type_symbol.is_subtype_of (iface)) {
iface.error = true;
- Report.error (type.source_reference, "Prerequisite cycle (`%s' and `%s')".printf (iface.get_full_name (), type.data_type.get_full_name ()));
+ Report.error (type.source_reference, "Prerequisite cycle (`%s' and `%s')".printf (iface.get_full_name (), type.type_symbol.get_full_name ()));
return;
}
}
return false;
}
- if (type_reference.data_type == null) {
+ if (type_reference.type_symbol == null) {
/* if type resolving didn't succeed, skip this check */
error = true;
return false;
}
bool is_numeric_type (DataType type) {
- if (type.nullable || !(type.data_type is Struct)) {
+ if (type.nullable || !(type.type_symbol is Struct)) {
return false;
}
- var st = (Struct) type.data_type;
+ var st = (Struct) type.type_symbol;
return st.is_integer_type () || st.is_floating_type ();
}
bool is_integer_type (DataType type) {
- if (type.nullable || !(type.data_type is Struct)) {
+ if (type.nullable || !(type.type_symbol is Struct)) {
return false;
}
- var st = (Struct) type.data_type;
+ var st = (Struct) type.type_symbol;
return st.is_integer_type ();
}
* A value type, i.e. a struct or an enum type.
*/
public abstract class Vala.ValueType : DataType {
- /**
- * The referred struct or enum.
- */
- public weak TypeSymbol type_symbol { get; set; }
-
- protected ValueType (TypeSymbol type_symbol) {
- this.type_symbol = type_symbol;
- data_type = type_symbol;
- }
-
public override bool is_disposable () {
if (!value_owned) {
return false;
return true;
}
- var st = type_symbol as Struct;
+ unowned Struct? st = type_symbol as Struct;
if (st != null) {
return st.is_disposable ();
}