+2007-12-02 Jürg Billeter <j@bitron.ch>
+
+ * vala/valatypesymbol.vala, vala/Makefile.am: rename DataType to
+ Typesymbol
+
+ * vala/*.vala, gobject/*.vala, vapigen/*.vala: adapt after renaming
+
2007-12-01 Jürg Billeter <j@bitron.ch>
* ccode/valaccodeblock.vala: don't emit unreachable code,
codegen.temp_vars.insert (0, temp_decl);
var parse_call = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_parse_name"));
parse_call.add_argument (sig.get_canonical_cconstant ());
- var decl_type = (DataType) sig.parent_symbol;
+ var decl_type = (Typesymbol) sig.parent_symbol;
parse_call.add_argument (new CCodeIdentifier (decl_type.get_type_id ()));
parse_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_decl.name)));
parse_call.add_argument (new CCodeConstant ("NULL"));
public TypeReference string_type;
public TypeReference float_type;
public TypeReference double_type;
- public DataType gtypeinstance_type;
- public DataType gobject_type;
- public DataType gerror_type;
- public DataType glist_type;
- public DataType gslist_type;
- public DataType gstring_type;
- public DataType garray_type;
+ public Typesymbol gtypeinstance_type;
+ public Typesymbol gobject_type;
+ public Typesymbol gerror_type;
+ public Typesymbol glist_type;
+ public Typesymbol gslist_type;
+ public Typesymbol gstring_type;
+ public Typesymbol garray_type;
public TypeReference gquark_type;
public TypeReference mutex_type;
- public DataType type_module_type;
- public DataType iterable_type;
- public DataType iterator_type;
- public DataType list_type;
- public DataType map_type;
- public DataType connection_type;
+ public Typesymbol type_module_type;
+ public Typesymbol iterable_type;
+ public Typesymbol iterator_type;
+ public Typesymbol list_type;
+ public Typesymbol map_type;
+ public Typesymbol connection_type;
Method substring_method;
root_symbol = context.root;
bool_type = new TypeReference ();
- bool_type.data_type = (DataType) root_symbol.scope.lookup ("bool");
+ bool_type.data_type = (Typesymbol) root_symbol.scope.lookup ("bool");
char_type = new TypeReference ();
- char_type.data_type = (DataType) root_symbol.scope.lookup ("char");
+ char_type.data_type = (Typesymbol) root_symbol.scope.lookup ("char");
unichar_type = new TypeReference ();
- unichar_type.data_type = (DataType) root_symbol.scope.lookup ("unichar");
+ unichar_type.data_type = (Typesymbol) root_symbol.scope.lookup ("unichar");
short_type = new TypeReference ();
- short_type.data_type = (DataType) root_symbol.scope.lookup ("short");
+ short_type.data_type = (Typesymbol) root_symbol.scope.lookup ("short");
ushort_type = new TypeReference ();
- ushort_type.data_type = (DataType) root_symbol.scope.lookup ("ushort");
+ ushort_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ushort");
int_type = new TypeReference ();
- int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
+ int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
uint_type = new TypeReference ();
- uint_type.data_type = (DataType) root_symbol.scope.lookup ("uint");
+ uint_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint");
long_type = new TypeReference ();
- long_type.data_type = (DataType) root_symbol.scope.lookup ("long");
+ long_type.data_type = (Typesymbol) root_symbol.scope.lookup ("long");
ulong_type = new TypeReference ();
- ulong_type.data_type = (DataType) root_symbol.scope.lookup ("ulong");
+ ulong_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ulong");
int64_type = new TypeReference ();
- int64_type.data_type = (DataType) root_symbol.scope.lookup ("int64");
+ int64_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int64");
uint64_type = new TypeReference ();
- uint64_type.data_type = (DataType) root_symbol.scope.lookup ("uint64");
+ uint64_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint64");
float_type = new TypeReference ();
- float_type.data_type = (DataType) root_symbol.scope.lookup ("float");
+ float_type.data_type = (Typesymbol) root_symbol.scope.lookup ("float");
double_type = new TypeReference ();
- double_type.data_type = (DataType) root_symbol.scope.lookup ("double");
+ double_type.data_type = (Typesymbol) root_symbol.scope.lookup ("double");
string_type = new TypeReference ();
- string_type.data_type = (DataType) root_symbol.scope.lookup ("string");
+ string_type.data_type = (Typesymbol) root_symbol.scope.lookup ("string");
substring_method = (Method) string_type.data_type.scope.lookup ("substring");
var glib_ns = root_symbol.scope.lookup ("GLib");
- gtypeinstance_type = (DataType) glib_ns.scope.lookup ("TypeInstance");
- gobject_type = (DataType) glib_ns.scope.lookup ("Object");
- gerror_type = (DataType) glib_ns.scope.lookup ("Error");
- glist_type = (DataType) glib_ns.scope.lookup ("List");
- gslist_type = (DataType) glib_ns.scope.lookup ("SList");
- gstring_type = (DataType) glib_ns.scope.lookup ("String");
- garray_type = (DataType) glib_ns.scope.lookup ("Array");
+ gtypeinstance_type = (Typesymbol) glib_ns.scope.lookup ("TypeInstance");
+ gobject_type = (Typesymbol) glib_ns.scope.lookup ("Object");
+ gerror_type = (Typesymbol) glib_ns.scope.lookup ("Error");
+ glist_type = (Typesymbol) glib_ns.scope.lookup ("List");
+ gslist_type = (Typesymbol) glib_ns.scope.lookup ("SList");
+ gstring_type = (Typesymbol) glib_ns.scope.lookup ("String");
+ garray_type = (Typesymbol) glib_ns.scope.lookup ("Array");
gquark_type = new TypeReference ();
- gquark_type.data_type = (DataType) glib_ns.scope.lookup ("Quark");
+ gquark_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Quark");
mutex_type = new TypeReference ();
- mutex_type.data_type = (DataType) glib_ns.scope.lookup ("Mutex");
+ mutex_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Mutex");
- type_module_type = (DataType) glib_ns.scope.lookup ("TypeModule");
+ type_module_type = (Typesymbol) glib_ns.scope.lookup ("TypeModule");
if (context.module_init_method != null) {
module_init_fragment = new CCodeFragment ();
var gee_ns = root_symbol.scope.lookup ("Gee");
if (gee_ns != null) {
- iterable_type = (DataType) gee_ns.scope.lookup ("Iterable");
- iterator_type = (DataType) gee_ns.scope.lookup ("Iterator");
- list_type = (DataType) gee_ns.scope.lookup ("List");
- map_type = (DataType) gee_ns.scope.lookup ("Map");
+ iterable_type = (Typesymbol) gee_ns.scope.lookup ("Iterable");
+ iterator_type = (Typesymbol) gee_ns.scope.lookup ("Iterator");
+ list_type = (Typesymbol) gee_ns.scope.lookup ("List");
+ map_type = (Typesymbol) gee_ns.scope.lookup ("Map");
}
var dbus_ns = root_symbol.scope.lookup ("DBus");
if (dbus_ns != null) {
- connection_type = (DataType) dbus_ns.scope.lookup ("Connection");
+ connection_type = (Typesymbol) dbus_ns.scope.lookup ("Connection");
}
/* we're only interested in non-pkg source files */
public override void visit_constant (Constant! c) {
c.accept_children (this);
- if (c.parent_symbol is DataType) {
- var t = (DataType) c.parent_symbol;
+ if (c.parent_symbol is Typesymbol) {
+ var t = (Typesymbol) c.parent_symbol;
if (!c.is_internal_symbol () && !(c.type_reference.data_type is Array)) {
var cdefine = new CCodeMacroReplacement.with_expression (c.get_cname (), (CCodeExpression) c.initializer.ccodenode);
current_return_type = null;
- var t = (DataType) prop.parent_symbol;
+ var t = (Typesymbol) prop.parent_symbol;
var this_type = new TypeReference ();
this_type.data_type = t;
if (inner_node == null) {
l = new CCodeIdentifier ("self");
} else if (stmt.resource.symbol_reference.parent_symbol != current_type_symbol) {
- l = new InstanceCast ((CCodeExpression) inner_node.ccodenode, (DataType) stmt.resource.symbol_reference.parent_symbol);
+ l = new InstanceCast ((CCodeExpression) inner_node.ccodenode, (Typesymbol) stmt.resource.symbol_reference.parent_symbol);
} else {
l = (CCodeExpression) inner_node.ccodenode;
}
var ma = (MemberAccess) array_expr;
CCodeExpression pub_inst = null;
- DataType base_type = null;
+ Typesymbol base_type = null;
CCodeExpression length_expr = null;
if (ma.inner == null) {
if (current_type_symbol != null) {
/* base type is available if this is a type method */
- base_type = (DataType) current_type_symbol;
+ base_type = (Typesymbol) current_type_symbol;
}
} else {
pub_inst = (CCodeExpression) ma.inner.ccodenode;
var instance_expression_type = new TypeReference ();
instance_expression_type.data_type = base_type;
var instance_target_type = new TypeReference ();
- instance_target_type.data_type = (DataType) field.parent_symbol;
+ instance_target_type.data_type = (Typesymbol) field.parent_symbol;
CCodeExpression typed_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
CCodeExpression inst;
} else {
inst = typed_inst;
}
- if (((DataType) field.parent_symbol).is_reference_type ()) {
+ if (((Typesymbol) field.parent_symbol).is_reference_type ()) {
length_expr = new CCodeMemberAccess.pointer (inst, length_cname);
} else {
length_expr = new CCodeMemberAccess (inst, length_cname);
if (init.symbol_reference is Field) {
var f = (Field) init.symbol_reference;
var instance_target_type = new TypeReference ();
- instance_target_type.data_type = (DataType) f.parent_symbol;
+ instance_target_type.data_type = (Typesymbol) f.parent_symbol;
var typed_inst = get_implicit_cast_expression (instance, expr.type_reference, instance_target_type);
CCodeExpression lhs;
if (expr.type_reference.data_type is Struct) {
visit_expression (expr);
}
- static CCodeFunctionCall create_type_check (CCodeNode! ccodenode, DataType! type) {
+ static CCodeFunctionCall create_type_check (CCodeNode! ccodenode, Typesymbol! type) {
var ccheck = new CCodeFunctionCall (new CCodeIdentifier (type.get_upper_case_cname ("IS_")));
ccheck.add_argument ((CCodeExpression) ccodenode);
return ccheck;
} else if (prop.base_interface_property != null) {
base_property = prop.base_interface_property;
}
- var base_property_type = (DataType) base_property.parent_symbol;
+ var base_property_type = (Typesymbol) base_property.parent_symbol;
set_func = "%s_set_%s".printf (base_property_type.get_lower_case_cname (null), base_property.name);
}
}
var instance_target_type = new TypeReference ();
- instance_target_type.data_type = (DataType) base_property.parent_symbol;
+ instance_target_type.data_type = (Typesymbol) base_property.parent_symbol;
instance = get_implicit_cast_expression (instance, instance_expression_type, instance_target_type);
ccall.add_argument (instance);
return cspec;
}
- private CCodeFunctionCall! get_signal_creation (Signal! sig, DataType! type) {
+ private CCodeFunctionCall! get_signal_creation (Signal! sig, Typesymbol! type) {
var csignew = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_new"));
csignew.add_argument (new CCodeConstant ("\"%s\"".printf (sig.name)));
csignew.add_argument (new CCodeIdentifier (type.get_upper_case_cname ("TYPE_")));
// parent_symbol may be null for late bound methods
if (base_method.parent_symbol != null) {
var instance_target_type = new TypeReference ();
- instance_target_type.data_type = (DataType) base_method.parent_symbol;
+ instance_target_type.data_type = (Typesymbol) base_method.parent_symbol;
instance = get_implicit_cast_expression (instance, instance_expression_type, instance_target_type);
}
using GLib;
public class Vala.CCodeGenerator {
- private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, DataType base_type) {
+ private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, Typesymbol base_type) {
if (expr.symbol_reference is Method) {
var m = (Method) expr.symbol_reference;
var instance_expression_type = new TypeReference ();
instance_expression_type.data_type = base_type;
var instance_target_type = new TypeReference ();
- instance_target_type.data_type = (DataType) f.parent_symbol;
+ instance_target_type.data_type = (Typesymbol) f.parent_symbol;
CCodeExpression typed_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
bool is_gtypeinstance = (instance_target_type.data_type.is_subtype_of (gtypeinstance_type));
} else if (prop.base_interface_property != null) {
base_property = prop.base_interface_property;
}
- var base_property_type = (DataType) base_property.parent_symbol;
+ var base_property_type = (Typesymbol) base_property.parent_symbol;
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_get_%s".printf (base_property_type.get_lower_case_cname (null), base_property.name)));
var instance_expression_type = new TypeReference ();
}
} else if (expr.symbol_reference is Signal) {
var sig = (Signal) expr.symbol_reference;
- var cl = (DataType) sig.parent_symbol;
+ var cl = (Typesymbol) sig.parent_symbol;
if (sig.has_emitter) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
public override void visit_member_access (MemberAccess! expr) {
CCodeExpression pub_inst = null;
- DataType base_type = null;
+ Typesymbol base_type = null;
if (expr.inner == null) {
pub_inst = new CCodeIdentifier ("self");
if (current_type_symbol != null) {
/* base type is available if this is a type method */
- base_type = (DataType) current_type_symbol;
+ base_type = (Typesymbol) current_type_symbol;
if (!base_type.is_reference_type ()) {
pub_inst = new CCodeIdentifier ("(*self)");
this_type.data_type = find_parent_type (m);
if (m.base_interface_method != null && !m.is_abstract && !m.is_virtual) {
var base_type = new TypeReference ();
- base_type.data_type = (DataType) m.base_interface_method.parent_symbol;
+ base_type.data_type = (Typesymbol) m.base_interface_method.parent_symbol;
instance_param = new CCodeFormalParameter ("base", base_type.get_cname ());
} else if (m.overrides) {
var base_type = new TypeReference ();
- base_type.data_type = (DataType) m.base_method.parent_symbol;
+ base_type.data_type = (Typesymbol) m.base_method.parent_symbol;
instance_param = new CCodeFormalParameter ("base", base_type.get_cname ());
} else {
if (m.parent_symbol is Struct && !((Struct) m.parent_symbol).is_simple_type ()) {
vfunc.line = function.line;
var this_type = new TypeReference ();
- this_type.data_type = (DataType) m.parent_symbol;
+ this_type.data_type = (Typesymbol) m.parent_symbol;
var cparam = new CCodeFormalParameter ("self", this_type.get_cname ());
vfunc.add_parameter (cparam);
}
}
- private CCodeStatement create_method_type_check_statement (Method! m, DataType! t, bool non_null, string! var_name) {
+ private CCodeStatement create_method_type_check_statement (Method! m, Typesymbol! t, bool non_null, string! var_name) {
return create_type_check_statement (m, m.return_type.data_type, t, non_null, var_name);
}
- private CCodeStatement create_property_type_check_statement (Property! prop, bool getter, DataType! t, bool non_null, string! var_name) {
+ private CCodeStatement create_property_type_check_statement (Property! prop, bool getter, Typesymbol! t, bool non_null, string! var_name) {
if (getter) {
return create_type_check_statement (prop, prop.type_reference.data_type, t, non_null, var_name);
} else {
}
}
- private CCodeStatement create_type_check_statement (CodeNode! method_node, DataType ret_type, DataType! t, bool non_null, string! var_name) {
+ private CCodeStatement create_type_check_statement (CodeNode! method_node, Typesymbol ret_type, Typesymbol! t, bool non_null, string! var_name) {
var ccheck = new CCodeFunctionCall ();
if ((t is Class && ((Class) t).is_subtype_of (gobject_type)) || (t is Interface && !((Interface) t).declaration_only)) {
return new CCodeExpressionStatement (ccheck);
}
- private CCodeExpression default_value_for_type (DataType! type) {
+ private CCodeExpression default_value_for_type (Typesymbol! type) {
if (type.is_reference_type () || type is Pointer) {
return new CCodeConstant ("NULL");
} else if (type.get_default_value () != null) {
return null;
}
- private DataType find_parent_type (Symbol sym) {
+ private Typesymbol find_parent_type (Symbol sym) {
while (sym != null) {
- if (sym is DataType) {
- return (DataType) sym;
+ if (sym is Typesymbol) {
+ return (Typesymbol) sym;
}
sym = sym.parent_symbol;
}
public override void visit_signal (Signal! sig) {
// parent_symbol may be null for late bound signals
if (sig.parent_symbol != null) {
- var dt = sig.parent_symbol as DataType;
+ var dt = sig.parent_symbol as Typesymbol;
if (!dt.is_subtype_of (gobject_type)) {
sig.error = true;
Report.error (sig.source_reference, "Only classes and interfaces deriving from GLib.Object support signals. `%s' does not derive from GLib.Object.".printf (dt.get_full_name ()));
class_reference = cl;
}
- public override DataType! get_type_declaration () {
+ public override Typesymbol! get_type_declaration () {
return class_reference;
}
set {
_context = value;
- string_type = (DataType) _context.root.scope.lookup ("string");
+ string_type = (Typesymbol) _context.root.scope.lookup ("string");
var dbus_ns = _context.root.scope.lookup ("DBus");
if (dbus_ns != null) {
- connection_type = (DataType) dbus_ns.scope.lookup ("Connection");
- dbus_error_type = (DataType) dbus_ns.scope.lookup ("Error");
+ connection_type = (Typesymbol) dbus_ns.scope.lookup ("Connection");
+ dbus_error_type = (Typesymbol) dbus_ns.scope.lookup ("Error");
}
}
}
private CodeContext _context;
- private DataType string_type;
- private DataType connection_type;
- private DataType dbus_error_type;
+ private Typesymbol string_type;
+ private Typesymbol connection_type;
+ private Typesymbol dbus_error_type;
private Collection<Symbol> symbols = new ArrayList<Symbol> ();
return null;
}
- private bool is_dbus_interface (DataType! t) {
+ private bool is_dbus_interface (Typesymbol! t) {
if (!(t is Interface)) {
return false;
}
interface_reference = iface;
}
- public override DataType! get_type_declaration () {
+ public override Typesymbol! get_type_declaration () {
return interface_reference;
}
*
* @return type to be registered
*/
- public abstract DataType! get_type_declaration ();
+ public abstract Typesymbol! get_type_declaration ();
/**
* Returns the name of the type struct in C code.
valaconstructor.vala \
valacontinuestatement.vala \
valacreationmethod.vala \
- valadatatype.vala \
valadeclarationstatement.vala \
valadestructor.vala \
valadostatement.vala \
valatypeofexpression.vala \
valatypeparameter.vala \
valatypereference.vala \
+ valatypesymbol.vala \
valaunaryexpression.vala \
valavariabledeclarator.vala \
valawhilestatement.vala \
/**
* Represents an array type i.e. everything with direct accessable elements.
*/
-public class Vala.Array : DataType {
+public class Vala.Array : Typesymbol {
/**
- * DataType of which this is an array of.
+ * Typesymbol of which this is an array of.
*/
- public weak DataType element_type { get; set construct; }
+ public weak Typesymbol element_type { get; set construct; }
/**
* TypeParameter of which this is an array of.
private ArrayResizeMethod resize_method;
private ArrayMoveMethod move_method;
- public Array (DataType! _element_type, int _rank, SourceReference _source_reference) {
+ public Array (Typesymbol! _element_type, int _rank, SourceReference _source_reference) {
rank = _rank;
element_type = _element_type;
source_reference = _source_reference;
var root_symbol = source_reference.file.context.root;
length_field.type_reference = new TypeReference ();
- length_field.type_reference.data_type = (DataType) root_symbol.scope.lookup ("int");
+ length_field.type_reference.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
}
return length_field;
var root_symbol = source_reference.file.context.root;
var int_type = new TypeReference ();
- int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
+ int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
resize_method.add_parameter (new FormalParameter ("length", int_type));
var root_symbol = source_reference.file.context.root;
var int_type = new TypeReference ();
- int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
+ int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
move_method.add_parameter (new FormalParameter ("src", int_type));
move_method.add_parameter (new FormalParameter ("dest", int_type));
/**
* Represents a function callback type.
*/
-public class Vala.Callback : DataType {
+public class Vala.Callback : Typesymbol {
/**
* The return type of this callback.
*/
/**
* Represents a class declaration in the source code.
*/
-public class Vala.Class : DataType {
+public class Vala.Class : Typesymbol {
/**
* Specifies the base class.
*/
this.free_function = name;
}
- public override bool is_subtype_of (DataType! t) {
+ public override bool is_subtype_of (Typesymbol! t) {
if (this == t) {
return true;
}
public override string! get_default_cname () {
var parent = parent_symbol;
- assert (parent is DataType);
+ assert (parent is Typesymbol);
if (name.len () == ".new".len ()) {
- return "%snew".printf (((DataType) parent).get_lower_case_cprefix ());
+ return "%snew".printf (((Typesymbol) parent).get_lower_case_cprefix ());
} else {
- return "%snew_%s".printf (((DataType) parent).get_lower_case_cprefix (), name.offset (".new.".len ()));
+ return "%snew_%s".printf (((Typesymbol) parent).get_lower_case_cprefix (), name.offset (".new.".len ()));
}
}
}
/**
* Represents an enum declaration in the source code.
*/
-public class Vala.Enum : DataType {
+public class Vala.Enum : Typesymbol {
/**
* Specifies whether this is a flags enum.
*/
/* valainstancecast.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
/**
* The target type.
*/
- public weak DataType! type_reference { get; set construct; }
+ public weak Typesymbol! type_reference { get; set construct; }
/**
* The expression to be cast.
* @param type the target type
* @return newly created instance cast expression
*/
- public InstanceCast (CCodeExpression! expr, DataType! type) {
+ public InstanceCast (CCodeExpression! expr, Typesymbol! type) {
inner = expr;
type_reference = type;
}
/**
* Represents a class declaration in the source code.
*/
-public class Vala.Interface : DataType {
+public class Vala.Interface : Typesymbol {
/**
* Specifies whether this interface is static. Static interfaces are not
* available at run-time. They can be implemented by structs.
return "g_object_unref";
}
- public override bool is_subtype_of (DataType! t) {
+ public override bool is_subtype_of (Typesymbol! t) {
if (this == t) {
return true;
}
if (m is CreationMethod) {
write_string (" ");
- var datatype = (DataType) m.parent_symbol;
+ var datatype = (Typesymbol) m.parent_symbol;
write_identifier (datatype.name);
write_identifier (m.name.offset (".new".len ()));
} else if (!m.instance) {
/**
* Represents a pointer-type.
*/
-public class Vala.Pointer : DataType {
+public class Vala.Pointer : Typesymbol {
/**
* The type to which this pointer type points.
*/
- public weak DataType! referent_type { get; set construct; }
+ public weak Typesymbol! referent_type { get; set construct; }
private string cname;
- public Pointer (construct DataType! referent_type, construct SourceReference source_reference = null) {
+ public Pointer (construct Typesymbol! referent_type, construct SourceReference source_reference = null) {
}
construct {
TypeReference ulong_type;
TypeReference unichar_type;
TypeReference type_type;
- DataType pointer_type;
- DataType object_type;
- DataType initially_unowned_type;
- DataType glist_type;
- DataType gslist_type;
- DataType gerror_type;
- DataType iterable_type;
- DataType iterator_type;
- DataType list_type;
- DataType map_type;
+ Typesymbol pointer_type;
+ Typesymbol object_type;
+ Typesymbol initially_unowned_type;
+ Typesymbol glist_type;
+ Typesymbol gslist_type;
+ Typesymbol gerror_type;
+ Typesymbol iterable_type;
+ Typesymbol iterator_type;
+ Typesymbol list_type;
+ Typesymbol map_type;
private int next_lambda_id = 0;
root_symbol = context.root;
bool_type = new TypeReference ();
- bool_type.data_type = (DataType) root_symbol.scope.lookup ("bool");
+ bool_type.data_type = (Typesymbol) root_symbol.scope.lookup ("bool");
string_type = new TypeReference ();
- string_type.data_type = (DataType) root_symbol.scope.lookup ("string");
+ string_type.data_type = (Typesymbol) root_symbol.scope.lookup ("string");
- pointer_type = (DataType) root_symbol.scope.lookup ("pointer");
+ pointer_type = (Typesymbol) root_symbol.scope.lookup ("pointer");
int_type = new TypeReference ();
- int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
+ int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
uint_type = new TypeReference ();
- uint_type.data_type = (DataType) root_symbol.scope.lookup ("uint");
+ uint_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint");
ulong_type = new TypeReference ();
- ulong_type.data_type = (DataType) root_symbol.scope.lookup ("ulong");
+ ulong_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ulong");
unichar_type = new TypeReference ();
- unichar_type.data_type = (DataType) root_symbol.scope.lookup ("unichar");
+ unichar_type.data_type = (Typesymbol) root_symbol.scope.lookup ("unichar");
// TODO: don't require GLib namespace in semantic analyzer
var glib_ns = root_symbol.scope.lookup ("GLib");
if (glib_ns != null) {
- object_type = (DataType) glib_ns.scope.lookup ("Object");
- initially_unowned_type = (DataType) glib_ns.scope.lookup ("InitiallyUnowned");
+ object_type = (Typesymbol) glib_ns.scope.lookup ("Object");
+ initially_unowned_type = (Typesymbol) glib_ns.scope.lookup ("InitiallyUnowned");
type_type = new TypeReference ();
- type_type.data_type = (DataType) glib_ns.scope.lookup ("Type");
+ type_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Type");
- glist_type = (DataType) glib_ns.scope.lookup ("List");
- gslist_type = (DataType) glib_ns.scope.lookup ("SList");
+ glist_type = (Typesymbol) glib_ns.scope.lookup ("List");
+ gslist_type = (Typesymbol) glib_ns.scope.lookup ("SList");
- gerror_type = (DataType) glib_ns.scope.lookup ("Error");
+ gerror_type = (Typesymbol) glib_ns.scope.lookup ("Error");
}
var gee_ns = root_symbol.scope.lookup ("Gee");
if (gee_ns != null) {
- iterable_type = (DataType) gee_ns.scope.lookup ("Iterable");
- iterator_type = (DataType) gee_ns.scope.lookup ("Iterator");
- list_type = (DataType) gee_ns.scope.lookup ("List");
- map_type = (DataType) gee_ns.scope.lookup ("Map");
+ iterable_type = (Typesymbol) gee_ns.scope.lookup ("Iterable");
+ iterator_type = (Typesymbol) gee_ns.scope.lookup ("Iterator");
+ list_type = (Typesymbol) gee_ns.scope.lookup ("List");
+ map_type = (Typesymbol) gee_ns.scope.lookup ("Map");
}
current_symbol = root_symbol;
cl.accept_children (this);
/* gather all prerequisites */
- Gee.List<DataType> prerequisites = new ArrayList<DataType> ();
+ Gee.List<Typesymbol> prerequisites = new ArrayList<Typesymbol> ();
foreach (TypeReference base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
get_all_prerequisites ((Interface) base_type.data_type, prerequisites);
}
/* check whether all prerequisites are met */
Gee.List<string> missing_prereqs = new ArrayList<string> ();
- foreach (DataType prereq in prerequisites) {
+ foreach (Typesymbol prereq in prerequisites) {
if (!class_is_a (cl, prereq)) {
missing_prereqs.insert (0, prereq.get_full_name ());
}
current_class = null;
}
- private void get_all_prerequisites (Interface! iface, Collection<DataType> list) {
+ private void get_all_prerequisites (Interface! iface, Collection<Typesymbol> list) {
foreach (TypeReference prereq in iface.get_prerequisites ()) {
- DataType type = prereq.data_type;
+ Typesymbol type = prereq.data_type;
/* skip on previous errors */
if (type == null) {
continue;
}
}
- private bool class_is_a (Class! cl, DataType! t) {
+ private bool class_is_a (Class! cl, Typesymbol! t) {
if (cl == t) {
return true;
}
/* check prerequisites */
Class prereq_class;
foreach (TypeReference prereq in iface.get_prerequisites ()) {
- DataType class_or_interface = prereq.data_type;
+ Typesymbol class_or_interface = prereq.data_type;
/* skip on previous errors */
if (class_or_interface == null) {
iface.error = true;
}
if (current_symbol is Class) {
- m.return_type.data_type = (DataType) m.parent_symbol;
+ m.return_type.data_type = (Typesymbol) m.parent_symbol;
m.return_type.transfers_ownership = true;
// check for floating reference
public override void visit_constructor (Constructor! c) {
c.this_parameter = new FormalParameter ("this", new TypeReference ());
- c.this_parameter.type_reference.data_type = (DataType) current_symbol;
+ c.this_parameter.type_reference.data_type = (Typesymbol) current_symbol;
c.scope.add (c.this_parameter.name, c.this_parameter);
c.owner = current_symbol.scope;
public override void visit_character_literal (CharacterLiteral! expr) {
expr.static_type = new TypeReference ();
- expr.static_type.data_type = (DataType) root_symbol.scope.lookup ("char");
+ expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup ("char");
}
public override void visit_integer_literal (IntegerLiteral! expr) {
expr.static_type = new TypeReference ();
- expr.static_type.data_type = (DataType) root_symbol.scope.lookup (expr.get_type_name ());
+ expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup (expr.get_type_name ());
}
public override void visit_real_literal (RealLiteral! expr) {
expr.static_type = new TypeReference ();
- expr.static_type.data_type = (DataType) root_symbol.scope.lookup (expr.get_type_name ());
+ expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup (expr.get_type_name ());
}
public override void visit_string_literal (StringLiteral! expr) {
return decl.type_reference;
} else if (sym is EnumValue) {
var type = new TypeReference ();
- type.data_type = (DataType) sym.parent_symbol;
+ type.data_type = (Typesymbol) sym.parent_symbol;
return type;
}
return null;
if (expr.inner is MemberAccess || expr.inner is BaseAccess) {
base_symbol = expr.inner.symbol_reference;
- if (expr.creation_member && base_symbol is DataType) {
+ if (expr.creation_member && base_symbol is Typesymbol) {
// check for named creation method
expr.symbol_reference = base_symbol.scope.lookup (".new." + expr.member_name);
}
- if (expr.symbol_reference == null && (base_symbol is Namespace || base_symbol is DataType)) {
+ if (expr.symbol_reference == null && (base_symbol is Namespace || base_symbol is Typesymbol)) {
expr.symbol_reference = base_symbol.scope.lookup (expr.member_name);
if (expr.inner is BaseAccess) {
// inner expression is base access
public override void visit_object_creation_expression (ObjectCreationExpression! expr) {
expr.accept_children (this);
- DataType type = null;
+ Typesymbol type = null;
if (expr.type_reference == null) {
if (expr.member_name == null) {
}
if (type_sym is Class || type_sym is Struct) {
- type = (DataType) type_sym;
+ type = (Typesymbol) type_sym;
} else if (type_sym is Enum && ((Enum) type_sym).error_domain) {
- type = (DataType) type_sym;
+ type = (Typesymbol) type_sym;
} else {
expr.error = true;
Report.error (expr.source_reference, "`%s' is not a class, struct, or error domain".printf (type_sym.get_full_name ()));
generated_callback.instance = true;
var sender_type = new TypeReference ();
- sender_type.data_type = (DataType) parent_symbol;
+ sender_type.data_type = (Typesymbol) parent_symbol;
var sender_param = new FormalParameter ("sender", sender_type);
generated_callback.add_parameter (sender_param);
Symbol s;
- if (sym is DataType ||
+ if (sym is Typesymbol ||
sym is Method ||
sym is Field ||
sym is Property ||
return;
}
- if (dep_type == SourceFileDependencyType.HEADER_FULL || (s is DataType && !((DataType)s).is_reference_type ())) {
+ if (dep_type == SourceFileDependencyType.HEADER_FULL || (s is Typesymbol && !((Typesymbol)s).is_reference_type ())) {
foreach (string fn in s.get_cheader_filenames ()) {
header_internal_includes.add (fn);
}
/**
* Represents a struct declaration in the source code.
*/
-public class Vala.Struct : DataType {
+public class Vala.Struct : Typesymbol {
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
private Gee.List<Constant> constants = new ArrayList<Constant> ();
private Gee.List<Field> fields = new ArrayList<Field> ();
while (sym == null && scope != null) {
sym = scope.lookup (type.type_name);
scope = scope.parent_scope;
- if (sym != null && !(sym is DataType) && !(sym is TypeParameter)) {
+ if (sym != null && !(sym is Typesymbol) && !(sym is TypeParameter)) {
// ignore non-type symbols
sym = null;
}
}
if (sym is TypeParameter) {
type.type_parameter = (TypeParameter) sym;
- } else if (sym is DataType) {
- type.data_type = (DataType) sym;
+ } else if (sym is Typesymbol) {
+ type.data_type = (Typesymbol) sym;
} else {
Report.error (type.source_reference, "`%s' is not a type".printf (sym.get_full_name ()));
return;
Report.error (type.source_reference, "The type name `%s' does not exist in the namespace `%s'".printf (type.type_name, type.namespace_name));
return;
}
- if (sym is DataType) {
- type.data_type = (DataType) sym;
+ if (sym is Typesymbol) {
+ type.data_type = (Typesymbol) sym;
} else {
Report.error (type.source_reference, "`%s' is not a type".printf (sym.get_full_name ()));
return;
/**
* The generic type declaring this parameter.
*/
- public weak DataType type;
+ public weak Typesymbol type;
/* holds the array types of this type; each rank is a separate one */
private Map<int,Array> array_types;
/**
* The referred data type.
*/
- public weak DataType data_type { get; set; }
+ public weak Typesymbol data_type { get; set; }
/**
* The referred generic type parameter.
*/
public string get_const_cname () {
string ptr;
- DataType t;
+ Typesymbol t;
/* FIXME: dirty hack to make constant arrays possible */
if (data_type is Array) {
t = ((Array) data_type).element_type;
* Represents a runtime data type. This data type may be defined in Vala source
* code or imported from an external library with a Vala API file.
*/
-public abstract class Vala.DataType : Symbol {
+public abstract class Vala.Typesymbol : Symbol {
private Gee.List<string> cheader_filenames = new ArrayList<string> ();
private Pointer pointer_type;
* @param t a data type
* @return true if t is a supertype of this data type, false otherwise
*/
- public virtual bool is_subtype_of (DataType! t) {
+ public virtual bool is_subtype_of (Typesymbol! t) {
return (this == t);
}
private SourceReference current_source_reference;
private Namespace current_namespace;
- private DataType current_data_type;
+ private Typesymbol current_data_type;
private Map<string,string> codenode_attributes_map;
private Map<pointer,string> codenode_attributes_patterns;
private Gee.Set<string> current_type_symbol_set;
- private Map<string,DataType> cname_type_map;
+ private Map<string,Typesymbol> cname_type_map;
/**
* Parse all source files in the specified code context and build a
* @param context a code context
*/
public void parse (CodeContext! context) {
- cname_type_map = new HashMap<string,DataType> (str_hash, str_equal);
+ cname_type_map = new HashMap<string,Typesymbol> (str_hash, str_equal);
this.context = context;
context.accept (this);
visit_type (cb);
}
- private void visit_type (DataType! t) {
+ private void visit_type (Typesymbol! t) {
if (!cname_type_map.contains (t.get_cname ())) {
cname_type_map[t.get_cname ()] = t;
}