From: Juerg Billeter Date: Tue, 13 May 2008 08:16:09 +0000 (+0000) Subject: Rename Expression.static_type to Expression.value_type X-Git-Tag: VALA_0_3_3~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=baa2dce00a916df3e046414832ca6f6fd27f5eb0;p=thirdparty%2Fvala.git Rename Expression.static_type to Expression.value_type 2008-05-13 Juerg Billeter * vala/valaexpression.vala: * vala/valamemorymanager.vala: * vala/valanullchecker.vala: * vala/valasemanticanalyzer.vala: * gobject/valaccodearraycreationexpressionbinding.vala: * gobject/valaccodeassignmentbinding.vala: * gobject/valaccodeelementaccessbinding.vala: * gobject/valaccodegenerator.vala: * gobject/valaccodeinvocationexpressionbinding.vala: * gobject/valaccodememberaccessbinding.vala: Rename Expression.static_type to Expression.value_type svn path=/trunk/; revision=1386 --- diff --git a/ChangeLog b/ChangeLog index cb9d70682..3ac3f0ca7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2008-05-13 Jürg Billeter + + * vala/valaexpression.vala: + * vala/valamemorymanager.vala: + * vala/valanullchecker.vala: + * vala/valasemanticanalyzer.vala: + * gobject/valaccodearraycreationexpressionbinding.vala: + * gobject/valaccodeassignmentbinding.vala: + * gobject/valaccodeelementaccessbinding.vala: + * gobject/valaccodegenerator.vala: + * gobject/valaccodeinvocationexpressionbinding.vala: + * gobject/valaccodememberaccessbinding.vala: + + Rename Expression.static_type to Expression.value_type + 2008-05-12 Jürg Billeter * configure.ac: Post-release version bump diff --git a/gen-project/valaprojectgenerator.vala b/gen-project/valaprojectgenerator.vala index b770990e5..f63f95f20 100644 --- a/gen-project/valaprojectgenerator.vala +++ b/gen-project/valaprojectgenerator.vala @@ -376,7 +376,7 @@ class Vala.ProjectGenerator : Dialog { TimeVal tv; tv.get_current_time (); - Date d = new Date (); + Date d = Date (); d.set_time_val (tv); s.append_printf ("/* %s\n", filename); diff --git a/gobject/valaccodearraycreationexpressionbinding.vala b/gobject/valaccodearraycreationexpressionbinding.vala index cb3d74acb..b002fd839 100644 --- a/gobject/valaccodearraycreationexpressionbinding.vala +++ b/gobject/valaccodearraycreationexpressionbinding.vala @@ -79,7 +79,7 @@ public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding { } var ce = new CCodeCommaExpression (); - var temp_var = codegen.get_temp_variable (expr.static_type, true, expr); + var temp_var = codegen.get_temp_variable (expr.value_type, true, expr); var name_cnode = new CCodeIdentifier (temp_var.name); int i = 0; diff --git a/gobject/valaccodeassignmentbinding.vala b/gobject/valaccodeassignmentbinding.vala index ec56259b4..c132acafb 100644 --- a/gobject/valaccodeassignmentbinding.vala +++ b/gobject/valaccodeassignmentbinding.vala @@ -46,7 +46,7 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding { CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode; // ensure to pass the value correctly typed (especially important for varargs) - cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.static_type, prop.type_reference); + cexpr = codegen.get_implicit_cast_expression (cexpr, assignment.right.value_type, prop.type_reference); if (!prop.no_accessor_method) { if (prop.type_reference.is_real_struct_type ()) { @@ -323,10 +323,10 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding { // custom element access CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode; - rhs = codegen.get_implicit_cast_expression (rhs, assignment.right.static_type, assignment.left.static_type); + rhs = codegen.get_implicit_cast_expression (rhs, assignment.right.value_type, assignment.left.value_type); var expr = (ElementAccess) assignment.left; - var container_type = expr.container.static_type.data_type; + var container_type = expr.container.value_type.data_type; Collection indices = expr.get_indices (); Iterator indices_it = indices.iterator (); indices_it.next (); @@ -350,14 +350,14 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding { var set_param = set_params_it.get (); if (set_param.type_reference.type_parameter != null) { - var index_type = SemanticAnalyzer.get_actual_type (expr.container.static_type, set_method, set_param.type_reference, assignment); + var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, set_method, set_param.type_reference, assignment); cindex = codegen.convert_to_generic_pointer (cindex, index_type); } var set_ccall = new CCodeFunctionCall (new CCodeIdentifier (set_method.get_cname ())); set_ccall.add_argument (new CCodeCastExpression (ccontainer, collection_iface.get_cname () + "*")); set_ccall.add_argument (cindex); - set_ccall.add_argument (codegen.convert_to_generic_pointer (rhs, expr.static_type)); + set_ccall.add_argument (codegen.convert_to_generic_pointer (rhs, expr.value_type)); codenode = set_ccall; } else { @@ -369,38 +369,38 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding { private void emit_simple_assignment () { CCodeExpression rhs = (CCodeExpression) assignment.right.ccodenode; - rhs = codegen.get_implicit_cast_expression (rhs, assignment.right.static_type, assignment.left.static_type); + rhs = codegen.get_implicit_cast_expression (rhs, assignment.right.value_type, assignment.left.value_type); - bool unref_old = (assignment.left.static_type.takes_ownership); + bool unref_old = (assignment.left.value_type.takes_ownership); bool array = false; bool instance_delegate = false; - if (assignment.left.static_type is ArrayType) { + if (assignment.left.value_type is ArrayType) { array = !(codegen.get_array_length_cexpression (assignment.left, 1) is CCodeConstant); - } else if (assignment.left.static_type is DelegateType) { - var delegate_type = (DelegateType) assignment.left.static_type; + } else if (assignment.left.value_type is DelegateType) { + var delegate_type = (DelegateType) assignment.left.value_type; instance_delegate = delegate_type.delegate_symbol.has_target; } if (unref_old || array || instance_delegate) { var ccomma = new CCodeCommaExpression (); - var temp_decl = codegen.get_temp_variable (assignment.left.static_type); + var temp_decl = codegen.get_temp_variable (assignment.left.value_type); codegen.temp_vars.insert (0, temp_decl); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), rhs)); if (unref_old) { /* unref old value */ - ccomma.append_expression (codegen.get_unref_expression ((CCodeExpression) assignment.left.ccodenode, assignment.left.static_type, assignment.left)); + ccomma.append_expression (codegen.get_unref_expression ((CCodeExpression) assignment.left.ccodenode, assignment.left.value_type, assignment.left)); } if (array) { - var array_type = (ArrayType) assignment.left.static_type; + var array_type = (ArrayType) assignment.left.value_type; for (int dim = 1; dim <= array_type.rank; dim++) { var lhs_array_len = codegen.get_array_length_cexpression (assignment.left, dim); var rhs_array_len = codegen.get_array_length_cexpression (assignment.right, dim); ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len)); } } else if (instance_delegate) { - var delegate_type = (DelegateType) assignment.left.static_type; + var delegate_type = (DelegateType) assignment.left.value_type; var lhs_delegate_target = codegen.get_delegate_target_cexpression (assignment.left); var rhs_delegate_target = codegen.get_delegate_target_cexpression (assignment.right); ccomma.append_expression (new CCodeAssignment (lhs_delegate_target, rhs_delegate_target)); @@ -463,8 +463,8 @@ public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding { } else if (assignment.left.symbol_reference is Signal) { emit_signal_assignment (); } else if (assignment.left is ElementAccess - && !(((ElementAccess) assignment.left).container.static_type is ArrayType) - && !(((ElementAccess) assignment.left).container.static_type is PointerType)) { + && !(((ElementAccess) assignment.left).container.value_type is ArrayType) + && !(((ElementAccess) assignment.left).container.value_type is PointerType)) { emit_non_array_element_access (); } else { emit_simple_assignment (); diff --git a/gobject/valaccodeelementaccessbinding.vala b/gobject/valaccodeelementaccessbinding.vala index d4b959354..e021fb38b 100644 --- a/gobject/valaccodeelementaccessbinding.vala +++ b/gobject/valaccodeelementaccessbinding.vala @@ -41,7 +41,7 @@ public class Vala.CCodeElementAccessBinding : CCodeExpressionBinding { Gee.List indices = expr.get_indices (); int rank = indices.size; - var container_type = expr.container.static_type.data_type; + var container_type = expr.container.value_type.data_type; var ccontainer = (CCodeExpression) expr.container.ccodenode; var cindex = (CCodeExpression) indices[0].ccodenode; @@ -78,7 +78,7 @@ public class Vala.CCodeElementAccessBinding : CCodeExpressionBinding { var get_param = get_params_it.get (); if (get_param.type_reference.type_parameter != null) { - var index_type = SemanticAnalyzer.get_actual_type (expr.container.static_type, get_method, get_param.type_reference, expr); + var index_type = SemanticAnalyzer.get_actual_type (expr.container.value_type, get_method, get_param.type_reference, expr); cindex = codegen.convert_to_generic_pointer (cindex, index_type); } @@ -86,7 +86,7 @@ public class Vala.CCodeElementAccessBinding : CCodeExpressionBinding { get_ccall.add_argument (new CCodeCastExpression (ccontainer, collection_iface.get_cname () + "*")); get_ccall.add_argument (cindex); - codenode = codegen.convert_from_generic_pointer (get_ccall, expr.static_type); + codenode = codegen.convert_from_generic_pointer (get_ccall, expr.value_type); } else { // access to element in an array for (int i = 1; i < rank; i++) { diff --git a/gobject/valaccodegenerator.vala b/gobject/valaccodegenerator.vala index a3aecd146..0f8a7e2c3 100644 --- a/gobject/valaccodegenerator.vala +++ b/gobject/valaccodegenerator.vala @@ -597,7 +597,7 @@ public class Vala.CCodeGenerator : CodeGenerator { if (f.initializer != null) { var rhs = (CCodeExpression) f.initializer.ccodenode; - rhs = get_implicit_cast_expression (rhs, f.initializer.static_type, f.type_reference); + rhs = get_implicit_cast_expression (rhs, f.initializer.value_type, f.type_reference); instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs, rhs))); @@ -1142,7 +1142,7 @@ public class Vala.CCodeGenerator : CodeGenerator { CCodeExpression rhs = null; if (local.initializer != null && local.initializer.ccodenode != null) { rhs = (CCodeExpression) local.initializer.ccodenode; - rhs = get_implicit_cast_expression (rhs, local.initializer.static_type, local.variable_type); + rhs = get_implicit_cast_expression (rhs, local.initializer.value_type, local.variable_type); if (local.variable_type is ArrayType) { var array_type = (ArrayType) local.variable_type; @@ -1226,7 +1226,7 @@ public class Vala.CCodeGenerator : CodeGenerator { var clist = new CCodeInitializerList (); foreach (Expression expr in list.get_initializers ()) { - clist.append (get_implicit_cast_expression ((CCodeExpression) expr.ccodenode, expr.static_type, expr.expected_type)); + clist.append (get_implicit_cast_expression ((CCodeExpression) expr.ccodenode, expr.value_type, expr.expected_type)); } list.ccodenode = clist; } @@ -1463,7 +1463,7 @@ public class Vala.CCodeGenerator : CodeGenerator { return; } - var full_expr_var = get_temp_variable (expr.static_type, true, expr); + var full_expr_var = get_temp_variable (expr.value_type, true, expr); expr.temp_vars.add (full_expr_var); var expr_list = new CCodeCommaExpression (); @@ -1655,7 +1655,7 @@ public class Vala.CCodeGenerator : CodeGenerator { public override void visit_switch_statement (SwitchStatement stmt) { // we need a temporary variable to save the property value - var temp_var = get_temp_variable (stmt.expression.static_type, true, stmt); + var temp_var = get_temp_variable (stmt.expression.value_type, true, stmt); stmt.expression.temp_vars.insert (0, temp_var); var ctemp = new CCodeIdentifier (temp_var.name); @@ -1872,8 +1872,8 @@ public class Vala.CCodeGenerator : CodeGenerator { cblock.add_statement (cfrag); } - if (stmt.collection.static_type is ArrayType) { - var array_type = (ArrayType) stmt.collection.static_type; + if (stmt.collection.value_type is ArrayType) { + var array_type = (ArrayType) stmt.collection.value_type; var array_len = get_array_length_cexpression (stmt.collection); @@ -1893,7 +1893,7 @@ public class Vala.CCodeGenerator : CodeGenerator { if (stmt.type_reference.takes_ownership) { var ma = new MemberAccess.simple (stmt.variable_name); - ma.static_type = stmt.type_reference; + ma.value_type = stmt.type_reference; ma.ccodenode = element_expr; element_expr = get_ref_expression (ma); @@ -1937,7 +1937,7 @@ public class Vala.CCodeGenerator : CodeGenerator { if (stmt.type_reference.takes_ownership) { var ma = new MemberAccess.simple (stmt.variable_name); - ma.static_type = stmt.type_reference; + ma.value_type = stmt.type_reference; ma.ccodenode = element_expr; element_expr = get_ref_expression (ma); @@ -1979,7 +1979,7 @@ public class Vala.CCodeGenerator : CodeGenerator { cfor.add_iterator (new CCodeAssignment (new CCodeIdentifier (it_name), new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier (it_name), new CCodeConstant ("1")))); cblock.add_statement (cfor); } - } else if (stmt.collection.static_type.compatible (new ClassInstanceType (glist_type)) || stmt.collection.static_type.compatible (new ClassInstanceType (gslist_type))) { + } else if (stmt.collection.value_type.compatible (new ClassInstanceType (glist_type)) || stmt.collection.value_type.compatible (new ClassInstanceType (gslist_type))) { var it_name = "%s_it".printf (stmt.variable_name); var citdecl = new CCodeDeclaration (collection_type.get_cname ()); @@ -2005,7 +2005,7 @@ public class Vala.CCodeGenerator : CodeGenerator { if (stmt.type_reference.takes_ownership) { var ma = new MemberAccess.simple (stmt.variable_name); - ma.static_type = stmt.type_reference; + ma.value_type = stmt.type_reference; ma.ccodenode = element_expr; element_expr = get_ref_expression (ma); @@ -2031,7 +2031,7 @@ public class Vala.CCodeGenerator : CodeGenerator { cfor.add_iterator (new CCodeAssignment (new CCodeIdentifier (it_name), new CCodeMemberAccess.pointer (new CCodeIdentifier (it_name), "next"))); cblock.add_statement (cfor); - } else if (iterable_type != null && stmt.collection.static_type.compatible (new InterfaceInstanceType (iterable_type))) { + } else if (iterable_type != null && stmt.collection.value_type.compatible (new InterfaceInstanceType (iterable_type))) { var it_name = "%s_it".printf (stmt.variable_name); var citdecl = new CCodeDeclaration (iterator_type.get_cname () + "*"); @@ -2054,13 +2054,13 @@ public class Vala.CCodeGenerator : CodeGenerator { Iterator 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); + var it_type = SemanticAnalyzer.get_actual_type (stmt.collection.value_type, it_method, type_arg_it.get (), stmt); element_expr = get_implicit_cast_expression (element_expr, it_type, stmt.type_reference); if (stmt.type_reference.takes_ownership && !it_type.takes_ownership) { var ma = new MemberAccess.simple (stmt.variable_name); - ma.static_type = stmt.type_reference; + ma.value_type = stmt.type_reference; ma.ccodenode = element_expr; element_expr = get_ref_expression (ma); @@ -2196,7 +2196,7 @@ public class Vala.CCodeGenerator : CodeGenerator { } private void create_local_free_expr (Expression expr) { - var return_expr_decl = get_temp_variable (expr.static_type, true, expr); + var return_expr_decl = get_temp_variable (expr.value_type, true, expr); var ccomma = new CCodeCommaExpression (); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (return_expr_decl.name), (CCodeExpression) expr.ccodenode)); @@ -2255,7 +2255,7 @@ public class Vala.CCodeGenerator : CodeGenerator { // return array length if appropriate if (current_method != null && !current_method.no_array_length && current_return_type is ArrayType) { - var return_expr_decl = get_temp_variable (stmt.return_expression.static_type, true, stmt); + var return_expr_decl = get_temp_variable (stmt.return_expression.value_type, true, stmt); var ccomma = new CCodeCommaExpression (); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (return_expr_decl.name), (CCodeExpression) stmt.return_expression.ccodenode)); @@ -2276,7 +2276,7 @@ public class Vala.CCodeGenerator : CodeGenerator { create_local_free_expr (stmt.return_expression); - stmt.return_expression.ccodenode = get_implicit_cast_expression ((CCodeExpression) stmt.return_expression.ccodenode, stmt.return_expression.static_type, current_return_type); + stmt.return_expression.ccodenode = get_implicit_cast_expression ((CCodeExpression) stmt.return_expression.ccodenode, stmt.return_expression.value_type, current_return_type); // Property getters of non simple structs shall return the struct value as out parameter, // therefore replace any return statement with an assignment statement to the out formal @@ -2429,7 +2429,7 @@ public class Vala.CCodeGenerator : CodeGenerator { public override void visit_delete_statement (DeleteStatement stmt) { stmt.accept_children (this); - var pointer_type = (PointerType) stmt.expression.static_type; + var pointer_type = (PointerType) stmt.expression.value_type; DataType type = pointer_type; if (pointer_type.base_type.data_type != null && pointer_type.base_type.data_type.is_reference_type ()) { type = pointer_type.base_type; @@ -2507,7 +2507,7 @@ public class Vala.CCodeGenerator : CodeGenerator { public CCodeExpression get_array_length_cexpression (Expression array_expr, int dim = -1) { // dim == -1 => total size over all dimensions if (dim == -1) { - var array_type = array_expr.static_type as ArrayType; + var array_type = array_expr.value_type as ArrayType; if (array_type != null && array_type.rank > 1) { CCodeExpression cexpr = get_array_length_cexpression (array_expr, 1); for (dim = 2; dim <= array_type.rank; dim++) { @@ -2583,8 +2583,8 @@ public class Vala.CCodeGenerator : CodeGenerator { } else { pub_inst = (CCodeExpression) ma.inner.ccodenode; - if (ma.inner.static_type != null) { - base_type = ma.inner.static_type.data_type; + if (ma.inner.value_type != null) { + base_type = ma.inner.value_type.data_type; } } @@ -2704,8 +2704,8 @@ public class Vala.CCodeGenerator : CodeGenerator { } else { pub_inst = (CCodeExpression) ma.inner.ccodenode; - if (ma.inner.static_type != null) { - base_type = ma.inner.static_type.data_type; + if (ma.inner.value_type != null) { + base_type = ma.inner.value_type.data_type; } } @@ -2756,7 +2756,7 @@ public class Vala.CCodeGenerator : CodeGenerator { } public override void visit_base_access (BaseAccess expr) { - expr.ccodenode = new InstanceCast (new CCodeIdentifier ("self"), expr.static_type.data_type); + expr.ccodenode = new InstanceCast (new CCodeIdentifier ("self"), expr.value_type.data_type); } public override void visit_postfix_expression (PostfixExpression expr) { @@ -2818,7 +2818,7 @@ public class Vala.CCodeGenerator : CodeGenerator { * if static type of expr is non-null */ - var dupexpr = get_dup_func_expression (expr.static_type, expr.source_reference); + var dupexpr = get_dup_func_expression (expr.value_type, expr.source_reference); if (dupexpr == null) { expr.error = true; @@ -2833,23 +2833,23 @@ public class Vala.CCodeGenerator : CodeGenerator { return ccall; } else { - var decl = get_temp_variable (expr.static_type, false, expr); + var decl = get_temp_variable (expr.value_type, false, expr); temp_vars.insert (0, decl); var ctemp = new CCodeIdentifier (decl.name); var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ctemp, new CCodeConstant ("NULL")); - if (expr.static_type.data_type == null) { + if (expr.value_type.data_type == null) { if (!(current_type_symbol is Class)) { return (CCodeExpression) expr.ccodenode; } // dup functions are optional for type parameters - var cdupisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, get_dup_func_expression (expr.static_type, expr.source_reference), new CCodeConstant ("NULL")); + var cdupisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, get_dup_func_expression (expr.value_type, expr.source_reference), new CCodeConstant ("NULL")); cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.OR, cisnull, cdupisnull); } - if (expr.static_type.data_type != null) { + if (expr.value_type.data_type != null) { ccall.add_argument (ctemp); } else { // cast from gconstpointer to gpointer as GBoxedCopyFunc expects gpointer @@ -2860,7 +2860,7 @@ public class Vala.CCodeGenerator : CodeGenerator { ccomma.append_expression (new CCodeAssignment (ctemp, (CCodeExpression) expr.ccodenode)); CCodeExpression cifnull; - if (expr.static_type.data_type != null) { + if (expr.value_type.data_type != null) { cifnull = new CCodeConstant ("NULL"); } else { // the value might be non-null even when the dup function is null, @@ -2877,9 +2877,9 @@ public class Vala.CCodeGenerator : CodeGenerator { } public void visit_expression (Expression expr) { - if (expr.static_type != null && - expr.static_type.transfers_ownership && - expr.static_type.floating_reference) { + if (expr.value_type != null && + expr.value_type.transfers_ownership && + expr.value_type.floating_reference) { /* constructor of GInitiallyUnowned subtype * returns floating reference, sink it */ @@ -2890,7 +2890,7 @@ public class Vala.CCodeGenerator : CodeGenerator { } if (expr.ref_leaked) { - var decl = get_temp_variable (expr.static_type, true, expr); + var decl = get_temp_variable (expr.value_type, true, expr); temp_vars.insert (0, decl); temp_ref_vars.insert (0, decl); expr.ccodenode = new CCodeParenthesizedExpression (new CCodeAssignment (new CCodeIdentifier (get_variable_cname (decl.name)), (CCodeExpression) expr.ccodenode)); @@ -2981,7 +2981,7 @@ public class Vala.CCodeGenerator : CodeGenerator { param = params_it.get (); ellipsis = param.ellipsis; if (!param.ellipsis) { - cexpr = get_implicit_cast_expression (cexpr, arg.static_type, param.type_reference); + cexpr = get_implicit_cast_expression (cexpr, arg.value_type, param.type_reference); // pass non-simple struct instances always by reference if (param.type_reference.data_type is Struct && !((Struct) param.type_reference.data_type).is_simple_type ()) { @@ -2994,7 +2994,7 @@ public class Vala.CCodeGenerator : CodeGenerator { // (tmp = expr, &tmp) var ccomma = new CCodeCommaExpression (); - var temp_var = get_temp_variable (arg.static_type); + var temp_var = get_temp_variable (arg.value_type); temp_vars.insert (0, temp_var); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_var.name), cexpr)); ccomma.append_expression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_var.name))); @@ -3093,7 +3093,7 @@ public class Vala.CCodeGenerator : CodeGenerator { ccomma.append_expression (new CCodeAssignment (lhs, (CCodeExpression) init.initializer.ccodenode)); } else if (init.symbol_reference is Property) { var inst_ma = new MemberAccess.simple ("new"); - inst_ma.static_type = expr.type_reference; + inst_ma.value_type = expr.type_reference; inst_ma.ccodenode = instance; var ma = new MemberAccess (inst_ma, init.name); ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, (CCodeExpression) init.initializer.ccodenode)); @@ -3151,7 +3151,7 @@ public class Vala.CCodeGenerator : CodeGenerator { // checked cast for strict subtypes of GTypeInstance if (expr.is_silent_cast) { var ccomma = new CCodeCommaExpression (); - var temp_decl = get_temp_variable (expr.inner.static_type, true, expr); + var temp_decl = get_temp_variable (expr.inner.value_type, true, expr); temp_vars.add (temp_decl); @@ -3191,7 +3191,7 @@ public class Vala.CCodeGenerator : CodeGenerator { public override void visit_reference_transfer_expression (ReferenceTransferExpression expr) { /* (tmp = var, var = null, tmp) */ var ccomma = new CCodeCommaExpression (); - var temp_decl = get_temp_variable (expr.static_type, true, expr); + var temp_decl = get_temp_variable (expr.value_type, true, expr); temp_vars.insert (0, temp_decl); var cvar = new CCodeIdentifier (temp_decl.name); @@ -3253,13 +3253,13 @@ public class Vala.CCodeGenerator : CodeGenerator { if (expr.operator == BinaryOperator.EQUALITY || expr.operator == BinaryOperator.INEQUALITY) { - var left_type_as_struct = expr.left.static_type.data_type as Struct; - var right_type_as_struct = expr.right.static_type.data_type as Struct; + var left_type_as_struct = expr.left.value_type.data_type as Struct; + var right_type_as_struct = expr.right.value_type.data_type as Struct; - if (expr.left.static_type.data_type is Class && ((Class) expr.left.static_type.data_type).is_subtype_of (gobject_type) && - expr.right.static_type.data_type is Class && ((Class) expr.right.static_type.data_type).is_subtype_of (gobject_type)) { - var left_cl = (Class) expr.left.static_type.data_type; - var right_cl = (Class) expr.right.static_type.data_type; + if (expr.left.value_type.data_type is Class && ((Class) expr.left.value_type.data_type).is_subtype_of (gobject_type) && + expr.right.value_type.data_type is Class && ((Class) expr.right.value_type.data_type).is_subtype_of (gobject_type)) { + var left_cl = (Class) expr.left.value_type.data_type; + var right_cl = (Class) expr.right.value_type.data_type; if (left_cl != right_cl) { if (left_cl.is_subtype_of (right_cl)) { @@ -3268,17 +3268,17 @@ public class Vala.CCodeGenerator : CodeGenerator { cright = new InstanceCast (cright, left_cl); } } - } else if (left_type_as_struct != null && expr.right.static_type is NullType) { + } else if (left_type_as_struct != null && expr.right.value_type is NullType) { cleft = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cleft); - } else if (right_type_as_struct != null && expr.left.static_type is NullType) { + } else if (right_type_as_struct != null && expr.left.value_type is NullType) { cright = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cright); } } - if (!(expr.left.static_type is NullType) - && expr.left.static_type.compatible (string_type) - && !(expr.right.static_type is NullType) - && expr.right.static_type.compatible (string_type) + if (!(expr.left.value_type is NullType) + && expr.left.value_type.compatible (string_type) + && !(expr.right.value_type is NullType) + && expr.right.value_type.compatible (string_type) && (expr.operator == BinaryOperator.EQUALITY || expr.operator == BinaryOperator.INEQUALITY || expr.operator == BinaryOperator.LESS_THAN @@ -3594,7 +3594,7 @@ public class Vala.CCodeGenerator : CodeGenerator { instance_expression_type = get_data_type_for_symbol (current_type_symbol); } else { instance = (CCodeExpression) ma.inner.ccodenode; - instance_expression_type = ma.inner.static_type; + instance_expression_type = ma.inner.value_type; } var instance_target_type = get_data_type_for_symbol ((Typesymbol) base_property.parent_symbol); @@ -3649,7 +3649,7 @@ public class Vala.CCodeGenerator : CodeGenerator { } var ccomma = new CCodeCommaExpression (); - var temp_decl = get_temp_variable (e.static_type); + var temp_decl = get_temp_variable (e.value_type); var ctemp = new CCodeIdentifier (temp_decl.name); temp_vars.add (temp_decl); ccomma.append_expression (new CCodeAssignment (ctemp, ce)); diff --git a/gobject/valaccodeinvocationexpressionbinding.vala b/gobject/valaccodeinvocationexpressionbinding.vala index 857e28e15..12f411d86 100644 --- a/gobject/valaccodeinvocationexpressionbinding.vala +++ b/gobject/valaccodeinvocationexpressionbinding.vala @@ -51,7 +51,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { var ma = (MemberAccess) expr.call; - var itype = expr.call.static_type; + var itype = expr.call.value_type; params = itype.get_parameters (); if (itype is MethodType) { @@ -66,7 +66,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { var carg_map = new HashMap (direct_hash, direct_equal); if (m is ArrayResizeMethod) { - var array_type = (ArrayType) ma.inner.static_type; + var array_type = (ArrayType) ma.inner.value_type; carg_map.set (codegen.get_param_pos (0), new CCodeIdentifier (array_type.element_type.get_cname ())); } else if (m is ArrayMoveMethod) { codegen.requires_array_move = true; @@ -87,7 +87,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { instance_expression_type = codegen.get_data_type_for_symbol (codegen.current_type_symbol); } else { instance = (CCodeExpression) ma.inner.ccodenode; - instance_expression_type = ma.inner.static_type; + instance_expression_type = ma.inner.value_type; } if (instance_expression_type.data_type is Struct @@ -111,7 +111,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { // parent_symbol may be null for late bound methods if (base_method.parent_symbol != null) { - var instance_target_type = ma.static_type.copy (); + var instance_target_type = ma.value_type.copy (); instance_target_type.data_type = (Typesymbol) base_method.parent_symbol; instance = codegen.get_implicit_cast_expression (instance, instance_expression_type, instance_target_type); } @@ -126,7 +126,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { } if (m is ArrayMoveMethod) { - var array_type = (ArrayType) ma.inner.static_type; + var array_type = (ArrayType) ma.inner.value_type; var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof")); csizeof.add_argument (new CCodeIdentifier (array_type.element_type.get_cname ())); carg_map.set (codegen.get_param_pos (0.1), csizeof); @@ -137,17 +137,17 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { var unary = arg as UnaryExpression; if (unary != null && unary.operator == UnaryOperator.OUT) { // out argument - var param = new FormalParameter ("param%d".printf (param_nr), unary.inner.static_type); + var param = new FormalParameter ("param%d".printf (param_nr), unary.inner.value_type); param.direction = ParameterDirection.OUT; m.add_parameter (param); } else if (unary != null && unary.operator == UnaryOperator.REF) { // ref argument - var param = new FormalParameter ("param%d".printf (param_nr), unary.inner.static_type); + var param = new FormalParameter ("param%d".printf (param_nr), unary.inner.value_type); param.direction = ParameterDirection.REF; m.add_parameter (param); } else { // in argument - m.add_parameter (new FormalParameter ("param%d".printf (param_nr), arg.static_type)); + m.add_parameter (new FormalParameter ("param%d".printf (param_nr), arg.value_type)); } param_nr++; } @@ -195,11 +195,11 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { } if (param.direction == ParameterDirection.IN) { // don't cast arguments passed by reference - cexpr = codegen.get_implicit_cast_expression (cexpr, arg.static_type, param.type_reference); + cexpr = codegen.get_implicit_cast_expression (cexpr, arg.value_type, param.type_reference); } // pass non-simple struct instances always by reference - if (!(arg.static_type is NullType) && param.type_reference.data_type is Struct && !((Struct) param.type_reference.data_type).is_simple_type ()) { + if (!(arg.value_type is NullType) && param.type_reference.data_type is Struct && !((Struct) param.type_reference.data_type).is_simple_type ()) { // we already use a reference for arguments of ref and out parameters if (param.direction == ParameterDirection.IN) { if (cexpr is CCodeIdentifier) { @@ -209,7 +209,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { // (tmp = expr, &tmp) var ccomma = new CCodeCommaExpression (); - var temp_var = codegen.get_temp_variable (arg.static_type); + var temp_var = codegen.get_temp_variable (arg.value_type); codegen.temp_vars.insert (0, temp_var); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_var.name), cexpr)); ccomma.append_expression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_var.name))); @@ -227,7 +227,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { var ccomma = new CCodeCommaExpression (); - var temp_decl = codegen.get_temp_variable (arg.static_type); + var temp_decl = codegen.get_temp_variable (arg.value_type); codegen.temp_vars.insert (0, temp_decl); ccomma.append_expression (new CCodeAssignment (new CCodeIdentifier (temp_decl.name), cexpr)); @@ -239,13 +239,13 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { } // unref old value for non-null non-weak out arguments - if (param.direction == ParameterDirection.OUT && param.type_reference.takes_ownership && !(arg.static_type is NullType)) { + if (param.direction == ParameterDirection.OUT && param.type_reference.takes_ownership && !(arg.value_type is NullType)) { var unary = (UnaryExpression) arg; // (ret_tmp = call (&tmp), free (var1), var1 = tmp, ret_tmp) var ccomma = new CCodeCommaExpression (); - var temp_var = codegen.get_temp_variable (unary.inner.static_type); + var temp_var = codegen.get_temp_variable (unary.inner.value_type); codegen.temp_vars.insert (0, temp_var); cexpr = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_var.name)); @@ -260,7 +260,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { } // unref old value - ccomma.append_expression (codegen.get_unref_expression ((CCodeExpression) unary.inner.ccodenode, arg.static_type, arg)); + ccomma.append_expression (codegen.get_unref_expression ((CCodeExpression) unary.inner.ccodenode, arg.value_type, arg)); // assign new value ccomma.append_expression (new CCodeAssignment ((CCodeExpression) unary.inner.ccodenode, new CCodeIdentifier (temp_var.name))); @@ -387,8 +387,8 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { expr.ccodenode = new CCodeAssignment (instance, ccall_expr); } else { /* cast pointer to actual type if this is a generic method return value */ - if (m != null && m.return_type.type_parameter != null && expr.static_type.data_type != null) { - expr.ccodenode = codegen.convert_from_generic_pointer (ccall_expr, expr.static_type); + if (m != null && m.return_type.type_parameter != null && expr.value_type.data_type != null) { + expr.ccodenode = codegen.convert_from_generic_pointer (ccall_expr, expr.value_type); } else { expr.ccodenode = ccall_expr; } @@ -412,7 +412,7 @@ public class Vala.CCodeInvocationExpressionBinding : CCodeExpressionBinding { var clen = codegen.get_array_length_cexpression (ma.inner, 1); var celems = (CCodeExpression) ma.inner.ccodenode; - var array_type = (ArrayType) ma.inner.static_type; + var array_type = (ArrayType) ma.inner.value_type; var csizeof = new CCodeIdentifier ("sizeof (%s)".printf (array_type.element_type.get_cname ())); var cdelta = new CCodeParenthesizedExpression (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, temp_ref, clen)); var ccheck = new CCodeBinaryExpression (CCodeBinaryOperator.GREATER_THAN, temp_ref, clen); diff --git a/gobject/valaccodememberaccessbinding.vala b/gobject/valaccodememberaccessbinding.vala index 67c5891a5..d7d56a4ea 100644 --- a/gobject/valaccodememberaccessbinding.vala +++ b/gobject/valaccodememberaccessbinding.vala @@ -59,7 +59,7 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding { if (expr.inner != null && !expr.inner.is_pure ()) { // instance expression has side-effects // store in temp. variable - var temp_var = codegen.get_temp_variable (expr.inner.static_type); + var temp_var = codegen.get_temp_variable (expr.inner.value_type); codegen.temp_vars.insert (0, temp_var); var ctemp = new CCodeIdentifier (temp_var.name); inst = new CCodeAssignment (ctemp, pub_inst); @@ -94,7 +94,7 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding { } else { inst = typed_inst; } - if (instance_target_type.data_type.is_reference_type () || (expr.inner != null && expr.inner.static_type is PointerType)) { + if (instance_target_type.data_type.is_reference_type () || (expr.inner != null && expr.inner.value_type is PointerType)) { expr.ccodenode = new CCodeMemberAccess.pointer (inst, f.get_cname ()); } else { expr.ccodenode = new CCodeMemberAccess (inst, f.get_cname ()); @@ -108,8 +108,8 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding { expr.ccodenode = new CCodeIdentifier (f.get_cname ()); } - if (f.type_reference.type_parameter != null && expr.static_type.type_parameter == null) { - expr.ccodenode = codegen.convert_from_generic_pointer ((CCodeExpression) expr.ccodenode, expr.static_type); + if (f.type_reference.type_parameter != null && expr.value_type.type_parameter == null) { + expr.ccodenode = codegen.convert_from_generic_pointer ((CCodeExpression) expr.ccodenode, expr.value_type); } } else if (expr.symbol_reference is Constant) { var c = (Constant) expr.symbol_reference; @@ -165,7 +165,7 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding { // we need a temporary variable to save the property value - var temp_var = codegen.get_temp_variable (expr.static_type); + var temp_var = codegen.get_temp_variable (expr.value_type); codegen.temp_vars.insert (0, temp_var); var ctemp = new CCodeIdentifier (temp_var.name); @@ -258,8 +258,8 @@ public class Vala.CCodeMemberAccessBinding : CCodeExpressionBinding { } else { pub_inst = (CCodeExpression) expr.inner.ccodenode; - if (expr.inner.static_type != null) { - base_type = expr.inner.static_type; + if (expr.inner.value_type != null) { + base_type = expr.inner.value_type; } } diff --git a/vala/valaexpression.vala b/vala/valaexpression.vala index 0abd76d36..acc99b2e0 100644 --- a/vala/valaexpression.vala +++ b/vala/valaexpression.vala @@ -28,11 +28,11 @@ using Gee; */ public abstract class Vala.Expression : CodeNode { /** - * The static type of this expression. + * The static type of the value of this expression. * * The semantic analyzer computes this value. */ - public DataType static_type { get; set; } + public DataType value_type { get; set; } /* * The static type this expression is expected to have. diff --git a/vala/valamemorymanager.vala b/vala/valamemorymanager.vala index 2a4bc9210..c3a2cb662 100644 --- a/vala/valamemorymanager.vala +++ b/vala/valamemorymanager.vala @@ -41,17 +41,17 @@ public class Vala.MemoryManager : CodeVisitor { } private void visit_possibly_leaked_expression (Expression expr) { - if (expr.static_type != null - && expr.static_type.transfers_ownership) { + if (expr.value_type != null + && expr.value_type.transfers_ownership) { /* mark reference as leaked */ expr.ref_leaked = true; } } private void visit_possibly_missing_copy_expression (Expression expr) { - if (expr.static_type != null - && !expr.static_type.transfers_ownership - && !(expr.static_type is NullType)) { + if (expr.value_type != null + && !expr.value_type.transfers_ownership + && !(expr.value_type is NullType)) { /* mark reference as missing */ expr.ref_missing = true; } @@ -215,7 +215,7 @@ public class Vala.MemoryManager : CodeVisitor { public override void visit_array_creation_expression (ArrayCreationExpression e) { if (e.initializer_list != null) { foreach (Expression init in e.initializer_list.get_initializers ()) { - if (init.static_type.is_reference_type_or_type_parameter ()) { + if (init.value_type.is_reference_type_or_type_parameter ()) { visit_possibly_missing_copy_expression (init); } else { visit_possibly_leaked_expression (init); @@ -237,7 +237,7 @@ public class Vala.MemoryManager : CodeVisitor { public override void visit_invocation_expression (InvocationExpression expr) { expr.accept_children (this); - var mtype = expr.call.static_type; + var mtype = expr.call.value_type; Collection params = mtype.get_parameters (); Iterator params_it = params.iterator (); @@ -250,7 +250,7 @@ public class Vala.MemoryManager : CodeVisitor { if (is_ref && param.type_reference.type_parameter != null) { if (expr.call is MemberAccess) { var ma = (MemberAccess) expr.call; - var param_type = SemanticAnalyzer.get_actual_type (ma.inner.static_type, ma.symbol_reference, param.type_reference, expr); + var param_type = SemanticAnalyzer.get_actual_type (ma.inner.value_type, ma.symbol_reference, param.type_reference, expr); if (param_type != null) { is_ref = param_type.takes_ownership; } @@ -323,8 +323,8 @@ public class Vala.MemoryManager : CodeVisitor { if (a.left is PointerIndirection || a.left.symbol_reference is Signal) { } else { - if (!(a.left.static_type is PointerType)) { - if (a.left.static_type.takes_ownership) { + if (!(a.left.value_type is PointerType)) { + if (a.left.value_type.takes_ownership) { visit_possibly_missing_copy_expression (a.right); } else { visit_possibly_leaked_expression (a.right); diff --git a/vala/valanullchecker.vala b/vala/valanullchecker.vala index 0524e9386..12a7a6f3c 100644 --- a/vala/valanullchecker.vala +++ b/vala/valanullchecker.vala @@ -41,18 +41,18 @@ public class Vala.NullChecker : CodeVisitor { void check_compatible (Expression expr, DataType target_type) { if (!target_type.nullable) { - if (expr.static_type is NullType) { + if (expr.value_type is NullType) { Report.error (expr.source_reference, "`null' incompatible with `%s'".printf (target_type.to_string ())); - } else if (expr.static_type.nullable) { - Report.warning (expr.source_reference, "`%s' incompatible with `%s'".printf (expr.static_type.to_string (), target_type.to_string ())); + } else if (expr.value_type.nullable) { + Report.warning (expr.source_reference, "`%s' incompatible with `%s'".printf (expr.value_type.to_string (), target_type.to_string ())); } } } void check_non_null (Expression expr) { - if (expr.static_type is NullType) { + if (expr.value_type is NullType) { Report.error (expr.source_reference, "null dereference"); - } else if (expr.static_type.nullable) { + } else if (expr.value_type.nullable) { Report.warning (expr.source_reference, "possible null dereference"); } } @@ -197,7 +197,7 @@ public class Vala.NullChecker : CodeVisitor { public override void visit_invocation_expression (InvocationExpression expr) { expr.accept_children (this); - var mtype = expr.call.static_type as MethodType; + var mtype = expr.call.value_type as MethodType; var ma = expr.call as MemberAccess; if (mtype != null && mtype.method_symbol.binding == MemberBinding.INSTANCE && ma != null) { if (ma.inner == null) { @@ -240,6 +240,6 @@ public class Vala.NullChecker : CodeVisitor { public override void visit_assignment (Assignment a) { a.accept_children (this); - check_compatible (a.right, a.left.static_type); + check_compatible (a.right, a.left.value_type); } } diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala index a629292f1..e7aa9dd6b 100644 --- a/vala/valasemanticanalyzer.vala +++ b/vala/valasemanticanalyzer.vala @@ -449,7 +449,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!precondition.static_type.compatible (bool_type)) { + if (!precondition.value_type.compatible (bool_type)) { m.error = true; Report.error (precondition.source_reference, "Precondition must be boolean"); return; @@ -463,7 +463,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!postcondition.static_type.compatible (bool_type)) { + if (!postcondition.value_type.compatible (bool_type)) { m.error = true; Report.error (postcondition.source_reference, "Postcondition must be boolean"); return; @@ -807,13 +807,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.error (local.source_reference, "var declaration not allowed without initializer"); return; } - if (local.initializer.static_type == null) { + if (local.initializer.value_type == null) { local.error = true; Report.error (local.source_reference, "var declaration not allowed with non-typed initializer"); return; } - local.variable_type = local.initializer.static_type.copy (); + local.variable_type = local.initializer.value_type.copy (); local.variable_type.takes_ownership = (local.variable_type.data_type == null || local.variable_type.data_type.is_reference_type ()); local.variable_type.transfers_ownership = false; @@ -823,7 +823,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (local.initializer != null) { - if (local.initializer.static_type == null) { + if (local.initializer.value_type == null) { if (!(local.initializer is MemberAccess) && !(local.initializer is LambdaExpression)) { local.error = true; Report.error (local.source_reference, "expression type not allowed as initializer"); @@ -843,7 +843,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - local.initializer.static_type = local.variable_type; + local.initializer.value_type = local.variable_type; } else { local.error = true; Report.error (local.source_reference, "expression type not allowed as initializer"); @@ -851,13 +851,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } } - if (!local.initializer.static_type.compatible (local.variable_type)) { + if (!local.initializer.value_type.compatible (local.variable_type)) { local.error = true; - Report.error (local.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (local.initializer.static_type.to_string (), local.variable_type.to_string ())); + Report.error (local.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (local.initializer.value_type.to_string (), local.variable_type.to_string ())); return; } - if (local.initializer.static_type.transfers_ownership) { + if (local.initializer.value_type.transfers_ownership) { /* rhs transfers ownership of the expression */ if (!(local.variable_type is PointerType) && !local.variable_type.takes_ownership) { /* lhs doesn't own the value */ @@ -927,7 +927,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { bool error = false; foreach (Expression e in list.get_initializers ()) { - if (e.static_type == null) { + if (e.value_type == null) { error = true; continue; } @@ -935,16 +935,16 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var unary = e as UnaryExpression; if (unary != null && (unary.operator == UnaryOperator.REF || unary.operator == UnaryOperator.OUT)) { // TODO check type for ref and out expressions - } else if (!e.static_type.compatible (e.expected_type)) { + } else if (!e.value_type.compatible (e.expected_type)) { error = true; e.error = true; - Report.error (e.source_reference, "Expected initializer of type `%s' but got `%s'".printf (e.expected_type.to_string (), e.static_type.to_string ())); + Report.error (e.source_reference, "Expected initializer of type `%s' but got `%s'".printf (e.expected_type.to_string (), e.value_type.to_string ())); } } if (!error) { /* everything seems to be correct */ - list.static_type = list.expected_type; + list.value_type = list.expected_type; } } @@ -967,7 +967,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!stmt.condition.static_type.compatible (bool_type)) { + if (!stmt.condition.value_type.compatible (bool_type)) { stmt.error = true; Report.error (stmt.condition.source_reference, "Condition must be boolean"); return; @@ -1002,7 +1002,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!stmt.condition.static_type.compatible (bool_type)) { + if (!stmt.condition.value_type.compatible (bool_type)) { stmt.error = true; Report.error (stmt.condition.source_reference, "Condition must be boolean"); return; @@ -1018,7 +1018,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!stmt.condition.static_type.compatible (bool_type)) { + if (!stmt.condition.value_type.compatible (bool_type)) { stmt.error = true; Report.error (stmt.condition.source_reference, "Condition must be boolean"); return; @@ -1034,7 +1034,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (stmt.condition != null && !stmt.condition.static_type.compatible (bool_type)) { + if (stmt.condition != null && !stmt.condition.value_type.compatible (bool_type)) { stmt.error = true; Report.error (stmt.condition.source_reference, "Condition must be boolean"); return; @@ -1066,15 +1066,15 @@ public class Vala.SemanticAnalyzer : CodeVisitor { // ignore inner error stmt.error = true; return; - } else if (stmt.collection.static_type == null) { + } else if (stmt.collection.value_type == null) { Report.error (stmt.collection.source_reference, "invalid collection expression"); stmt.error = true; return; } - var collection_type = stmt.collection.static_type.copy (); + var collection_type = stmt.collection.value_type.copy (); collection_type.transfers_ownership = false; - collection_type.takes_ownership = stmt.collection.static_type.transfers_ownership; + collection_type.takes_ownership = stmt.collection.value_type.transfers_ownership; stmt.collection_variable = new LocalVariable (collection_type, "%s_collection".printf (stmt.variable_name)); stmt.add_local_variable (stmt.collection_variable); @@ -1156,13 +1156,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (stmt.return_expression != null && - !stmt.return_expression.static_type.compatible (current_return_type)) { - Report.error (stmt.source_reference, "Return: Cannot convert from `%s' to `%s'".printf (stmt.return_expression.static_type.to_string (), current_return_type.to_string ())); + !stmt.return_expression.value_type.compatible (current_return_type)) { + Report.error (stmt.source_reference, "Return: Cannot convert from `%s' to `%s'".printf (stmt.return_expression.value_type.to_string (), current_return_type.to_string ())); return; } if (stmt.return_expression != null && - stmt.return_expression.static_type.transfers_ownership && + stmt.return_expression.value_type.transfers_ownership && !current_return_type.transfers_ownership) { stmt.error = true; Report.error (stmt.source_reference, "Return value transfers ownership but method return type hasn't been declared to transfer ownership"); @@ -1171,7 +1171,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (stmt.return_expression != null && stmt.return_expression.symbol_reference is LocalVariable && - stmt.return_expression.static_type.takes_ownership && + stmt.return_expression.value_type.takes_ownership && !current_return_type.transfers_ownership) { Report.warning (stmt.source_reference, "Local variable with strong reference used as return value and method return type hasn't been declared to transfer ownership"); } @@ -1231,9 +1231,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!(stmt.expression.static_type is PointerType)) { + if (!(stmt.expression.value_type is PointerType)) { stmt.error = true; - Report.error (stmt.source_reference, "delete operator not supported for `%s'".printf (stmt.expression.static_type.to_string ())); + Report.error (stmt.source_reference, "delete operator not supported for `%s'".printf (stmt.expression.value_type.to_string ())); } } @@ -1307,10 +1307,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (size.size > 0) { /* check for errors in the size list */ foreach (Expression e in size) { - if (e.static_type == null) { + if (e.value_type == null) { /* return on previous error */ return; - } else if (!(e.static_type.data_type is Struct) || !((Struct) e.static_type.data_type).is_integer_type ()) { + } else if (!(e.value_type.data_type is Struct) || !((Struct) e.value_type.data_type).is_integer_type ()) { expr.error = true; Report.error (e.source_reference, "Expression of integer type expected"); } @@ -1332,7 +1332,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } /* check for wrong elements inside the initializer */ - if (expr.initializer_list != null && expr.initializer_list.static_type == null) { + if (expr.initializer_list != null && expr.initializer_list.value_type == null) { return; } @@ -1350,40 +1350,40 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.element_type.takes_ownership = true; } - expr.static_type = new ArrayType (expr.element_type, expr.rank, expr.source_reference); - expr.static_type.transfers_ownership = true; - expr.static_type.takes_ownership = true; + expr.value_type = new ArrayType (expr.element_type, expr.rank, expr.source_reference); + expr.value_type.transfers_ownership = true; + expr.value_type.takes_ownership = true; - expr.static_type.add_type_argument (expr.element_type); + expr.value_type.add_type_argument (expr.element_type); } public override void visit_boolean_literal (BooleanLiteral expr) { - expr.static_type = bool_type; + expr.value_type = bool_type; } public override void visit_character_literal (CharacterLiteral expr) { - expr.static_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("char")); + expr.value_type = new ValueType ((Typesymbol) root_symbol.scope.lookup ("char")); } public override void visit_integer_literal (IntegerLiteral expr) { var int_type = new IntegerType ((Typesymbol) root_symbol.scope.lookup (expr.get_type_name ())); int_type.literal = expr; - expr.static_type = int_type; + expr.value_type = int_type; } public override void visit_real_literal (RealLiteral expr) { - expr.static_type = new ValueType ((Typesymbol) root_symbol.scope.lookup (expr.get_type_name ())); + expr.value_type = new ValueType ((Typesymbol) root_symbol.scope.lookup (expr.get_type_name ())); } public override void visit_string_literal (StringLiteral expr) { - expr.static_type = string_type.copy (); + expr.value_type = string_type.copy (); } public override void visit_null_literal (NullLiteral expr) { - expr.static_type = new NullType (expr.source_reference); + expr.value_type = new NullType (expr.source_reference); } - private DataType? get_static_type_for_symbol (Symbol sym) { + private DataType? get_value_type_for_symbol (Symbol sym) { if (sym is Field) { var f = (Field) sym; return f.type_reference; @@ -1481,16 +1481,16 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (expr.inner.static_type == null) { + if (expr.inner.value_type == null) { // static type may be null for method references expr.error = true; Report.error (expr.inner.source_reference, "Invalid expression type"); return; } - expr.static_type = expr.inner.static_type.copy (); + expr.value_type = expr.inner.value_type.copy (); // don't call g_object_ref_sink on inner and outer expression - expr.static_type.floating_reference = false; + expr.value_type.floating_reference = false; } public override void visit_member_access (MemberAccess expr) { @@ -1570,14 +1570,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } } - if (expr.symbol_reference == null && expr.inner.static_type != null) { + if (expr.symbol_reference == null && expr.inner.value_type != null) { if (expr.pointer_member_access) { - expr.symbol_reference = expr.inner.static_type.get_pointer_member (expr.member_name); + expr.symbol_reference = expr.inner.value_type.get_pointer_member (expr.member_name); } else { - if (expr.inner.static_type.data_type != null) { - base_symbol = expr.inner.static_type.data_type; + if (expr.inner.value_type.data_type != null) { + base_symbol = expr.inner.value_type.data_type; } - expr.symbol_reference = expr.inner.static_type.get_member (expr.member_name); + expr.symbol_reference = expr.inner.value_type.get_member (expr.member_name); } if (expr.symbol_reference != null) { // inner expression is variable, field, or parameter @@ -1591,7 +1591,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.symbol_reference = base_symbol.scope.lookup (".new." + expr.member_name); } - if (expr.symbol_reference == null && expr.inner.static_type != null && expr.inner.static_type.is_dynamic) { + if (expr.symbol_reference == null && expr.inner.value_type != null && expr.inner.value_type.is_dynamic) { // allow late bound members for dynamic types if (expr.parent_node is InvocationExpression) { var invoc = (InvocationExpression) expr.parent_node; @@ -1602,7 +1602,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } else { ret_type = new VoidType (); } - var m = new DynamicMethod (expr.inner.static_type, expr.member_name, ret_type, expr.source_reference); + var m = new DynamicMethod (expr.inner.value_type, expr.member_name, ret_type, expr.source_reference); m.invocation = invoc; m.add_error_domain (new ErrorType (null)); m.access = SymbolAccessibility.PUBLIC; @@ -1614,7 +1614,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (a.left == expr && (a.operator == AssignmentOperator.ADD || a.operator == AssignmentOperator.SUB)) { - var s = new DynamicSignal (expr.inner.static_type, expr.member_name, new VoidType (), expr.source_reference); + var s = new DynamicSignal (expr.inner.value_type, expr.member_name, new VoidType (), expr.source_reference); s.handler = a.right; s.access = SymbolAccessibility.PUBLIC; context.add_dynamic_member (s); @@ -1631,8 +1631,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.error = true; string base_type_name = "(null)"; - if (expr.inner != null && expr.inner.static_type != null) { - base_type_name = expr.inner.static_type.to_string (); + if (expr.inner != null && expr.inner.value_type != null) { + base_type_name = expr.inner.value_type.to_string (); } else if (base_symbol != null) { base_type_name = base_symbol.get_full_name (); } @@ -1709,18 +1709,18 @@ public class Vala.SemanticAnalyzer : CodeVisitor { // also set static type for prototype access // required when using instance methods as delegates in constants // TODO replace by MethodPrototype - expr.static_type = get_static_type_for_symbol (expr.symbol_reference); + expr.value_type = get_value_type_for_symbol (expr.symbol_reference); } else if (expr.symbol_reference is Field) { - expr.static_type = new FieldPrototype ((Field) expr.symbol_reference); + expr.value_type = new FieldPrototype ((Field) expr.symbol_reference); } } else { - expr.static_type = get_static_type_for_symbol (expr.symbol_reference); + expr.value_type = get_value_type_for_symbol (expr.symbol_reference); // resolve generic return values - if (expr.static_type != null && expr.static_type.type_parameter != null) { + if (expr.value_type != null && expr.value_type.type_parameter != null) { if (expr.inner != null) { - expr.static_type = get_actual_type (expr.inner.static_type, expr.symbol_reference, expr.static_type, expr); - if (expr.static_type == null) { + expr.value_type = get_actual_type (expr.inner.value_type, expr.symbol_reference, expr.value_type, expr); + if (expr.value_type == null) { return; } } @@ -1748,7 +1748,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } } - var mtype = expr.call.static_type; + var mtype = expr.call.value_type; // check for struct construction if (expr.call is MemberAccess && @@ -1811,7 +1811,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var ma = expr.call as MemberAccess; if (ret_type.type_parameter != null) { if (ma != null && ma.inner != null) { - ret_type = get_actual_type (ma.inner.static_type, ma.symbol_reference, ret_type, expr); + ret_type = get_actual_type (ma.inner.value_type, ma.symbol_reference, ret_type, expr); if (ret_type == null) { return; } @@ -1820,7 +1820,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Gee.List resolved_type_args = new ArrayList (); foreach (DataType type_arg in ret_type.get_type_arguments ()) { if (type_arg.type_parameter != null && ma != null && ma.inner != null) { - resolved_type_args.add (get_actual_type (ma.inner.static_type, ma.symbol_reference, type_arg, expr)); + resolved_type_args.add (get_actual_type (ma.inner.value_type, ma.symbol_reference, type_arg, expr)); } else { resolved_type_args.add (type_arg); } @@ -1836,7 +1836,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { expr.tree_can_fail = expr.can_fail = (m.get_error_domains ().size > 0); } - expr.static_type = ret_type; + expr.value_type = ret_type; check_arguments (expr, mtype, params, expr.get_argument_list ()); } @@ -1870,22 +1870,22 @@ public class Vala.SemanticAnalyzer : CodeVisitor { // ignore inner error expr.error = true; return false; - } else if (arg.static_type == null) { + } else if (arg.value_type == null) { // disallow untyped arguments except for type inference of callbacks if (!(param.type_reference is DelegateType) || !(arg.symbol_reference is Method)) { expr.error = true; Report.error (arg.source_reference, "Invalid type for argument %d".printf (i + 1)); return false; } - } else if (!arg.static_type.compatible (param.type_reference) + } else if (!arg.value_type.compatible (param.type_reference) && !(arg is NullLiteral && param.direction == ParameterDirection.OUT)) { expr.error = true; - Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to `%s'".printf (i + 1, arg.static_type.to_string (), param.type_reference.to_string ())); + Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to `%s'".printf (i + 1, arg.value_type.to_string (), param.type_reference.to_string ())); return false; } else { // 0 => null, 1 => in, 2 => ref, 3 => out int arg_type = 1; - if (arg.static_type is NullType) { + if (arg.value_type is NullType) { arg_type = 0; } else if (arg is UnaryExpression) { var unary = (UnaryExpression) arg; @@ -1938,7 +1938,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { // ignore inner error expr.error = true; return false; - } else if (arg.static_type == null) { + } else if (arg.value_type == null) { // disallow untyped arguments except for type inference of callbacks if (!(arg.symbol_reference is Method)) { expr.error = true; @@ -2100,21 +2100,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_element_access (ElementAccess expr) { - if (expr.container.static_type == null) { + if (expr.container.value_type == null) { /* don't proceed if a child expression failed */ expr.error = true; return; } - var container_type = expr.container.static_type.data_type; + var container_type = expr.container.value_type.data_type; bool index_int_type_check = true; - var pointer_type = expr.container.static_type as PointerType; + var pointer_type = expr.container.value_type as PointerType; - /* assign a static_type when possible */ - if (expr.container.static_type is ArrayType) { - var args = expr.container.static_type.get_type_arguments (); + /* assign a value_type when possible */ + if (expr.container.value_type is ArrayType) { + var args = expr.container.value_type.get_type_arguments (); if (args.size != 1) { expr.error = true; @@ -2122,9 +2122,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - expr.static_type = args.get (0); + expr.value_type = args.get (0); } else if (pointer_type != null && !pointer_type.base_type.is_reference_type_or_type_parameter ()) { - expr.static_type = pointer_type.base_type.copy (); + expr.value_type = pointer_type.base_type.copy (); } else if (container_type == string_type.data_type) { if (expr.get_indices ().size != 1) { expr.error = true; @@ -2132,7 +2132,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - expr.static_type = unichar_type; + expr.value_type = unichar_type; } else if (container_type != null && list_type != null && map_type != null && (container_type.is_subtype_of (list_type) || container_type.is_subtype_of (map_type))) { Collection indices = expr.get_indices (); @@ -2161,32 +2161,32 @@ public class Vala.SemanticAnalyzer : CodeVisitor { var index_type = get_param.type_reference; if (index_type.type_parameter != null) { - index_type = get_actual_type (expr.container.static_type, get_method, get_param.type_reference, expr); + index_type = get_actual_type (expr.container.value_type, get_method, get_param.type_reference, expr); } - if (!index.static_type.compatible (index_type)) { + if (!index.value_type.compatible (index_type)) { expr.error = true; - Report.error (expr.source_reference, "index expression: Cannot convert from `%s' to `%s'".printf (index.static_type.to_string (), index_type.to_string ())); + Report.error (expr.source_reference, "index expression: Cannot convert from `%s' to `%s'".printf (index.value_type.to_string (), index_type.to_string ())); return; } - expr.static_type = get_actual_type (expr.container.static_type, get_method, get_method.return_type, expr).copy (); - expr.static_type.takes_ownership = false; + expr.value_type = get_actual_type (expr.container.value_type, get_method, get_method.return_type, expr).copy (); + expr.value_type.takes_ownership = false; } else { expr.error = true; - Report.error (expr.source_reference, "The expression `%s' does not denote an Array".printf (expr.container.static_type.to_string ())); + Report.error (expr.source_reference, "The expression `%s' does not denote an Array".printf (expr.container.value_type.to_string ())); } if (index_int_type_check) { /* check if the index is of type integer */ foreach (Expression e in expr.get_indices ()) { /* don't proceed if a child expression failed */ - if (e.static_type == null) { + if (e.value_type == null) { return; } /* check if the index is of type integer */ - if (!(e.static_type.data_type is Struct) || !((Struct) e.static_type.data_type).is_integer_type ()) { + if (!(e.value_type.data_type is Struct) || !((Struct) e.value_type.data_type).is_integer_type ()) { expr.error = true; Report.error (e.source_reference, "Expression of integer type expected"); } @@ -2235,20 +2235,20 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } Iterator base_type_it = current_struct.get_base_types ().iterator (); base_type_it.next (); - expr.static_type = base_type_it.get (); + expr.value_type = base_type_it.get (); } else if (current_class.base_class == null) { expr.error = true; Report.error (expr.source_reference, "Base access invalid without base class"); return; } else { - expr.static_type = new ClassInstanceType (current_class.base_class); + expr.value_type = new ClassInstanceType (current_class.base_class); } - expr.symbol_reference = expr.static_type.data_type; + expr.symbol_reference = expr.value_type.data_type; } public override void visit_postfix_expression (PostfixExpression expr) { - expr.static_type = expr.inner.static_type; + expr.value_type = expr.inner.value_type; } public override void visit_object_creation_expression (ObjectCreationExpression expr) { @@ -2319,8 +2319,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor { current_source_file.add_symbol_dependency (type, SourceFileDependencyType.SOURCE); - expr.static_type = expr.type_reference.copy (); - expr.static_type.transfers_ownership = true; + expr.value_type = expr.type_reference.copy (); + expr.value_type.transfers_ownership = true; int given_num_type_args = expr.type_reference.get_type_arguments ().size; int expected_num_type_args = 0; @@ -2337,14 +2337,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (cl.is_abstract) { - expr.static_type = null; + expr.value_type = null; expr.error = true; Report.error (expr.source_reference, "Can't create instance of abstract class `%s'".printf (cl.get_full_name ())); return; } if (cl.is_static) { - expr.static_type = null; + expr.value_type = null; expr.error = true; Report.error (expr.source_reference, "Can't create instance of static class `%s'".printf (cl.get_full_name ())); return; @@ -2356,7 +2356,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { while (cl != null) { if (cl == initially_unowned_type) { - expr.static_type.floating_reference = true; + expr.value_type.floating_reference = true; break; } @@ -2371,7 +2371,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.warning (expr.source_reference, "deprecated syntax, don't use `new' to initialize structs"); } - expr.static_type.transfers_ownership = false; + expr.value_type.transfers_ownership = false; if (expr.symbol_reference == null) { expr.symbol_reference = st.default_construction_method; @@ -2389,7 +2389,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } if (expr.symbol_reference == null && expr.get_argument_list ().size != 0) { - expr.static_type = null; + expr.value_type = null; expr.error = true; Report.error (expr.source_reference, "No arguments allowed when constructing type `%s'".printf (type.get_full_name ())); return; @@ -2430,12 +2430,12 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Iterator arg_it = expr.get_argument_list ().iterator (); arg_it.next (); var ex = arg_it.get (); - if (ex.static_type == null || !ex.static_type.compatible (string_type)) { + if (ex.value_type == null || !ex.value_type.compatible (string_type)) { expr.error = true; Report.error (expr.source_reference, "Invalid type for argument 1"); } } - expr.static_type = new VoidType (); + expr.value_type = new VoidType (); } foreach (MemberInitializer init in expr.get_object_initializer ()) { @@ -2470,7 +2470,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } } - if (init.initializer.static_type == null || !init.initializer.static_type.compatible (member_type)) { + if (init.initializer.value_type == null || !init.initializer.value_type.compatible (member_type)) { init.error = true; Report.error (init.source_reference, "Invalid type for member `%s'".printf (init.name)); return; @@ -2478,11 +2478,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } public override void visit_sizeof_expression (SizeofExpression expr) { - expr.static_type = ulong_type; + expr.value_type = ulong_type; } public override void visit_typeof_expression (TypeofExpression expr) { - expr.static_type = type_type; + expr.value_type = type_type; } private bool is_numeric_type (DataType type) { @@ -2512,37 +2512,37 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (expr.operator == UnaryOperator.PLUS || expr.operator == UnaryOperator.MINUS) { // integer or floating point type - if (!is_numeric_type (expr.inner.static_type)) { + if (!is_numeric_type (expr.inner.value_type)) { expr.error = true; - Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.static_type.to_string ())); + Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.value_type.to_string ())); return; } - expr.static_type = expr.inner.static_type; + expr.value_type = expr.inner.value_type; } else if (expr.operator == UnaryOperator.LOGICAL_NEGATION) { // boolean type - if (!expr.inner.static_type.compatible (bool_type)) { + if (!expr.inner.value_type.compatible (bool_type)) { expr.error = true; - Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.static_type.to_string ())); + Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.value_type.to_string ())); return; } - expr.static_type = expr.inner.static_type; + expr.value_type = expr.inner.value_type; } else if (expr.operator == UnaryOperator.BITWISE_COMPLEMENT) { // integer type - if (!is_integer_type (expr.inner.static_type)) { + if (!is_integer_type (expr.inner.value_type)) { expr.error = true; - Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.static_type.to_string ())); + Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.value_type.to_string ())); return; } - expr.static_type = expr.inner.static_type; + expr.value_type = expr.inner.value_type; } else if (expr.operator == UnaryOperator.INCREMENT || expr.operator == UnaryOperator.DECREMENT) { // integer type - if (!is_integer_type (expr.inner.static_type)) { + if (!is_integer_type (expr.inner.value_type)) { expr.error = true; - Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.static_type.to_string ())); + Report.error (expr.source_reference, "Operator not supported for `%s'".printf (expr.inner.value_type.to_string ())); return; } @@ -2564,7 +2564,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } else if (expr.operator == UnaryOperator.REF || expr.operator == UnaryOperator.OUT) { if (expr.inner.symbol_reference is Field || expr.inner.symbol_reference is FormalParameter || expr.inner.symbol_reference is LocalVariable) { // ref and out can only be used with fields, parameters, and local variables - expr.static_type = expr.inner.static_type; + expr.value_type = expr.inner.value_type; } else { expr.error = true; Report.error (expr.source_reference, "ref and out method arguments can only be used with fields, parameters, and local variables"); @@ -2600,27 +2600,27 @@ public class Vala.SemanticAnalyzer : CodeVisitor { current_source_file.add_type_dependency (expr.type_reference, SourceFileDependencyType.SOURCE); - expr.static_type = expr.type_reference; - expr.static_type.transfers_ownership = expr.inner.static_type.transfers_ownership; + expr.value_type = expr.type_reference; + expr.value_type.transfers_ownership = expr.inner.value_type.transfers_ownership; } public override void visit_pointer_indirection (PointerIndirection expr) { if (expr.inner.error) { return; } - if (expr.inner.static_type == null) { + if (expr.inner.value_type == null) { expr.error = true; Report.error (expr.source_reference, "internal error: unknown type of inner expression"); return; } - if (expr.inner.static_type is PointerType) { - var pointer_type = (PointerType) expr.inner.static_type; + if (expr.inner.value_type is PointerType) { + var pointer_type = (PointerType) expr.inner.value_type; if (pointer_type.base_type is ReferenceType) { expr.error = true; Report.error (expr.source_reference, "Pointer indirection not supported for this expression"); return; } - expr.static_type = pointer_type.base_type; + expr.value_type = pointer_type.base_type; } else { expr.error = true; Report.error (expr.source_reference, "Pointer indirection not supported for this expression"); @@ -2632,19 +2632,19 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (expr.inner.error) { return; } - if (!(expr.inner.static_type is ValueType - || expr.inner.static_type is ClassInstanceType - || expr.inner.static_type is InterfaceInstanceType - || expr.inner.static_type is PointerType)) { + if (!(expr.inner.value_type is ValueType + || expr.inner.value_type is ClassInstanceType + || expr.inner.value_type is InterfaceInstanceType + || expr.inner.value_type is PointerType)) { expr.error = true; Report.error (expr.source_reference, "Address-of operator not supported for this expression"); return; } - if (expr.inner.static_type.is_reference_type_or_type_parameter ()) { - expr.static_type = new PointerType (new PointerType (expr.inner.static_type)); + if (expr.inner.value_type.is_reference_type_or_type_parameter ()) { + expr.value_type = new PointerType (new PointerType (expr.inner.value_type)); } else { - expr.static_type = new PointerType (expr.inner.static_type); + expr.value_type = new PointerType (expr.inner.value_type); } } @@ -2661,16 +2661,16 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (!expr.inner.static_type.takes_ownership - && !(expr.inner.static_type is PointerType)) { + if (!expr.inner.value_type.takes_ownership + && !(expr.inner.value_type is PointerType)) { expr.error = true; Report.error (expr.source_reference, "No reference to be transferred"); return; } - expr.static_type = expr.inner.static_type.copy (); - expr.static_type.transfers_ownership = true; - expr.static_type.takes_ownership = false; + expr.value_type = expr.inner.value_type.copy (); + expr.value_type.transfers_ownership = true; + expr.value_type.takes_ownership = false; } private DataType? get_arithmetic_result_type (DataType left_type, DataType right_type) { @@ -2712,21 +2712,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (expr.left.static_type == null) { + if (expr.left.value_type == null) { Report.error (expr.left.source_reference, "invalid left operand"); expr.error = true; return; } - if (expr.operator != BinaryOperator.IN && expr.right.static_type == null) { + if (expr.operator != BinaryOperator.IN && expr.right.value_type == null) { Report.error (expr.right.source_reference, "invalid right operand"); expr.error = true; return; } - if (expr.left.static_type.data_type == string_type.data_type + if (expr.left.value_type.data_type == string_type.data_type && expr.operator == BinaryOperator.PLUS) { - if (expr.right.static_type == null || expr.right.static_type.data_type != string_type.data_type) { + if (expr.right.value_type == null || expr.right.value_type.data_type != string_type.data_type) { expr.error = true; Report.error (expr.source_reference, "Operands must be strings"); return; @@ -2745,94 +2745,94 @@ public class Vala.SemanticAnalyzer : CodeVisitor { || expr.operator == BinaryOperator.MUL || expr.operator == BinaryOperator.DIV) { // check for pointer arithmetic - if (expr.left.static_type is PointerType) { - var offset_type = expr.right.static_type.data_type as Struct; + if (expr.left.value_type is PointerType) { + var offset_type = expr.right.value_type.data_type as Struct; if (offset_type != null && offset_type.is_integer_type ()) { if (expr.operator == BinaryOperator.PLUS || expr.operator == BinaryOperator.MINUS) { // pointer arithmetic: pointer +/- offset - expr.static_type = expr.left.static_type.copy (); + expr.value_type = expr.left.value_type.copy (); } - } else if (expr.right.static_type is PointerType) { + } else if (expr.right.value_type is PointerType) { // pointer arithmetic: pointer - pointer - expr.static_type = size_t_type; + expr.value_type = size_t_type; } } - if (expr.static_type == null) { - expr.static_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type); + if (expr.value_type == null) { + expr.value_type = get_arithmetic_result_type (expr.left.value_type, expr.right.value_type); } - if (expr.static_type == null) { + if (expr.value_type == null) { expr.error = true; - Report.error (expr.source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf (expr.left.static_type.to_string (), expr.right.static_type.to_string ())); + Report.error (expr.source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf (expr.left.value_type.to_string (), expr.right.value_type.to_string ())); return; } } else if (expr.operator == BinaryOperator.MOD || expr.operator == BinaryOperator.SHIFT_LEFT || expr.operator == BinaryOperator.SHIFT_RIGHT || expr.operator == BinaryOperator.BITWISE_XOR) { - expr.static_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type); + expr.value_type = get_arithmetic_result_type (expr.left.value_type, expr.right.value_type); - if (expr.static_type == null) { + if (expr.value_type == null) { expr.error = true; - Report.error (expr.source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf (expr.left.static_type.to_string (), expr.right.static_type.to_string ())); + Report.error (expr.source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf (expr.left.value_type.to_string (), expr.right.value_type.to_string ())); return; } } else if (expr.operator == BinaryOperator.LESS_THAN || expr.operator == BinaryOperator.GREATER_THAN || expr.operator == BinaryOperator.LESS_THAN_OR_EQUAL || expr.operator == BinaryOperator.GREATER_THAN_OR_EQUAL) { - if (expr.left.static_type.compatible (string_type) - && expr.right.static_type.compatible (string_type)) { + if (expr.left.value_type.compatible (string_type) + && expr.right.value_type.compatible (string_type)) { // string comparison - } else if (expr.left.static_type is PointerType && expr.right.static_type is PointerType) { + } else if (expr.left.value_type is PointerType && expr.right.value_type is PointerType) { // pointer arithmetic } else { - var resulting_type = get_arithmetic_result_type (expr.left.static_type, expr.right.static_type); + var resulting_type = get_arithmetic_result_type (expr.left.value_type, expr.right.value_type); if (resulting_type == null) { expr.error = true; - Report.error (expr.source_reference, "Relational operation not supported for types `%s' and `%s'".printf (expr.left.static_type.to_string (), expr.right.static_type.to_string ())); + Report.error (expr.source_reference, "Relational operation not supported for types `%s' and `%s'".printf (expr.left.value_type.to_string (), expr.right.value_type.to_string ())); return; } } - expr.static_type = bool_type; + expr.value_type = bool_type; } else if (expr.operator == BinaryOperator.EQUALITY || expr.operator == BinaryOperator.INEQUALITY) { /* relational operation */ - if (!expr.right.static_type.compatible (expr.left.static_type) - && !expr.left.static_type.compatible (expr.right.static_type)) { - Report.error (expr.source_reference, "Equality operation: `%s' and `%s' are incompatible".printf (expr.right.static_type.to_string (), expr.left.static_type.to_string ())); + if (!expr.right.value_type.compatible (expr.left.value_type) + && !expr.left.value_type.compatible (expr.right.value_type)) { + Report.error (expr.source_reference, "Equality operation: `%s' and `%s' are incompatible".printf (expr.right.value_type.to_string (), expr.left.value_type.to_string ())); expr.error = true; return; } - if (expr.left.static_type.compatible (string_type) - && expr.right.static_type.compatible (string_type)) { + if (expr.left.value_type.compatible (string_type) + && expr.right.value_type.compatible (string_type)) { // string comparison } - expr.static_type = bool_type; + expr.value_type = bool_type; } else if (expr.operator == BinaryOperator.BITWISE_AND || expr.operator == BinaryOperator.BITWISE_OR) { // integer type or flags type - expr.static_type = expr.left.static_type; + expr.value_type = expr.left.value_type; } else if (expr.operator == BinaryOperator.AND || expr.operator == BinaryOperator.OR) { - if (!expr.left.static_type.compatible (bool_type) || !expr.right.static_type.compatible (bool_type)) { + if (!expr.left.value_type.compatible (bool_type) || !expr.right.value_type.compatible (bool_type)) { expr.error = true; Report.error (expr.source_reference, "Operands must be boolean"); } - expr.static_type = bool_type; + expr.value_type = bool_type; } else if (expr.operator == BinaryOperator.IN) { // integer type or flags type - expr.static_type = bool_type; + expr.value_type = bool_type; } else { assert_not_reached (); } @@ -2847,21 +2847,21 @@ public class Vala.SemanticAnalyzer : CodeVisitor { current_source_file.add_type_dependency (expr.type_reference, SourceFileDependencyType.SOURCE); - expr.static_type = bool_type; + expr.value_type = bool_type; } public override void visit_conditional_expression (ConditionalExpression expr) { - if (!expr.condition.static_type.compatible (bool_type)) { + if (!expr.condition.value_type.compatible (bool_type)) { expr.error = true; Report.error (expr.condition.source_reference, "Condition must be boolean"); return; } /* FIXME: support memory management */ - if (expr.false_expression.static_type.compatible (expr.true_expression.static_type)) { - expr.static_type = expr.true_expression.static_type.copy (); - } else if (expr.true_expression.static_type.compatible (expr.false_expression.static_type)) { - expr.static_type = expr.false_expression.static_type.copy (); + if (expr.false_expression.value_type.compatible (expr.true_expression.value_type)) { + expr.value_type = expr.true_expression.value_type.copy (); + } else if (expr.true_expression.value_type.compatible (expr.false_expression.value_type)) { + expr.value_type = expr.false_expression.value_type.copy (); } else { expr.error = true; Report.error (expr.condition.source_reference, "Incompatible expressions"); @@ -2979,7 +2979,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { if (a.left is MemberAccess) { var ma = (MemberAccess) a.left; - if (!(ma.symbol_reference is Signal) && ma.static_type == null) { + if (!(ma.symbol_reference is Signal) && ma.value_type == null) { a.error = true; Report.error (a.source_reference, "unsupported lvalue in assignment"); return; @@ -3003,7 +3003,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { a.right.expected_type = new DelegateType (deleg); } } else { - a.right.expected_type = ma.static_type; + a.right.expected_type = ma.value_type; } } else if (a.left is ElementAccess) { // do nothing @@ -3084,7 +3084,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.error (ma.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ())); return; } - } else if (ma.symbol_reference is LocalVariable && a.right.static_type == null) { + } else if (ma.symbol_reference is LocalVariable && a.right.value_type == null) { var local = (LocalVariable) ma.symbol_reference; if (a.right.symbol_reference is Method && @@ -3100,13 +3100,13 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - a.right.static_type = local.variable_type; + a.right.value_type = local.variable_type; } else { a.error = true; Report.error (a.source_reference, "Assignment: Invalid callback assignment attempt"); return; } - } else if (ma.symbol_reference is Field && a.right.static_type == null) { + } else if (ma.symbol_reference is Field && a.right.value_type == null) { var f = (Field) ma.symbol_reference; if (a.right.symbol_reference is Method && @@ -3122,30 +3122,30 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - a.right.static_type = f.type_reference; + a.right.value_type = f.type_reference; } else { a.error = true; Report.error (a.source_reference, "Assignment: Invalid callback assignment attempt"); return; } - } else if (a.left.static_type != null && a.right.static_type != null) { + } else if (a.left.value_type != null && a.right.value_type != null) { /* if there was an error on either side, - * i.e. a.{left|right}.static_type == null, skip type check */ + * i.e. a.{left|right}.value_type == null, skip type check */ - if (!a.right.static_type.compatible (a.left.static_type)) { + if (!a.right.value_type.compatible (a.left.value_type)) { a.error = true; - Report.error (a.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (a.right.static_type.to_string (), a.left.static_type.to_string ())); + Report.error (a.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (a.right.value_type.to_string (), a.left.value_type.to_string ())); return; } - if (a.right.static_type.transfers_ownership) { + if (a.right.value_type.transfers_ownership) { /* rhs transfers ownership of the expression */ - if (!(a.left.static_type is PointerType) && !a.left.static_type.takes_ownership) { + if (!(a.left.value_type is PointerType) && !a.left.value_type.takes_ownership) { /* lhs doesn't own the value */ a.error = true; Report.error (a.source_reference, "Invalid assignment from owned expression to unowned variable"); } - } else if (a.left.static_type.takes_ownership) { + } else if (a.left.value_type.takes_ownership) { /* lhs wants to own the value * rhs doesn't transfer the ownership * code generator needs to add reference @@ -3155,16 +3155,16 @@ public class Vala.SemanticAnalyzer : CodeVisitor { } else if (a.left is ElementAccess) { var ea = (ElementAccess) a.left; - if (!a.right.static_type.compatible (a.left.static_type)) { + if (!a.right.value_type.compatible (a.left.value_type)) { a.error = true; - Report.error (a.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (a.right.static_type.to_string (), a.left.static_type.to_string ())); + Report.error (a.source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf (a.right.value_type.to_string (), a.left.value_type.to_string ())); return; } - if (a.right.static_type.transfers_ownership) { + if (a.right.value_type.transfers_ownership) { /* rhs transfers ownership of the expression */ - var args = ea.container.static_type.get_type_arguments (); + var args = ea.container.value_type.get_type_arguments (); if (args.size != 1) { a.error = true; Report.error (ea.source_reference, "internal error: array reference with %d type arguments".printf (args.size)); @@ -3178,7 +3178,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor { Report.error (a.source_reference, "Invalid assignment from owned expression to unowned variable"); return; } - } else if (a.left.static_type.takes_ownership) { + } else if (a.left.value_type.takes_ownership) { /* lhs wants to own the value * rhs doesn't transfer the ownership * code generator needs to add reference @@ -3188,14 +3188,14 @@ public class Vala.SemanticAnalyzer : CodeVisitor { return; } - if (a.left.static_type != null) { - a.static_type = a.left.static_type.copy (); + if (a.left.value_type != null) { + a.value_type = a.left.value_type.copy (); if (a.parent_node is ExpressionStatement) { // Gee.List.get () transfers ownership but void function Gee.List.set () doesn't - a.static_type.transfers_ownership = false; + a.value_type.transfers_ownership = false; } } else { - a.static_type = null; + a.value_type = null; } a.tree_can_fail = a.left.tree_can_fail || a.right.tree_can_fail;