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)));
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;
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;
}
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 ();
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);
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);
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);
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);
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 ());
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);
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 () + "*");
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);
+ 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);
}
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));
// 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));
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
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;
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++) {
} 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;
}
}
} 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;
}
}
}
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) {
* 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;
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
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,
}
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
*/
}
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));
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 ()) {
// (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)));
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));
// 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);
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);
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)) {
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
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);
}
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));
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;
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;
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;
}
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");
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");
}
}
- 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 */
bool error = false;
foreach (Expression e in list.get_initializers ()) {
- if (e.static_type == null) {
+ if (e.value_type == null) {
error = true;
continue;
}
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;
}
}
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;
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;
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;
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;
// 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);
}
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");
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");
}
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 ()));
}
}
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");
}
}
/* 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;
}
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;
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) {
}
}
- 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
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;
} 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;
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);
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 ();
}
// 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;
}
}
}
}
- var mtype = expr.call.static_type;
+ var mtype = expr.call.value_type;
// check for struct construction
if (expr.call is MemberAccess &&
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;
}
Gee.List<DataType> resolved_type_args = new ArrayList<DataType> ();
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);
}
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 ());
}
// 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;
// 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;
}
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;
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;
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<Expression> indices = expr.get_indices ();
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");
}
}
Iterator<DataType> 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) {
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;
}
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;
while (cl != null) {
if (cl == initially_unowned_type) {
- expr.static_type.floating_reference = true;
+ expr.value_type.floating_reference = true;
break;
}
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;
}
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;
Iterator<Expression> 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 ()) {
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;
}
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) {
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;
}
} 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");
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");
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);
}
}
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) {
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;
|| 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 ();
}
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");
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;
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
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 &&
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 &&
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
} 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));
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
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;