2007-12-02 Jürg Billeter <j@bitron.ch>
+ * vala/valadatatype.vala, vala/Makefile.am: rename TypeReference to
+ DataType
+
+ * vala/parser.y, vala/vala.h, vala/*.vala, gobject/*.vala,
+ vapigen/valagidlparser.vala: adapt after renaming
+
+2007-12-02 Jürg Billeter <j@bitron.ch>
+
* vala/valatypesymbol.vala, vala/Makefile.am: rename DataType to
Typesymbol
public Symbol current_type_symbol;
Class current_class;
Method current_method;
- TypeReference current_return_type;
+ DataType current_return_type;
TryStatement current_try;
CCodeFragment header_begin;
public bool in_creation_method = false;
private bool current_method_inner_error = false;
- public TypeReference bool_type;
- public TypeReference char_type;
- public TypeReference unichar_type;
- public TypeReference short_type;
- public TypeReference ushort_type;
- public TypeReference int_type;
- public TypeReference uint_type;
- public TypeReference long_type;
- public TypeReference ulong_type;
- public TypeReference int64_type;
- public TypeReference uint64_type;
- public TypeReference string_type;
- public TypeReference float_type;
- public TypeReference double_type;
+ public DataType bool_type;
+ public DataType char_type;
+ public DataType unichar_type;
+ public DataType short_type;
+ public DataType ushort_type;
+ public DataType int_type;
+ public DataType uint_type;
+ public DataType long_type;
+ public DataType ulong_type;
+ public DataType int64_type;
+ public DataType uint64_type;
+ public DataType string_type;
+ public DataType float_type;
+ public DataType double_type;
public Typesymbol gtypeinstance_type;
public Typesymbol gobject_type;
public Typesymbol gerror_type;
public Typesymbol gslist_type;
public Typesymbol gstring_type;
public Typesymbol garray_type;
- public TypeReference gquark_type;
- public TypeReference mutex_type;
+ public DataType gquark_type;
+ public DataType mutex_type;
public Typesymbol type_module_type;
public Typesymbol iterable_type;
public Typesymbol iterator_type;
root_symbol = context.root;
- bool_type = new TypeReference ();
+ bool_type = new DataType ();
bool_type.data_type = (Typesymbol) root_symbol.scope.lookup ("bool");
- char_type = new TypeReference ();
+ char_type = new DataType ();
char_type.data_type = (Typesymbol) root_symbol.scope.lookup ("char");
- unichar_type = new TypeReference ();
+ unichar_type = new DataType ();
unichar_type.data_type = (Typesymbol) root_symbol.scope.lookup ("unichar");
- short_type = new TypeReference ();
+ short_type = new DataType ();
short_type.data_type = (Typesymbol) root_symbol.scope.lookup ("short");
- ushort_type = new TypeReference ();
+ ushort_type = new DataType ();
ushort_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ushort");
- int_type = new TypeReference ();
+ int_type = new DataType ();
int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
- uint_type = new TypeReference ();
+ uint_type = new DataType ();
uint_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint");
- long_type = new TypeReference ();
+ long_type = new DataType ();
long_type.data_type = (Typesymbol) root_symbol.scope.lookup ("long");
- ulong_type = new TypeReference ();
+ ulong_type = new DataType ();
ulong_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ulong");
- int64_type = new TypeReference ();
+ int64_type = new DataType ();
int64_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int64");
- uint64_type = new TypeReference ();
+ uint64_type = new DataType ();
uint64_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint64");
- float_type = new TypeReference ();
+ float_type = new DataType ();
float_type.data_type = (Typesymbol) root_symbol.scope.lookup ("float");
- double_type = new TypeReference ();
+ double_type = new DataType ();
double_type.data_type = (Typesymbol) root_symbol.scope.lookup ("double");
- string_type = new TypeReference ();
+ string_type = new DataType ();
string_type.data_type = (Typesymbol) root_symbol.scope.lookup ("string");
substring_method = (Method) string_type.data_type.scope.lookup ("substring");
gstring_type = (Typesymbol) glib_ns.scope.lookup ("String");
garray_type = (Typesymbol) glib_ns.scope.lookup ("Array");
- gquark_type = new TypeReference ();
+ gquark_type = new DataType ();
gquark_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Quark");
- mutex_type = new TypeReference ();
+ mutex_type = new DataType ();
mutex_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Mutex");
type_module_type = (Typesymbol) glib_ns.scope.lookup ("TypeModule");
var arr = (Array) f.type_reference.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
- var len_type = new TypeReference ();
+ var len_type = new DataType ();
len_type.data_type = int_type.data_type;
st.add_field (len_type.get_cname (), get_array_length_cname (f.name, dim));
current_return_type = prop.type_reference;
} else {
// void
- current_return_type = new TypeReference ();
+ current_return_type = new DataType ();
}
acc.accept_children (this);
var t = (Typesymbol) prop.parent_symbol;
- var this_type = new TypeReference ();
+ var this_type = new DataType ();
this_type.data_type = t;
var cselfparam = new CCodeFormalParameter ("self", this_type.get_cname ());
var cvalueparam = new CCodeFormalParameter ("value", prop.type_reference.get_cname (false, true));
for (int dim = 1; dim <= arr.rank; dim++) {
var len_decl = new VariableDeclarator (get_array_length_cname (decl.name, dim));
- len_decl.type_reference = new TypeReference ();
+ len_decl.type_reference = new DataType ();
len_decl.type_reference.data_type = int_type.data_type;
temp_vars.insert (0, len_decl);
}
}
- public VariableDeclarator get_temp_variable_declarator (TypeReference! type, bool takes_ownership = true, CodeNode node_reference = null) {
+ public VariableDeclarator get_temp_variable_declarator (DataType! type, bool takes_ownership = true, CodeNode node_reference = null) {
var decl = new VariableDeclarator ("_tmp%d".printf (next_temp_var_id));
decl.type_reference = type.copy ();
decl.type_reference.is_ref = false;
return decl;
}
- private CCodeExpression get_type_id_expression (TypeReference! type) {
+ private CCodeExpression get_type_id_expression (DataType! type) {
if (type.data_type != null) {
return new CCodeIdentifier (type.data_type.get_type_id ());
} else if (type.type_parameter != null) {
}
}
- private CCodeExpression get_dup_func_expression (TypeReference! type) {
+ private CCodeExpression get_dup_func_expression (DataType! type) {
if (type.data_type != null) {
string dup_function;
if (type.data_type.is_reference_counting ()) {
}
}
- private CCodeExpression get_destroy_func_expression (TypeReference! type) {
+ private CCodeExpression get_destroy_func_expression (DataType! type) {
if (type.data_type != null) {
string unref_function;
if (type.data_type.is_reference_counting ()) {
}
}
- public CCodeExpression get_unref_expression (CCodeExpression! cvar, TypeReference! type, Expression expr) {
+ public CCodeExpression get_unref_expression (CCodeExpression! cvar, DataType! type, Expression expr) {
/* (foo == NULL ? NULL : foo = (unref (foo), NULL)) */
/* can be simplified to
bool takes_ownership = false;
CCodeExpression destroy_func_expression = null;
- foreach (TypeReference type_arg in type.get_type_arguments ()) {
+ foreach (DataType type_arg in type.get_type_arguments ()) {
takes_ownership = type_arg.takes_ownership;
if (takes_ownership) {
destroy_func_expression = get_destroy_func_expression (type_arg);
ccall.call = new CCodeIdentifier ("_vala_array_free");
ccall.add_argument (csizeexpr);
- var element_type = new TypeReference ();
+ var element_type = new DataType ();
element_type.data_type = arr.element_type;
element_type.type_parameter = arr.element_type_parameter;
ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (element_type), "GDestroyNotify"));
element_expr = convert_from_generic_pointer (element_expr, stmt.type_reference);
- Iterator<TypeReference> type_arg_it = it_method.return_type.get_type_arguments ().iterator ();
+ Iterator<DataType> type_arg_it = it_method.return_type.get_type_arguments ().iterator ();
type_arg_it.next ();
var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.static_type, it_method, type_arg_it.get (), stmt);
}
if (field.instance) {
- var instance_expression_type = new TypeReference ();
+ var instance_expression_type = new DataType ();
instance_expression_type.data_type = base_type;
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = (Typesymbol) field.parent_symbol;
CCodeExpression typed_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
bool is_class = false;
bool is_interface = false;
- foreach (TypeReference type_arg in expr.static_type.get_type_arguments ()) {
+ foreach (DataType type_arg in expr.static_type.get_type_arguments ()) {
is_ref |= type_arg.takes_ownership;
is_class |= type_arg.data_type is Class;
is_interface |= type_arg.data_type is Interface;
}
if (expr.type_reference.data_type is Class && expr.type_reference.data_type.is_subtype_of (gobject_type)) {
- foreach (TypeReference type_arg in expr.type_reference.get_type_arguments ()) {
+ foreach (DataType type_arg in expr.type_reference.get_type_arguments ()) {
creation_call.add_argument (get_type_id_expression (type_arg));
if (type_arg.takes_ownership) {
creation_call.add_argument (new CCodeCastExpression (get_dup_func_expression (type_arg), "GBoxedCopyFunc"));
foreach (MemberInitializer init in expr.get_object_initializer ()) {
if (init.symbol_reference is Field) {
var f = (Field) init.symbol_reference;
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
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;
l.ccodenode = new CCodeIdentifier (l.method.get_cname ());
}
- public CCodeExpression! convert_from_generic_pointer (CCodeExpression! cexpr, TypeReference! actual_type) {
+ public CCodeExpression! convert_from_generic_pointer (CCodeExpression! cexpr, DataType! actual_type) {
var result = cexpr;
if (actual_type.data_type is Struct) {
var st = (Struct) actual_type.data_type;
return result;
}
- public CCodeExpression! convert_to_generic_pointer (CCodeExpression! cexpr, TypeReference! actual_type) {
+ public CCodeExpression! convert_to_generic_pointer (CCodeExpression! cexpr, DataType! actual_type) {
var result = cexpr;
if (actual_type.data_type is Struct) {
var st = (Struct) actual_type.data_type;
return result;
}
- public CCodeExpression! get_implicit_cast_expression (CCodeExpression! cexpr, TypeReference expression_type, TypeReference! target_type) {
+ public CCodeExpression! get_implicit_cast_expression (CCodeExpression! cexpr, DataType expression_type, DataType! target_type) {
if (null == expression_type) {
return cexpr;
}
/* target instance is first argument */
CCodeExpression instance;
- TypeReference instance_expression_type;
+ DataType instance_expression_type;
if (ma.inner == null) {
instance = new CCodeIdentifier ("self");
- instance_expression_type = new TypeReference ();
+ instance_expression_type = new DataType ();
instance_expression_type.data_type = current_type_symbol;
} else {
instance = (CCodeExpression) ma.inner.ccodenode;
instance_expression_type = ma.inner.static_type;
}
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = (Typesymbol) base_property.parent_symbol;
instance = get_implicit_cast_expression (instance, instance_expression_type, instance_target_type);
}
add_class_init_function (cl);
- foreach (TypeReference base_type in cl.get_base_types ()) {
+ foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
add_interface_init_function (cl, (Interface) base_type.data_type);
}
source_type_member_definition.append (function);
}
- public CCodeIdentifier! get_value_setter_function (TypeReference! type_reference) {
+ public CCodeIdentifier! get_value_setter_function (DataType! type_reference) {
if (type_reference.data_type != null) {
return new CCodeIdentifier (type_reference.data_type.get_set_value_function ());
} else {
base_method = m.base_method;
}
- TypeReference instance_expression_type;
+ DataType instance_expression_type;
if (ma.inner == null) {
instance = new CCodeIdentifier ("self");
- instance_expression_type = new TypeReference ();
+ instance_expression_type = new DataType ();
instance_expression_type.data_type = current_type_symbol;
} else {
instance = (CCodeExpression) ma.inner.ccodenode;
// parent_symbol may be null for late bound methods
if (base_method.parent_symbol != null) {
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = (Typesymbol) base_method.parent_symbol;
instance = get_implicit_cast_expression (instance, instance_expression_type, instance_target_type);
}
ccall.add_argument (get_dbus_array_type (array));
- var garray_type_reference = new TypeReference ();
+ var garray_type_reference = new DataType ();
garray_type_reference.data_type = garray_type;
var temp_decl = get_temp_variable_declarator (garray_type_reference);
temp_vars.insert (0, temp_decl);
} else if (expr.symbol_reference is Field) {
var f = (Field) expr.symbol_reference;
if (f.instance) {
- var instance_expression_type = new TypeReference ();
+ var instance_expression_type = new DataType ();
instance_expression_type.data_type = base_type;
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = (Typesymbol) f.parent_symbol;
CCodeExpression typed_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
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 ();
+ var instance_expression_type = new DataType ();
instance_expression_type.data_type = base_type;
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = base_property_type;
CCodeExpression typed_pub_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
if (sig.has_emitter) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
- var instance_expression_type = new TypeReference ();
+ var instance_expression_type = new DataType ();
instance_expression_type.data_type = base_type;
- var instance_target_type = new TypeReference ();
+ var instance_target_type = new DataType ();
instance_target_type.data_type = cl;
CCodeExpression typed_pub_inst = get_implicit_cast_expression (pub_inst, instance_expression_type, instance_target_type);
public class Vala.CCodeGenerator {
public override void visit_method (Method! m) {
Method old_method = current_method;
- TypeReference old_return_type = current_return_type;
+ DataType old_return_type = current_return_type;
bool old_method_inner_error = current_method_inner_error;
int old_next_temp_var_id = next_temp_var_id;
current_symbol = m;
CCodeFormalParameter instance_param = null;
if (m.instance || (m.parent_symbol is Struct && m is CreationMethod)) {
- var this_type = new TypeReference ();
+ var this_type = new DataType ();
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 ();
+ var base_type = new DataType ();
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 ();
+ var base_type = new DataType ();
base_type.data_type = (Typesymbol) m.base_method.parent_symbol;
instance_param = new CCodeFormalParameter ("base", base_type.get_cname ());
} else {
} else {
base_method = m.base_interface_method;
}
- var base_expression_type = new TypeReference ();
+ var base_expression_type = new DataType ();
base_expression_type.data_type = base_method.parent_symbol;
- var self_target_type = new TypeReference ();
+ var self_target_type = new DataType ();
self_target_type.data_type = cl;
CCodeExpression cself = get_implicit_cast_expression (new CCodeIdentifier ("base"), base_expression_type, self_target_type);
var vfunc = new CCodeFunction (m.get_cname (), m.return_type.get_cname ());
vfunc.line = function.line;
- var this_type = new TypeReference ();
+ var this_type = new DataType ();
this_type.data_type = (Typesymbol) m.parent_symbol;
var cparam = new CCodeFormalParameter ("self", this_type.get_cname ());
using GLib;
public class Vala.CCodeGenerator {
- private string get_marshaller_type_name (TypeReference t) {
+ private string get_marshaller_type_name (DataType t) {
if (t.type_parameter != null) {
return ("POINTER");
} else if (t.data_type == null) {
return ret;
}
- private string get_value_type_name_from_type_reference (TypeReference! t) {
+ private string get_value_type_name_from_type_reference (DataType! t) {
if (t.type_parameter != null) {
return "gpointer";
} else if (t.data_type == null) {
public override CCodeFragment! get_type_interface_init_declaration () {
var frag = new CCodeFragment ();
- foreach (TypeReference base_type in class_reference.get_base_types ()) {
+ foreach (DataType base_type in class_reference.get_base_types ()) {
if (!(base_type.data_type is Interface)) {
continue;
}
public override CCodeFragment! get_type_interface_init_statements () {
var frag = new CCodeFragment ();
- foreach (TypeReference base_type in class_reference.get_base_types ()) {
+ foreach (DataType base_type in class_reference.get_base_types ()) {
if (!(base_type.data_type is Interface)) {
continue;
}
if (type_args.size != 1) {
return null;
}
- Iterator<TypeReference> type_args_it = type_args.iterator ();
+ Iterator<DataType> type_args_it = type_args.iterator ();
type_args_it.next ();
- var ret_type = new TypeReference ();
+ var ret_type = new DataType ();
ret_type.data_type = type_args_it.get ().data_type;
if (!is_dbus_interface (ret_type.data_type)) {
return null;
m.set_cname ("dbus_g_proxy_new_for_name");
m.add_cheader_filename ("dbus/dbus-glib.h");
m.access = SymbolAccessibility.PUBLIC;
- var string_type_ref = new TypeReference ();
+ var string_type_ref = new DataType ();
string_type_ref.data_type = string_type;
m.add_parameter (_context.create_formal_parameter ("name", string_type_ref));
m.add_parameter (_context.create_formal_parameter ("path", string_type_ref));
} else if (ma.inner != null && ma.inner.static_type != null && is_dbus_interface (ma.inner.static_type.data_type)) {
if (ma.parent_node is InvocationExpression) {
var expr = (InvocationExpression) ma.parent_node;
- var ret_type = new TypeReference ();
+ var ret_type = new DataType ();
if (expr.expected_type != null) {
ret_type.data_type = expr.expected_type.data_type;
ret_type.transfers_ownership = ret_type.data_type.is_reference_type ();
}
var m = new DBusMethod (ma.member_name, ret_type, ma.source_reference);
if (expr.expected_type != null) {
- var error_type = new TypeReference ();
+ var error_type = new DataType ();
error_type.data_type = dbus_error_type;
m.add_error_domain (error_type);
}
if (a.left != ma) {
return null;
}
- var s = new DBusSignal (ma.member_name, new TypeReference (), ma.source_reference);
+ var s = new DBusSignal (ma.member_name, new DataType (), ma.source_reference);
s.access = SymbolAccessibility.PUBLIC;
symbols.add (s);
return s;
* Represents a dynamic bound DBus method.
*/
public class Vala.DBusMethod : Method {
- public DBusMethod (construct string name, construct TypeReference return_type, construct SourceReference source_reference = null) {
+ public DBusMethod (construct string name, construct DataType return_type, construct SourceReference source_reference = null) {
}
public override Collection<string> get_cheader_filenames () {
* Represents a dynamic bound DBus signal.
*/
public class Vala.DBusSignal : Signal {
- public DBusSignal (construct string name, construct TypeReference return_type, construct SourceReference source_reference = null) {
+ public DBusSignal (construct string name, construct DataType return_type, construct SourceReference source_reference = null) {
}
}
var frag = new CCodeFragment ();
/* register all prerequisites */
- foreach (TypeReference prereq_ref in interface_reference.get_prerequisites ()) {
+ foreach (DataType prereq_ref in interface_reference.get_prerequisites ()) {
var prereq = prereq_ref.data_type;
var func = new CCodeFunctionCall (new CCodeIdentifier ("g_type_interface_add_prerequisite"));
valaconstructor.vala \
valacontinuestatement.vala \
valacreationmethod.vala \
+ valadatatype.vala \
valadeclarationstatement.vala \
valadestructor.vala \
valadostatement.vala \
valatypecheck.vala \
valatypeofexpression.vala \
valatypeparameter.vala \
- valatypereference.vala \
valatypesymbol.vala \
valaunaryexpression.vala \
valavariabledeclarator.vala \
char *str;
GList *list;
ValaLiteral *literal;
- ValaTypeReference *type_reference;
+ ValaDataType *type_reference;
ValaExpression *expression;
ValaStatement *statement;
ValaBlock *block;
{
GList *l;
ValaSourceReference *src = src(@1);
- $$ = vala_type_reference_new_from_name (NULL, $1, src);
+ $$ = vala_data_type_new_from_name (NULL, $1, src);
g_free ($1);
g_object_unref (src);
for (l = $2; l != NULL; l = l->next) {
- vala_type_reference_add_type_argument ($$, l->data);
+ vala_data_type_add_type_argument ($$, l->data);
g_object_unref (l->data);
}
g_list_free ($2);
{
GList *l;
ValaSourceReference *src = src(@1);
- $$ = vala_type_reference_new_from_name ($1, $3, src);
+ $$ = vala_data_type_new_from_name ($1, $3, src);
g_free ($1);
g_free ($3);
g_object_unref (src);
for (l = $4; l != NULL; l = l->next) {
- vala_type_reference_add_type_argument ($$, l->data);
+ vala_data_type_add_type_argument ($$, l->data);
g_object_unref (l->data);
}
g_list_free ($4);
: type_name opt_rank_specifier opt_op_neg
{
$$ = $1;
- vala_type_reference_set_array_rank ($$, $2);
+ vala_data_type_set_array_rank ($$, $2);
if ($3) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| WEAK type_name opt_rank_specifier opt_op_neg
{
$$ = $2;
- vala_type_reference_set_is_weak ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $3);
+ vala_data_type_set_is_weak ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $3);
if ($4) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| type_name opt_rank_specifier opt_op_neg HASH
{
$$ = $1;
- vala_type_reference_set_takes_ownership ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $2);
+ vala_data_type_set_takes_ownership ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $2);
if ($3) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| REF type_name opt_rank_specifier opt_op_neg
{
$$ = $2;
- vala_type_reference_set_is_ref ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $3);
+ vala_data_type_set_is_ref ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $3);
if ($4) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| OUT type_name opt_rank_specifier opt_op_neg
{
$$ = $2;
- vala_type_reference_set_is_out ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $3);
+ vala_data_type_set_is_out ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $3);
if ($4) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| OUT WEAK type_name opt_rank_specifier opt_op_neg
{
$$ = $3;
- vala_type_reference_set_is_weak ($$, TRUE);
- vala_type_reference_set_is_out ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $4);
+ vala_data_type_set_is_weak ($$, TRUE);
+ vala_data_type_set_is_out ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $4);
if ($5) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| type_name stars opt_rank_specifier opt_op_neg
{
$$ = $1;
- vala_type_reference_set_pointer_level ($$, $2);
- vala_type_reference_set_array_rank ($$, $3);
+ vala_data_type_set_pointer_level ($$, $2);
+ vala_data_type_set_array_rank ($$, $3);
if ($4) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
;
{
GList *l;
ValaSourceReference *src = src(@2);
- ValaTypeReference *t = vala_type_reference_new_from_expression (VALA_EXPRESSION ($2));
+ ValaDataType *t = vala_data_type_new_from_expression (VALA_EXPRESSION ($2));
$$ = VALA_EXPRESSION (vala_code_context_create_array_creation_expression (context, t, g_list_length ($3), VALA_INITIALIZER_LIST ($4), src));
g_object_unref (t);
for (l = $3; l != NULL; l = l->next) {
| NEW member_name rank_specifier initializer
{
ValaSourceReference *src = src(@2);
- ValaTypeReference *t = vala_type_reference_new_from_expression (VALA_EXPRESSION ($2));
+ ValaDataType *t = vala_data_type_new_from_expression (VALA_EXPRESSION ($2));
$$ = VALA_EXPRESSION (vala_code_context_create_array_creation_expression (context, t, $3, VALA_INITIALIZER_LIST ($4), src));
g_object_unref (t);
g_object_unref (src);
g_object_unref (src);
for (l = $2; l != NULL; l = l->next) {
ValaVariableDeclarator *decl = l->data;
- ValaTypeReference *type = vala_type_reference_copy ($1);
+ ValaDataType *type = vala_data_type_copy ($1);
vala_variable_declarator_set_type_reference (decl, type);
g_object_unref (type);
vala_local_variable_declaration_add_declarator ($$, decl);
: primary_expression opt_bracket_pair opt_op_neg
{
ValaSourceReference *src = src(@1);
- $$ = vala_type_reference_new_from_expression ($1);
+ $$ = vala_data_type_new_from_expression ($1);
g_object_unref ($1);
g_object_unref (src);
- vala_type_reference_set_takes_ownership ($$, TRUE);
- vala_type_reference_set_array_rank ($$, $2);
+ vala_data_type_set_takes_ownership ($$, TRUE);
+ vala_data_type_set_array_rank ($$, $2);
if ($3) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
| primary_expression stars
{
ValaSourceReference *src = src(@1);
- $$ = vala_type_reference_new_from_expression ($1);
+ $$ = vala_data_type_new_from_expression ($1);
g_object_unref ($1);
g_object_unref (src);
- vala_type_reference_set_pointer_level ($$, $2);
+ vala_data_type_set_pointer_level ($$, $2);
}
| WEAK primary_expression opt_bracket_pair opt_op_neg
{
ValaSourceReference *src = src(@2);
- $$ = vala_type_reference_new_from_expression ($2);
+ $$ = vala_data_type_new_from_expression ($2);
g_object_unref ($2);
g_object_unref (src);
- vala_type_reference_set_array_rank ($$, $3);
+ vala_data_type_set_array_rank ($$, $3);
if ($4) {
- vala_type_reference_set_non_null ($$, TRUE);
+ vala_data_type_set_non_null ($$, TRUE);
}
}
;
: FOREACH OPEN_PARENS type identifier IN expression CLOSE_PARENS embedded_statement
{
ValaSourceReference *src = src(@3);
- if (!vala_type_reference_get_is_weak ($3)) {
- vala_type_reference_set_takes_ownership ($3, TRUE);
+ if (!vala_data_type_get_is_weak ($3)) {
+ vala_data_type_set_takes_ownership ($3, TRUE);
}
$$ = VALA_STATEMENT (vala_code_context_create_foreach_statement (context, $3, $4, $6, $8, src));
g_object_unref ($3);
src = src_com(@5, $1);
- if (vala_type_reference_get_is_ref ($5) || vala_type_reference_get_is_out ($5)) {
+ if (vala_data_type_get_is_ref ($5) || vala_data_type_get_is_out ($5)) {
vala_report_error (src, "`ref' and `out' may only be used for parameters.");
}
- if (!vala_type_reference_get_is_weak ($5)) {
- vala_type_reference_set_takes_ownership ($5, TRUE);
+ if (!vala_data_type_get_is_weak ($5)) {
+ vala_data_type_set_takes_ownership ($5, TRUE);
}
$$ = vala_code_context_create_field (context, vala_symbol_get_name (VALA_SYMBOL ($6)), $5, vala_variable_declarator_get_initializer ($6), src);
src = src_com(@6, $1);
- if (vala_type_reference_get_is_ref ($5) || vala_type_reference_get_is_out ($5)) {
+ if (vala_data_type_get_is_ref ($5) || vala_data_type_get_is_out ($5)) {
vala_report_error (src, "`ref' and `out' may only be used for parameters.");
}
- if (!vala_type_reference_get_is_weak ($5)) {
- vala_type_reference_set_transfers_ownership ($5, TRUE);
+ if (!vala_data_type_get_is_weak ($5)) {
+ vala_data_type_set_transfers_ownership ($5, TRUE);
}
$$ = vala_code_context_create_method (context, $6, $5, src);
/* HASH in property type context has the meaning of transferring
* ownership instead of taking it */
- if (vala_type_reference_get_takes_ownership ($5)) {
- vala_type_reference_set_transfers_ownership ($5, TRUE);
- vala_type_reference_set_takes_ownership ($5, FALSE);
+ if (vala_data_type_get_takes_ownership ($5)) {
+ vala_data_type_set_transfers_ownership ($5, TRUE);
+ vala_data_type_set_takes_ownership ($5, FALSE);
}
- if (!vala_type_reference_get_is_weak ($5)) {
- vala_type_reference_set_takes_ownership ($5, TRUE);
+ if (!vala_data_type_get_is_weak ($5)) {
+ vala_data_type_set_takes_ownership ($5, TRUE);
}
src = src_com(@5, $1);
/* HASH in property type context has the meaning of transferring
* ownership instead of taking it */
- if (vala_type_reference_get_takes_ownership ($5)) {
- vala_type_reference_set_transfers_ownership ($5, TRUE);
- vala_type_reference_set_takes_ownership ($5, FALSE);
+ if (vala_data_type_get_takes_ownership ($5)) {
+ vala_data_type_set_transfers_ownership ($5, TRUE);
+ vala_data_type_set_takes_ownership ($5, FALSE);
}
- if (!vala_type_reference_get_is_weak ($5)) {
- vala_type_reference_set_takes_ownership ($5, TRUE);
+ if (!vala_data_type_get_is_weak ($5)) {
+ vala_data_type_set_takes_ownership ($5, TRUE);
}
src = src_com(@5, $1);
: type
{
$$ = $1;
- if (!vala_type_reference_get_is_weak ($$)) {
- vala_type_reference_set_takes_ownership ($$, TRUE);
+ if (!vala_data_type_get_is_weak ($$)) {
+ vala_data_type_set_takes_ownership ($$, TRUE);
}
}
;
#include <vala/valaconstructor.h>
#include <vala/valacontinuestatement.h>
#include <vala/valacreationmethod.h>
+#include <vala/valadatatype.h>
#include <vala/valadeclarationstatement.h>
#include <vala/valadestructor.h>
#include <vala/valadostatement.h>
#include <vala/valatypecheck.h>
#include <vala/valatypeofexpression.h>
#include <vala/valatypeparameter.h>
-#include <vala/valatypereference.h>
+#include <vala/valatypesymbol.h>
#include <vala/valaunaryexpression.h>
#include <vala/valavariabledeclarator.h>
#include <vala/valawhilestatement.h>
length_field.access = SymbolAccessibility.PUBLIC;
var root_symbol = source_reference.file.context.root;
- length_field.type_reference = new TypeReference ();
+ length_field.type_reference = new DataType ();
length_field.type_reference.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
}
if (resize_method == null) {
resize_method = new ArrayResizeMethod (source_reference);
- resize_method.return_type = new TypeReference ();
+ resize_method.return_type = new DataType ();
resize_method.access = SymbolAccessibility.PUBLIC;
resize_method.set_cname ("g_renew");
var root_symbol = source_reference.file.context.root;
- var int_type = new TypeReference ();
+ var int_type = new DataType ();
int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
resize_method.add_parameter (new FormalParameter ("length", int_type));
if (move_method == null) {
move_method = new ArrayMoveMethod (source_reference);
- move_method.return_type = new TypeReference ();
+ move_method.return_type = new DataType ();
move_method.access = SymbolAccessibility.PUBLIC;
move_method.set_cname ("_vala_array_move");
var root_symbol = source_reference.file.context.root;
- var int_type = new TypeReference ();
+ var int_type = new DataType ();
int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
move_method.add_parameter (new FormalParameter ("src", int_type));
/**
* The type of the elements of the array.
*/
- public TypeReference element_type { get; set construct; }
+ public DataType element_type { get; set construct; }
/**
* The rank of the array.
return new ReadOnlyList<Expression> (sizes);
}
- public ArrayCreationExpression (construct TypeReference element_type, construct int rank, construct InitializerList initializer_list, construct SourceReference source_reference) {
+ public ArrayCreationExpression (construct DataType element_type, construct int rank, construct InitializerList initializer_list, construct SourceReference source_reference) {
}
public override void accept_children (CodeVisitor! visitor) {
/**
* The return type of this callback.
*/
- public TypeReference return_type { get; set; }
+ public DataType return_type { get; set; }
/**
* Specifies whether callback supports calling instance methods.
* @param source reference to source code
* @return newly created callback
*/
- public Callback (construct string name, construct TypeReference return_type, construct SourceReference source_reference = null) {
+ public Callback (construct string name, construct DataType return_type, construct SourceReference source_reference = null) {
}
/**
/**
* The target type.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* Checked casts return NULL instead of raising an error.
* @param type target type
* @return newly created cast expression
*/
- public CastExpression (construct Expression! inner, construct TypeReference! type_reference, construct SourceReference source_reference, construct bool is_silent_cast) {
+ public CastExpression (construct Expression! inner, construct DataType! type_reference, construct SourceReference source_reference, construct bool is_silent_cast) {
}
public override void accept (CodeVisitor! visitor) {
/**
* Specifies the error type.
*/
- public TypeReference type_reference { get; set; }
+ public DataType type_reference { get; set; }
/**
* Specifies the error variable name.
* @param source_reference reference to source code
* @return newly created catch clause
*/
- public CatchClause (construct TypeReference type_reference, construct string variable_name, construct Block body, construct SourceReference source_reference = null) {
+ public CatchClause (construct DataType type_reference, construct string variable_name, construct Block body, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
- private Gee.List<TypeReference> base_types = new ArrayList<TypeReference> ();
+ private Gee.List<DataType> base_types = new ArrayList<DataType> ();
private Gee.List<Constant> constants = new ArrayList<Constant> ();
private Gee.List<Field> fields = new ArrayList<Field> ();
*
* @param type a class or interface reference
*/
- public void add_base_type (TypeReference! type) {
+ public void add_base_type (DataType! type) {
base_types.add (type);
}
*
* @return list of base types
*/
- public Collection<TypeReference> get_base_types () {
- return new ReadOnlyCollection<TypeReference> (base_types);
+ public Collection<DataType> get_base_types () {
+ return new ReadOnlyCollection<DataType> (base_types);
}
/**
*/
public void add_method (Method! m) {
if (m.instance || m is CreationMethod) {
- m.this_parameter = new FormalParameter ("this", new TypeReference ());
+ m.this_parameter = new FormalParameter ("this", new DataType ());
m.this_parameter.type_reference.data_type = this;
m.scope.add (m.this_parameter.name, m.this_parameter);
}
properties.add (prop);
scope.add (prop.name, prop);
- prop.this_parameter = new FormalParameter ("this", new TypeReference ());
+ prop.this_parameter = new FormalParameter ("this", new DataType ());
prop.this_parameter.type_reference.data_type = this;
prop.scope.add (prop.this_parameter.name, prop.this_parameter);
}
public override void accept_children (CodeVisitor! visitor) {
- foreach (TypeReference type in base_types) {
+ foreach (DataType type in base_types) {
type.accept (visitor);
}
return true;
}
- foreach (TypeReference base_type in base_types) {
+ foreach (DataType base_type in base_types) {
if (base_type.data_type != null && base_type.data_type.is_subtype_of (t)) {
return true;
}
return node;
}
- public Callback! create_callback (string name, TypeReference return_type, SourceReference source_reference = null) {
+ public Callback! create_callback (string name, DataType return_type, SourceReference source_reference = null) {
var node = new Callback (name, return_type, source_reference);
node.code_binding = codegen.create_callback_binding (node);
return node;
}
- public Constant! create_constant (string! name, TypeReference! type_reference, Expression initializer, SourceReference source_reference) {
+ public Constant! create_constant (string! name, DataType! type_reference, Expression initializer, SourceReference source_reference) {
var node = new Constant (name, type_reference, initializer, source_reference);
node.code_binding = codegen.create_constant_binding (node);
return node;
}
- public Field! create_field (string! name, TypeReference! type_reference, Expression initializer, SourceReference source_reference = null) {
+ public Field! create_field (string! name, DataType! type_reference, Expression initializer, SourceReference source_reference = null) {
var node = new Field (name, type_reference, initializer, source_reference);
node.code_binding = codegen.create_field_binding (node);
return node;
}
- public Method! create_method (string name, TypeReference return_type, SourceReference source_reference = null) {
+ public Method! create_method (string name, DataType return_type, SourceReference source_reference = null) {
var node = new Method (name, return_type, source_reference);
node.code_binding = codegen.create_method_binding (node);
return node;
return node;
}
- public FormalParameter! create_formal_parameter (string! name, TypeReference type_reference, SourceReference source_reference = null) {
+ public FormalParameter! create_formal_parameter (string! name, DataType type_reference, SourceReference source_reference = null) {
var node = new FormalParameter (name, type_reference, source_reference);
node.code_binding = codegen.create_formal_parameter_binding (node);
return node;
return node;
}
- public Property! create_property (string! name, TypeReference! type_reference, PropertyAccessor get_accessor, PropertyAccessor set_accessor, SourceReference source_reference) {
+ public Property! create_property (string! name, DataType! type_reference, PropertyAccessor get_accessor, PropertyAccessor set_accessor, SourceReference source_reference) {
var node = new Property (name, type_reference, get_accessor, set_accessor, source_reference);
node.code_binding = codegen.create_property_binding (node);
return node;
return node;
}
- public Signal! create_signal (string! name, TypeReference! return_type, SourceReference source_reference = null) {
+ public Signal! create_signal (string! name, DataType! return_type, SourceReference source_reference = null) {
var node = new Signal (name, return_type, source_reference);
node.code_binding = codegen.create_signal_binding (node);
return node;
return node;
}
- public LocalVariableDeclaration! create_local_variable_declaration (TypeReference type_reference, SourceReference source_reference) {
+ public LocalVariableDeclaration! create_local_variable_declaration (DataType type_reference, SourceReference source_reference) {
var node = new LocalVariableDeclaration (type_reference, source_reference);
node.code_binding = codegen.create_local_variable_declaration_binding (node);
return node;
return node;
}
- public ForeachStatement! create_foreach_statement (TypeReference! type_reference, string! variable_name, Expression! collection, Block body, SourceReference source_reference) {
+ public ForeachStatement! create_foreach_statement (DataType! type_reference, string! variable_name, Expression! collection, Block body, SourceReference source_reference) {
var node = new ForeachStatement (type_reference, variable_name, collection, body, source_reference);
node.code_binding = codegen.create_foreach_statement_binding (node);
return node;
return node;
}
- public CatchClause! create_catch_clause (TypeReference type_reference, string variable_name, Block body, SourceReference source_reference = null) {
+ public CatchClause! create_catch_clause (DataType type_reference, string variable_name, Block body, SourceReference source_reference = null) {
var node = new CatchClause (type_reference, variable_name, body, source_reference);
node.code_binding = codegen.create_catch_clause_binding (node);
return node;
return node;
}
- public ArrayCreationExpression! create_array_creation_expression (TypeReference element_type, int rank, InitializerList initializer_list, SourceReference source_reference) {
+ public ArrayCreationExpression! create_array_creation_expression (DataType element_type, int rank, InitializerList initializer_list, SourceReference source_reference) {
var node = new ArrayCreationExpression (element_type, rank, initializer_list, source_reference);
node.code_binding = codegen.create_array_creation_expression_binding (node);
return node;
return node;
}
- public SizeofExpression! create_sizeof_expression (TypeReference! type_reference, SourceReference source_reference) {
+ public SizeofExpression! create_sizeof_expression (DataType! type_reference, SourceReference source_reference) {
var node = new SizeofExpression (type_reference, source_reference);
node.code_binding = codegen.create_sizeof_expression_binding (node);
return node;
}
- public TypeofExpression! create_typeof_expression (TypeReference! type_reference, SourceReference source_reference) {
+ public TypeofExpression! create_typeof_expression (DataType! type_reference, SourceReference source_reference) {
var node = new TypeofExpression (type_reference, source_reference);
node.code_binding = codegen.create_typeof_expression_binding (node);
return node;
return node;
}
- public CastExpression! create_cast_expression (Expression! inner, TypeReference! type_reference, SourceReference source_reference, bool is_silent_cast) {
+ public CastExpression! create_cast_expression (Expression! inner, DataType! type_reference, SourceReference source_reference, bool is_silent_cast) {
var node = new CastExpression (inner, type_reference, source_reference, is_silent_cast);
node.code_binding = codegen.create_cast_expression_binding (node);
return node;
return node;
}
- public TypeCheck! create_type_check (Expression! expression, TypeReference! type_reference, SourceReference source_reference) {
+ public TypeCheck! create_type_check (Expression! expression, DataType! type_reference, SourceReference source_reference) {
var node = new TypeCheck (expression, type_reference, source_reference);
node.code_binding = codegen.create_type_check_binding (node);
return node;
*
* @param type a type reference
*/
- public virtual void visit_type_reference (TypeReference! type) {
+ public virtual void visit_type_reference (DataType! type) {
}
/**
/**
* The data type of this constant.
*/
- public TypeReference! type_reference { get; set; }
+ public DataType! type_reference { get; set; }
/**
* The value of this constant.
* @param source_reference reference to source code
* @return newly created constant
*/
- public Constant (construct string! name, construct TypeReference! type_reference, construct Expression initializer, construct SourceReference source_reference) {
+ public Constant (construct string! name, construct DataType! type_reference, construct Expression initializer, construct SourceReference source_reference) {
}
public override void accept (CodeVisitor! visitor) {
param.accept (visitor);
}
- foreach (TypeReference error_domain in get_error_domains ()) {
+ foreach (DataType error_domain in get_error_domains ()) {
error_domain.accept (visitor);
}
* A reference to a data type. This is used to specify static types of
* expressions.
*/
-public class Vala.TypeReference : CodeNode {
+public class Vala.DataType : CodeNode {
/**
* Specifies that the expression transfers ownership of its value.
*/
*/
public bool is_weak { get; set; }
- private ArrayList<TypeReference> type_argument_list = new ArrayList<TypeReference> ();
+ private ArrayList<DataType> type_argument_list = new ArrayList<DataType> ();
- public TypeReference () {
+ public DataType () {
}
/**
* @param source reference to source code
* @return newly created type reference
*/
- public TypeReference.from_name (string ns, string! type, SourceReference source = null) {
+ public DataType.from_name (string ns, string! type, SourceReference source = null) {
namespace_name = ns;
type_name = type;
source_reference = source;
* @param source reference to source code
* @return newly created type reference
*/
- public static TypeReference new_from_expression (Expression! expr) {
+ public static DataType new_from_expression (Expression! expr) {
string ns = null;
string type_name = null;
if (expr is MemberAccess) {
- TypeReference type_ref = null;
+ DataType type_ref = null;
MemberAccess ma = (MemberAccess) expr;
if (ma.inner != null) {
if (ma.inner is MemberAccess) {
var simple = (MemberAccess) ma.inner;
- type_ref = new TypeReference.from_name (simple.member_name, ma.member_name, ma.source_reference);
+ type_ref = new DataType.from_name (simple.member_name, ma.member_name, ma.source_reference);
}
} else {
- type_ref = new TypeReference.from_name (null, ma.member_name, ma.source_reference);
+ type_ref = new DataType.from_name (null, ma.member_name, ma.source_reference);
}
if (type_ref != null) {
var type_args = ma.get_type_arguments ();
- foreach (TypeReference arg in type_args) {
+ foreach (DataType arg in type_args) {
type_ref.add_type_argument (arg);
}
*
* @param arg a type reference
*/
- public void add_type_argument (TypeReference! arg) {
+ public void add_type_argument (DataType! arg) {
type_argument_list.add (arg);
}
*
* @return type argument list
*/
- public Gee.List<TypeReference> get_type_arguments () {
- return new ReadOnlyList<TypeReference> (type_argument_list);
+ public Gee.List<DataType> get_type_arguments () {
+ return new ReadOnlyList<DataType> (type_argument_list);
}
/**
}
public override void accept (CodeVisitor! visitor) {
- if (((Gee.List<TypeReference>) type_argument_list).size > 0) {
- foreach (TypeReference type_arg in type_argument_list) {
+ if (((Gee.List<DataType>) type_argument_list).size > 0) {
+ foreach (DataType type_arg in type_argument_list) {
type_arg.accept (visitor);
}
}
*
* @return copy of this type reference
*/
- public TypeReference! copy () {
- var result = new TypeReference ();
+ public DataType! copy () {
+ var result = new DataType ();
result.source_reference = source_reference;
result.transfers_ownership = transfers_ownership;
result.takes_ownership = takes_ownership;
result.is_ref = is_ref;
result.is_weak = is_weak;
- foreach (TypeReference arg in type_argument_list) {
+ foreach (DataType arg in type_argument_list) {
result.type_argument_list.add (arg.copy ());
}
* @return true if this type reference is equal to type2, false
* otherwise
*/
- public bool equals (TypeReference! type2) {
+ public bool equals (DataType! type2) {
if (type2.transfers_ownership != transfers_ownership) {
return false;
}
* @param type2 a type reference
* @return true if this type reference is stricter or equal
*/
- public bool stricter (TypeReference! type2) {
+ public bool stricter (DataType! type2) {
if (type2.transfers_ownership != transfers_ownership) {
return false;
}
return;
}
if (m.instance) {
- m.this_parameter = new FormalParameter ("this", new TypeReference ());
+ m.this_parameter = new FormalParameter ("this", new DataType ());
m.this_parameter.type_reference.data_type = this;
m.scope.add (m.this_parameter.name, m.this_parameter);
}
*
* The semantic analyzer computes this value.
*/
- public TypeReference static_type { get; set; }
+ public DataType static_type { get; set; }
/*
* The static type this expression is expected to have.
*
* The semantic analyzer computes this value, lambda expressions use it.
*/
- public TypeReference expected_type { get; set; }
+ public DataType expected_type { get; set; }
/**
* The symbol this expression refers to.
/**
* The data type of this field.
*/
- public TypeReference! type_reference { get; set; }
+ public DataType! type_reference { get; set; }
/**
* Specifies the expression to be used to initialize this field.
* @param source reference to source code
* @return newly created field
*/
- public Field (construct string! name, construct TypeReference! type_reference, construct Expression initializer, construct SourceReference source_reference = null) {
+ public Field (construct string! name, construct DataType! type_reference, construct Expression initializer, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
return cb.get_parameters ();
}
- public TypeReference get_return_type () {
+ public DataType get_return_type () {
if (!is_invokable ()) {
return null;
}
/**
* Specifies the element type.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* Specifies the element variable name.
* @param source reference to source code
* @return newly created foreach statement
*/
- public ForeachStatement (construct TypeReference! type_reference, construct string! variable_name, construct Expression! collection, construct Block body, construct SourceReference source_reference) {
+ public ForeachStatement (construct DataType! type_reference, construct string! variable_name, construct Expression! collection, construct Block body, construct SourceReference source_reference) {
}
public override void accept (CodeVisitor! visitor) {
/**
* The parameter type.
*/
- public TypeReference type_reference { get; set; }
+ public DataType type_reference { get; set; }
/**
* Specifies whether the methods accepts an indefinite number of
* @param source reference to source code
* @return newly created formal parameter
*/
- public FormalParameter (string! _name, TypeReference type, SourceReference source = null) {
+ public FormalParameter (string! _name, DataType type, SourceReference source = null) {
name = _name;
type_reference = type;
source_reference = source;
return cb.get_parameters ();
}
- public TypeReference get_return_type () {
+ public DataType get_return_type () {
if (!is_invokable ()) {
return null;
}
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
- private Gee.List<TypeReference> prerequisites = new ArrayList<TypeReference> ();
+ private Gee.List<DataType> prerequisites = new ArrayList<DataType> ();
private Gee.List<Method> methods = new ArrayList<Method> ();
private Gee.List<Field> fields = new ArrayList<Field> ();
*
* @param type an interface or class reference
*/
- public void add_prerequisite (TypeReference! type) {
+ public void add_prerequisite (DataType! type) {
prerequisites.add (type);
}
*
* @param type an interface or class reference
*/
- public void prepend_prerequisite (TypeReference! type) {
+ public void prepend_prerequisite (DataType! type) {
prerequisites.insert (0, type);
}
*
* @return list of base types
*/
- public Collection<TypeReference> get_prerequisites () {
- return new ReadOnlyCollection<TypeReference> (prerequisites);
+ public Collection<DataType> get_prerequisites () {
+ return new ReadOnlyCollection<DataType> (prerequisites);
}
/**
return;
}
if (m.instance) {
- m.this_parameter = new FormalParameter ("this", new TypeReference ());
+ m.this_parameter = new FormalParameter ("this", new DataType ());
m.this_parameter.type_reference.data_type = this;
m.scope.add (m.this_parameter.name, m.this_parameter);
}
}
public override void accept_children (CodeVisitor! visitor) {
- foreach (TypeReference type in prerequisites) {
+ foreach (DataType type in prerequisites) {
type.accept (visitor);
}
return true;
}
- foreach (TypeReference prerequisite in prerequisites) {
+ foreach (DataType prerequisite in prerequisites) {
if (prerequisite.data_type != null && prerequisite.data_type.is_subtype_of (t)) {
return true;
}
write_string (" : ");
bool first = true;
- foreach (TypeReference base_type in base_types) {
+ foreach (DataType base_type in base_types) {
if (!first) {
write_string (", ");
} else {
write_string (" : ");
bool first = true;
- foreach (TypeReference prerequisite in prerequisites) {
+ foreach (DataType prerequisite in prerequisites) {
if (!first) {
write_string (", ");
} else {
write_newline ();
}
- private void write_error_domains (Collection<TypeReference> error_domains) {
+ private void write_error_domains (Collection<DataType> error_domains) {
if (error_domains.size > 0) {
write_string (" throws ");
bool first = true;
- foreach (TypeReference type in error_domains) {
+ foreach (DataType type in error_domains) {
if (!first) {
write_string (", ");
} else {
write_string (s);
}
- private void write_type (TypeReference! type) {
+ private void write_type (DataType! type) {
if (type.data_type != null) {
write_string (type.data_type.get_full_name ());
} else {
if (!(type.data_type is Array) && type_args.size > 0) {
write_string ("<");
bool first = true;
- foreach (TypeReference type_arg in type_args) {
+ foreach (DataType type_arg in type_args) {
if (!first) {
write_string (",");
} else {
*
* @return return type
*/
- public abstract TypeReference get_return_type ();
+ public abstract DataType get_return_type ();
/**
* Returns copy of the list of invocation parameters.
/**
* Specifies the type of this literal.
*/
- public TypeReference static_type { get; set; }
+ public DataType static_type { get; set; }
}
/**
* The type of the local variable.
*/
- public TypeReference type_reference { get; set; }
+ public DataType type_reference { get; set; }
private Gee.List<VariableDeclarator> variable_declarators = new ArrayList<VariableDeclarator> ();
* @param source_reference reference to source code
* @return newly created local variable declaration
*/
- public LocalVariableDeclaration (construct TypeReference type_reference, construct SourceReference source_reference) {
+ public LocalVariableDeclaration (construct DataType type_reference, construct SourceReference source_reference) {
}
/**
public bool creation_member { get; set; }
private Expression _inner;
- private Gee.List<TypeReference> type_argument_list = new ArrayList<TypeReference> ();
+ private Gee.List<DataType> type_argument_list = new ArrayList<DataType> ();
/**
* Creates a new member access expression.
*
* @param arg a type reference
*/
- public void add_type_argument (TypeReference! arg) {
+ public void add_type_argument (DataType! arg) {
type_argument_list.add (arg);
}
*
* @return type argument list
*/
- public Collection<TypeReference> get_type_arguments () {
- return new ReadOnlyCollection<TypeReference> (type_argument_list);
+ public Collection<DataType> get_type_arguments () {
+ return new ReadOnlyCollection<DataType> (type_argument_list);
}
public override void accept (CodeVisitor! visitor) {
inner.accept (visitor);
}
- foreach (TypeReference type_arg in type_argument_list) {
+ foreach (DataType type_arg in type_argument_list) {
type_arg.accept (visitor);
}
/**
* The return type of this method.
*/
- public TypeReference return_type { get; set; }
+ public DataType return_type { get; set; }
public Block body { get; set; }
private string _vfunc_name;
private string _sentinel;
private bool _no_array_length;
- private Gee.List<TypeReference> error_domains = new ArrayList<TypeReference> ();
+ private Gee.List<DataType> error_domains = new ArrayList<DataType> ();
/**
* Creates a new method.
* @param source reference to source code
* @return newly created method
*/
- public Method (construct string name, construct TypeReference return_type, construct SourceReference source_reference = null) {
+ public Method (construct string name, construct DataType return_type, construct SourceReference source_reference = null) {
}
/**
return new ReadOnlyCollection<FormalParameter> (parameters);
}
- public TypeReference get_return_type () {
+ public DataType get_return_type () {
return return_type;
}
param.accept (visitor);
}
- foreach (TypeReference error_domain in error_domains) {
+ foreach (DataType error_domain in error_domains) {
error_domain.accept (visitor);
}
return false;
}
- Iterator<TypeReference> method_error_domains_it = m2.get_error_domains ().iterator ();
- foreach (TypeReference error_domain in error_domains) {
+ Iterator<DataType> method_error_domains_it = m2.get_error_domains ().iterator ();
+ foreach (DataType error_domain in error_domains) {
/* method may not have less error domains */
if (!method_error_domains_it.next ()) {
return false;
*
* @param error_domain an error domain
*/
- public void add_error_domain (TypeReference! error_domain) {
+ public void add_error_domain (DataType! error_domain) {
error_domains.add (error_domain);
}
*
* @return list of error domains
*/
- public Collection<TypeReference> get_error_domains () {
- return new ReadOnlyCollection<TypeReference> (error_domains);
+ public Collection<DataType> get_error_domains () {
+ return new ReadOnlyCollection<DataType> (error_domains);
}
}
/**
* The object type to create.
*/
- public TypeReference type_reference { get; set; }
+ public DataType type_reference { get; set; }
/**
* The construction method to use. May be null to indicate that
/**
* The property type.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* The get accessor of this property if available.
* @param source reference to source code
* @return newly created property
*/
- public Property (string! _name, TypeReference! type, PropertyAccessor _get_accessor, PropertyAccessor _set_accessor, SourceReference source) {
+ public Property (string! _name, DataType! type, PropertyAccessor _get_accessor, PropertyAccessor _set_accessor, SourceReference source) {
name = _name;
type_reference = type;
get_accessor = _get_accessor;
Symbol root_symbol;
Symbol current_symbol;
SourceFile current_source_file;
- TypeReference current_return_type;
+ DataType current_return_type;
Class current_class;
Struct current_struct;
Collection<NamespaceReference> current_using_directives;
- TypeReference bool_type;
- TypeReference string_type;
- TypeReference int_type;
- TypeReference uint_type;
- TypeReference ulong_type;
- TypeReference unichar_type;
- TypeReference type_type;
+ DataType bool_type;
+ DataType string_type;
+ DataType int_type;
+ DataType uint_type;
+ DataType ulong_type;
+ DataType unichar_type;
+ DataType type_type;
Typesymbol pointer_type;
Typesymbol object_type;
Typesymbol initially_unowned_type;
root_symbol = context.root;
- bool_type = new TypeReference ();
+ bool_type = new DataType ();
bool_type.data_type = (Typesymbol) root_symbol.scope.lookup ("bool");
- string_type = new TypeReference ();
+ string_type = new DataType ();
string_type.data_type = (Typesymbol) root_symbol.scope.lookup ("string");
pointer_type = (Typesymbol) root_symbol.scope.lookup ("pointer");
- int_type = new TypeReference ();
+ int_type = new DataType ();
int_type.data_type = (Typesymbol) root_symbol.scope.lookup ("int");
- uint_type = new TypeReference ();
+ uint_type = new DataType ();
uint_type.data_type = (Typesymbol) root_symbol.scope.lookup ("uint");
- ulong_type = new TypeReference ();
+ ulong_type = new DataType ();
ulong_type.data_type = (Typesymbol) root_symbol.scope.lookup ("ulong");
- unichar_type = new TypeReference ();
+ unichar_type = new DataType ();
unichar_type.data_type = (Typesymbol) root_symbol.scope.lookup ("unichar");
// TODO: don't require GLib namespace in semantic analyzer
object_type = (Typesymbol) glib_ns.scope.lookup ("Object");
initially_unowned_type = (Typesymbol) glib_ns.scope.lookup ("InitiallyUnowned");
- type_type = new TypeReference ();
+ type_type = new DataType ();
type_type.data_type = (Typesymbol) glib_ns.scope.lookup ("Type");
glist_type = (Typesymbol) glib_ns.scope.lookup ("List");
current_source_file.add_symbol_dependency (cl.base_class, SourceFileDependencyType.HEADER_FULL);
}
- foreach (TypeReference base_type_reference in cl.get_base_types ()) {
+ foreach (DataType base_type_reference in cl.get_base_types ()) {
current_source_file.add_symbol_dependency (base_type_reference.data_type, SourceFileDependencyType.HEADER_FULL);
}
/* gather all prerequisites */
Gee.List<Typesymbol> prerequisites = new ArrayList<Typesymbol> ();
- foreach (TypeReference base_type in cl.get_base_types ()) {
+ foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
get_all_prerequisites ((Interface) base_type.data_type, prerequisites);
}
/* VAPI classes don't have to specify overridden methods */
if (!cl.source_reference.file.pkg) {
/* all abstract symbols defined in base types have to be at least defined (or implemented) also in this type */
- foreach (TypeReference base_type in cl.get_base_types ()) {
+ foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
Interface iface = (Interface) base_type.data_type;
}
private void get_all_prerequisites (Interface! iface, Collection<Typesymbol> list) {
- foreach (TypeReference prereq in iface.get_prerequisites ()) {
+ foreach (DataType prereq in iface.get_prerequisites ()) {
Typesymbol type = prereq.data_type;
/* skip on previous errors */
if (type == null) {
return true;
}
- foreach (TypeReference base_type in cl.get_base_types ()) {
+ 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)) {
return true;
public override void visit_interface (Interface! iface) {
current_symbol = iface;
- foreach (TypeReference prerequisite_reference in iface.get_prerequisites ()) {
+ foreach (DataType prerequisite_reference in iface.get_prerequisites ()) {
current_source_file.add_symbol_dependency (prerequisite_reference.data_type, SourceFileDependencyType.HEADER_FULL);
}
/* check prerequisites */
Class prereq_class;
- foreach (TypeReference prereq in iface.get_prerequisites ()) {
+ foreach (DataType prereq in iface.get_prerequisites ()) {
Typesymbol class_or_interface = prereq.data_type;
/* skip on previous errors */
if (class_or_interface == null) {
private void find_base_interface_method (Method! m, Class! cl) {
// FIXME report error if multiple possible base methods are found
- foreach (TypeReference type in cl.get_base_types ()) {
+ foreach (DataType type in cl.get_base_types ()) {
if (type.data_type is Interface) {
var sym = type.data_type.scope.lookup (m.name);
if (sym is Method) {
}
public override void visit_creation_method (CreationMethod! m) {
- m.return_type = new TypeReference ();
+ m.return_type = new DataType ();
if (m.type_name != null && m.type_name != current_symbol.name) {
// type_name is null for constructors generated by GIdlParser
private void find_base_interface_property (Property! prop, Class! cl) {
// FIXME report error if multiple possible base properties are found
- foreach (TypeReference type in cl.get_base_types ()) {
+ foreach (DataType type in cl.get_base_types ()) {
if (type.data_type is Interface) {
var sym = type.data_type.scope.lookup (prop.name);
if (sym is Property) {
current_return_type = acc.prop.type_reference;
} else {
// void
- current_return_type = new TypeReference ();
+ current_return_type = new DataType ();
}
if (!acc.source_reference.file.pkg) {
}
public override void visit_constructor (Constructor! c) {
- c.this_parameter = new FormalParameter ("this", new TypeReference ());
+ c.this_parameter = new FormalParameter ("this", new DataType ());
c.this_parameter.type_reference.data_type = (Typesymbol) current_symbol;
c.scope.add (c.this_parameter.name, c.this_parameter);
var collection_type = stmt.collection.static_type.data_type;
if (iterable_type != null && collection_type.is_subtype_of (iterable_type)) {
stmt.iterator_variable_declarator = new VariableDeclarator ("%s_it".printf (stmt.variable_name));
- stmt.iterator_variable_declarator.type_reference = new TypeReference ();
+ stmt.iterator_variable_declarator.type_reference = new DataType ();
stmt.iterator_variable_declarator.type_reference.data_type = iterator_type;
stmt.iterator_variable_declarator.type_reference.takes_ownership = true;
stmt.iterator_variable_declarator.type_reference.add_type_argument (stmt.type_reference);
}
clause.variable_declarator = new VariableDeclarator (clause.variable_name);
- clause.variable_declarator.type_reference = new TypeReference ();
+ clause.variable_declarator.type_reference = new DataType ();
clause.variable_declarator.type_reference.data_type = gerror_type;
clause.body.scope.add (clause.variable_name, clause.variable_declarator);
}
public override void visit_character_literal (CharacterLiteral! expr) {
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
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 = new DataType ();
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 = new DataType ();
expr.static_type.data_type = (Typesymbol) root_symbol.scope.lookup (expr.get_type_name ());
}
}
public override void visit_null_literal (NullLiteral! expr) {
- /* empty TypeReference represents null */
+ /* empty DataType represents null */
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
}
public override void visit_literal_expression (LiteralExpression! expr) {
expr.static_type = expr.literal.static_type;
}
- private TypeReference get_static_type_for_symbol (Symbol! sym) {
+ private DataType get_static_type_for_symbol (Symbol! sym) {
if (sym is Field) {
var f = (Field) sym;
return f.type_reference;
} else if (sym is FormalParameter) {
var p = (FormalParameter) sym;
return p.type_reference;
- } else if (sym is TypeReference) {
- return (TypeReference) sym;
+ } else if (sym is DataType) {
+ return (DataType) sym;
} else if (sym is VariableDeclarator) {
var decl = (VariableDeclarator) sym;
return decl.type_reference;
} else if (sym is EnumValue) {
- var type = new TypeReference ();
+ var type = new DataType ();
type.data_type = (Typesymbol) sym.parent_symbol;
return type;
}
var cl = (Class) sym;
// first check interfaces without prerequisites
// (prerequisites can be assumed to be met already)
- foreach (TypeReference base_type in cl.get_base_types ()) {
+ 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 (result != null) {
}
} else if (sym is Struct) {
var st = (Struct) sym;
- foreach (TypeReference base_type in st.get_base_types ()) {
+ foreach (DataType base_type in st.get_base_types ()) {
result = symbol_lookup_inherited (base_type.data_type, name);
if (result != null) {
return result;
} else if (sym is Interface) {
var iface = (Interface) sym;
// first check interface prerequisites recursively
- foreach (TypeReference prerequisite in iface.get_prerequisites ()) {
+ foreach (DataType prerequisite in iface.get_prerequisites ()) {
if (prerequisite.data_type is Interface) {
result = symbol_lookup_inherited (prerequisite.data_type, name);
if (result != null) {
}
}
// then check class prerequisite recursively
- foreach (TypeReference prerequisite in iface.get_prerequisites ()) {
+ foreach (DataType prerequisite in iface.get_prerequisites ()) {
if (prerequisite.data_type is Class) {
result = symbol_lookup_inherited (prerequisite.data_type, name);
if (result != null) {
current_source_file.add_symbol_dependency (expr.symbol_reference, SourceFileDependencyType.SOURCE);
}
- private bool is_type_compatible (TypeReference! expression_type, TypeReference! expected_type) {
+ private bool is_type_compatible (DataType! expression_type, DataType! expected_type) {
/* only null is compatible to null */
if (expected_type.data_type == null && expected_type.type_parameter == null) {
return (expression_type.data_type == null && expected_type.type_parameter == null);
arg.accept (this);
}
- TypeReference ret_type;
+ DataType ret_type;
if (msym is Invokable) {
var m = (Invokable) msym;
return true;
}
- public static TypeReference get_actual_type (TypeReference derived_instance_type, Symbol generic_member, TypeReference generic_type, CodeNode node_reference) {
- TypeReference instance_type = derived_instance_type;
+ public static DataType get_actual_type (DataType derived_instance_type, Symbol generic_member, DataType generic_type, CodeNode node_reference) {
+ DataType instance_type = derived_instance_type;
// trace type arguments back to the datatype where the method has been declared
while (instance_type.data_type != generic_member.parent_symbol) {
- Collection<TypeReference> base_types = null;
+ Collection<DataType> base_types = null;
if (instance_type.data_type is Class) {
var cl = (Class) instance_type.data_type;
base_types = cl.get_base_types ();
node_reference.error = true;
return null;
}
- foreach (TypeReference base_type in base_types) {
+ foreach (DataType base_type in base_types) {
if (SemanticAnalyzer.symbol_lookup_inherited (base_type.data_type, generic_member.name) != null) {
// construct a new type reference for the base type with correctly linked type arguments
- var instance_base_type = new TypeReference ();
+ var instance_base_type = new DataType ();
instance_base_type.data_type = base_type.data_type;
- foreach (TypeReference type_arg in base_type.get_type_arguments ()) {
+ foreach (DataType type_arg in base_type.get_type_arguments ()) {
if (type_arg.type_parameter != null) {
// link to type argument of derived type
int param_index = instance_type.data_type.get_type_parameter_index (type_arg.type_parameter.name);
return null;
}
- TypeReference actual_type = null;
+ DataType actual_type = null;
if (param_index < instance_type.get_type_arguments ().size) {
- actual_type = (TypeReference) instance_type.get_type_arguments ().get (param_index);
+ actual_type = (DataType) instance_type.get_type_arguments ().get (param_index);
}
if (actual_type == null) {
Report.error (node_reference.source_reference, "internal error: no actual argument found for type parameter %s".printf (generic_type.type_parameter.name));
Report.error (expr.source_reference, "Base access invalid without base type %d".printf (current_struct.get_base_types ().size));
return;
}
- Iterator<TypeReference> base_type_it = current_struct.get_base_types ().iterator ();
+ Iterator<DataType> base_type_it = current_struct.get_base_types ().iterator ();
base_type_it.next ();
expr.static_type = base_type_it.get ();
} else {
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
expr.static_type.data_type = current_class.base_class;
}
return;
}
- expr.type_reference = new TypeReference ();
+ expr.type_reference = new DataType ();
expr.type_reference.data_type = type;
- foreach (TypeReference type_arg in type_args) {
+ foreach (DataType type_arg in type_args) {
expr.type_reference.add_type_argument (type_arg);
if (type_arg.data_type != null) {
Report.error (expr.source_reference, "Invalid type for argument 1");
}
}
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
}
foreach (MemberInitializer init in expr.get_object_initializer ()) {
Report.error (expr.source_reference, "Access to private member `%s' denied".printf (init.symbol_reference.get_full_name ()));
return;
}
- TypeReference member_type;
+ DataType member_type;
if (init.symbol_reference is Field) {
var f = (Field) init.symbol_reference;
member_type = f.type_reference;
expr.static_type = type_type;
}
- private bool is_numeric_type (TypeReference! type) {
+ private bool is_numeric_type (DataType! type) {
if (!(type.data_type is Struct)) {
return false;
}
return st.is_integer_type () || st.is_floating_type ();
}
- private bool is_integer_type (TypeReference! type) {
+ private bool is_integer_type (DataType! type) {
if (!(type.data_type is Struct)) {
return false;
}
var pointer = (Pointer) expr.inner.static_type.data_type;
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
expr.static_type.data_type = pointer.referent_type;
expr.static_type.takes_ownership = expr.inner.static_type.takes_ownership;
}
return;
}
- expr.static_type = new TypeReference ();
+ expr.static_type = new DataType ();
expr.static_type.data_type = expr.inner.static_type.data_type.get_pointer ();
expr.static_type.takes_ownership = expr.inner.static_type.takes_ownership;
}
expr.static_type.takes_ownership = false;
}
- private TypeReference get_arithmetic_result_type (TypeReference! left_type, TypeReference! right_type) {
+ private DataType get_arithmetic_result_type (DataType! left_type, DataType! right_type) {
if (!(left_type.data_type is Struct) || !(right_type.data_type is Struct)) {
// at least one operand not struct
return null;
expr.static_type = bool_type;
}
- private TypeReference compute_common_base_type (Collection<TypeReference> types, SourceReference source_reference) {
+ private DataType compute_common_base_type (Collection<DataType> types, SourceReference source_reference) {
bool null_found = false;
bool class_or_iface_found = false;
bool type_param_found = false;
bool val_struct_found = false;
bool enum_found = false;
bool callback_found = false;
- TypeReference base_type = null;
- TypeReference last_type = null;
- foreach (TypeReference type in types) {
+ DataType base_type = null;
+ DataType last_type = null;
+ foreach (DataType type in types) {
last_type = type;
if (type.error) {
- base_type = new TypeReference ();
+ base_type = new DataType ();
base_type.error = true;
return base_type;
}
}
}
} else {
- base_type = new TypeReference ();
+ base_type = new DataType ();
base_type.error = true;
Report.error (type.source_reference, "internal error: unsupported type `%s'".printf (type.to_string ()));
return base_type;
}
if (base_type == null) {
- base_type = new TypeReference ();
+ base_type = new DataType ();
base_type.data_type = type.data_type;
base_type.type_parameter = type.type_parameter;
base_type.non_null = type.non_null;
}
/* FIXME: support memory management */
- Gee.List<TypeReference> types = new ArrayList<TypeReference> ();
+ Gee.List<DataType> types = new ArrayList<DataType> ();
types.add (expr.true_expression.static_type);
types.add (expr.false_expression.static_type);
expr.static_type = compute_common_base_type (types, expr.source_reference);
if (ma.symbol_reference is Signal) {
var sig = (Signal) ma.symbol_reference;
- a.right.expected_type = new TypeReference ();
+ a.right.expected_type = new DataType ();
a.right.expected_type.data_type = sig.get_callback ();
} else {
a.right.expected_type = ma.static_type;
/**
* The return type of handlers of this signal.
*/
- public TypeReference! return_type { get; set; }
+ public DataType! return_type { get; set; }
/**
* Specifies whether this signal has an emitter wrapper function.
* @param source reference to source code
* @return newly created signal
*/
- public Signal (construct string! name, construct TypeReference! return_type, construct SourceReference source_reference = null) {
+ public Signal (construct string! name, construct DataType! return_type, construct SourceReference source_reference = null) {
}
/**
return new ReadOnlyCollection<FormalParameter> (parameters);
}
- public TypeReference get_return_type () {
+ public DataType get_return_type () {
return return_type;
}
generated_callback = new Callback (null, return_type);
generated_callback.instance = true;
- var sender_type = new TypeReference ();
+ var sender_type = new DataType ();
sender_type.data_type = (Typesymbol) parent_symbol;
var sender_param = new FormalParameter ("sender", sender_type);
generated_callback.add_parameter (sender_param);
/**
* The type whose size to be retrieved.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* Creates a new sizeof expression.
* @param source reference to source code
* @return newly created sizeof expression
*/
- public SizeofExpression (TypeReference! type, SourceReference source) {
+ public SizeofExpression (DataType! type, SourceReference source) {
type_reference = type;
source_reference = source;
}
private Gee.List<Field> fields = new ArrayList<Field> ();
private Gee.List<Method> methods = new ArrayList<Method> ();
- private Gee.List<TypeReference> base_types = new ArrayList<TypeReference> ();
+ private Gee.List<DataType> base_types = new ArrayList<DataType> ();
private string cname;
private string const_cname;
return_if_fail (m != null);
if (m.instance) {
- m.this_parameter = new FormalParameter ("this", new TypeReference ());
+ m.this_parameter = new FormalParameter ("this", new DataType ());
m.this_parameter.type_reference.data_type = this;
m.scope.add (m.this_parameter.name, m.this_parameter);
}
}
public override void accept_children (CodeVisitor! visitor) {
- foreach (TypeReference type in base_types) {
+ foreach (DataType type in base_types) {
type.accept (visitor);
}
*
* @param type a class or interface reference
*/
- public void add_base_type (TypeReference! type) {
+ public void add_base_type (DataType! type) {
base_types.add (type);
}
*
* @return list of base types
*/
- public Collection<TypeReference> get_base_types () {
- return new ReadOnlyCollection<TypeReference> (base_types);
+ public Collection<DataType> get_base_types () {
+ return new ReadOnlyCollection<DataType> (base_types);
}
public override int get_type_parameter_index (string! name) {
* instances are passed by value.
*/
public bool is_simple_type () {
- foreach (TypeReference type in base_types) {
+ foreach (DataType type in base_types) {
var st = type.data_type as Struct;
if (st != null && st.is_simple_type ()) {
return true;
cl.accept_children (this);
- foreach (TypeReference type in cl.get_base_types ()) {
+ foreach (DataType type in cl.get_base_types ()) {
if (type.data_type is Class) {
if (cl.base_class != null) {
cl.error = true;
iface.accept_children (this);
- foreach (TypeReference type in iface.get_prerequisites ()) {
+ foreach (DataType type in iface.get_prerequisites ()) {
if (type.data_type.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 ()));
}
}
- public override void visit_type_reference (TypeReference! type) {
+ public override void visit_type_reference (DataType! type) {
if (type.type_name == null || type.type_name == "void") {
// reset transfers_ownership
type.transfers_ownership = false;
Report.error (type.source_reference, "Pointer to `%s' not supported".printf (type.type_name));
return;
}
- var referent_type = new TypeReference ();
+ var referent_type = new DataType ();
referent_type.data_type = type.data_type;
referent_type.pointer_level = type.pointer_level - 1;
/* check for array */
if (type.array_rank > 0) {
- var element_type = new TypeReference ();
+ var element_type = new DataType ();
element_type.data_type = type.data_type;
element_type.type_parameter = type.type_parameter;
- foreach (TypeReference type_arg in type.get_type_arguments ()) {
+ foreach (DataType type_arg in type.get_type_arguments ()) {
element_type.add_type_argument (type_arg);
}
type.remove_all_type_arguments ();
/**
* The type to be matched against.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* Creates a new type check expression.
* @param source reference to source code
* @return newly created type check expression
*/
- public TypeCheck (Expression! expr, TypeReference! type, SourceReference source) {
+ public TypeCheck (Expression! expr, DataType! type, SourceReference source) {
expression = expr;
type_reference = type;
source_reference = source;
/**
* The type to be retrieved.
*/
- public TypeReference! type_reference { get; set construct; }
+ public DataType! type_reference { get; set construct; }
/**
* Creates a new typeof expression.
* @param source reference to source code
* @return newly created typeof expression
*/
- public TypeofExpression (TypeReference! type, SourceReference source) {
+ public TypeofExpression (DataType! type, SourceReference source) {
type_reference = type;
source_reference = source;
}
/**
* The variable type.
*/
- public TypeReference type_reference { get; set; }
+ public DataType type_reference { get; set; }
private Expression _initializer;
return cb.get_parameters ();
}
- public TypeReference get_return_type () {
+ public DataType get_return_type () {
if (!is_invokable ()) {
return null;
}
current_source_file.add_node (cl);
}
- var parent = new TypeReference ();
+ var parent = new DataType ();
parent.namespace_name = "GLib";
parent.type_name = "Boxed";
cl.add_base_type (parent);
}
if (base_class != null) {
- var parent = new TypeReference ();
+ var parent = new DataType ();
parse_type_string (parent, base_class);
cl.add_base_type (parent);
} else if (node.parent != null) {
- var parent = new TypeReference ();
+ var parent = new DataType ();
parse_type_string (parent, node.parent);
cl.add_base_type (parent);
} else {
- var parent = new TypeReference ();
+ var parent = new DataType ();
parent.namespace_name = "GLib";
parent.type_name = "Object";
cl.add_base_type (parent);
}
foreach (string iface_name in node.interfaces) {
- var iface = new TypeReference ();
+ var iface = new DataType ();
parse_type_string (iface, iface_name);
cl.add_base_type (iface);
}
}
foreach (string prereq_name in node.prerequisites) {
- var prereq = new TypeReference ();
+ var prereq = new DataType ();
parse_type_string (prereq, prereq_name);
iface.add_prerequisite (prereq);
}
current_data_type = null;
}
- private TypeReference parse_type (IdlNodeType! type_node) {
- var type = new TypeReference ();
+ private DataType parse_type (IdlNodeType! type_node) {
+ var type = new DataType ();
if (type_node.tag == TypeTag.VOID) {
if (type_node.is_pointer) {
type.type_name = "pointer";
return false;
}
- private void parse_type_string (TypeReference! type, string! n) {
+ private void parse_type_string (DataType! type, string! n) {
var dt = cname_type_map[n];
if (dt != null) {
type.namespace_name = dt.parent_symbol.name;
}
}
- private TypeReference parse_param (IdlNodeParam! param) {
+ private DataType parse_param (IdlNodeParam! param) {
var type = parse_type (param.type);
// disable for now as null_ok not yet correctly set
return null;
}
- TypeReference return_type = null;
+ DataType return_type = null;
if (f.result != null) {
return_type = parse_param (f.result);
}