Commit 5ea6dc05 authored by Jürg Billeter's avatar Jürg Billeter

Drop Dova profile

parent 6a6a2cf5
......@@ -28,18 +28,6 @@ libvala_la_VALASOURCES = \
valaccodestructmodule.vala \
valaclassregisterfunction.vala \
valactype.vala \
valadovaarraymodule.vala \
valadovaassignmentmodule.vala \
valadovabasemodule.vala \
valadovacontrolflowmodule.vala \
valadovadelegatemodule.vala \
valadovaerrormodule.vala \
valadovamemberaccessmodule.vala \
valadovamethodcallmodule.vala \
valadovamethodmodule.vala \
valadovaobjectmodule.vala \
valadovastructmodule.vala \
valadovavaluemodule.vala \
valaenumregisterfunction.vala \
valagasyncmodule.vala \
valagdbusclientmodule.vala \
......
......@@ -584,11 +584,6 @@ public class Vala.CCodeAttribute : AttributeCache {
}
} else if (node is ObjectType) {
var type = (ObjectType) node;
if (CodeContext.get ().profile == Profile.DOVA) {
if (type.type_symbol.get_full_name () == "string") {
return "string_t";
}
}
string cname;
if (!type.value_owned) {
......@@ -603,19 +598,11 @@ public class Vala.CCodeAttribute : AttributeCache {
if (type.inline_allocated) {
return cname;
} else {
if (CodeContext.get ().profile == Profile.DOVA) {
return "DovaArray";
} else {
return "%s*".printf (cname);
}
return "%s*".printf (cname);
}
} else if (node is DelegateType) {
var type = (DelegateType) node;
if (CodeContext.get ().profile == Profile.DOVA) {
return "%s*".printf (CCodeBaseModule.get_ccode_name (type.delegate_symbol));
} else {
return CCodeBaseModule.get_ccode_name (type.delegate_symbol);
}
return CCodeBaseModule.get_ccode_name (type.delegate_symbol);
} else if (node is ErrorType) {
return "GError*";
} else if (node is GenericType) {
......@@ -1147,14 +1134,6 @@ public class Vala.CCodeAttribute : AttributeCache {
if (base_st != null) {
return CCodeBaseModule.get_ccode_default_value (base_st);
}
if (CodeContext.get ().profile == Profile.DOVA) {
if (st.is_boolean_type ()) {
return "false";
} else if (st.is_integer_type () || st.is_floating_type ()) {
return "0";
}
}
}
return "";
}
......@@ -1178,10 +1157,6 @@ public class Vala.CCodeAttribute : AttributeCache {
string infix = "construct";
if (CodeContext.get ().profile == Profile.DOVA) {
infix = "init";
}
if (m.name == ".new") {
return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (parent), infix);
} else {
......
/* valadovaarraymodule.vala
*
* Copyright (C) 2006-2011 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
public class Vala.DovaArrayModule : DovaMethodCallModule {
void append_initializer_list (CCodeExpression name_cnode, InitializerList initializer_list, ref int i) {
foreach (Expression e in initializer_list.get_initializers ()) {
ccode.add_assignment (new CCodeElementAccess (name_cnode, new CCodeConstant (i.to_string ())), get_cvalue (e));
i++;
}
}
public override void visit_array_creation_expression (ArrayCreationExpression expr) {
var array_type = expr.target_type as ArrayType;
if (array_type != null && array_type.fixed_length) {
// no heap allocation for fixed-length arrays
var temp_var = get_temp_variable (array_type, true, expr);
var name_cnode = new CCodeIdentifier (temp_var.name);
int i = 0;
emit_temp_var (temp_var);
append_initializer_list (name_cnode, expr.initializer_list, ref i);
set_cvalue (expr, name_cnode);
return;
}
generate_method_declaration ((Method) array_struct.scope.lookup ("create"), cfile);
var array_new = new CCodeFunctionCall (new CCodeIdentifier ("dova_array_create"));
array_new.add_argument (get_type_id_expression (expr.element_type));
// length of new array
array_new.add_argument (get_cvalue (expr.get_sizes ().get (0)));
var temp_var = get_temp_variable (expr.value_type, true, expr);
var name_cnode = get_variable_cexpression (temp_var.name);
emit_temp_var (temp_var);
ccode.add_assignment (name_cnode, array_new);
set_cvalue (expr, name_cnode);
}
public override void visit_element_access (ElementAccess expr) {
List<Expression> indices = expr.get_indices ();
var ccontainer = get_cvalue (expr.container);
var cindex = get_cvalue (indices[0]);
// access to element in an array
set_cvalue (expr, new CCodeElementAccess (ccontainer, cindex));
}
public override void visit_slice_expression (SliceExpression expr) {
var ccontainer = get_cvalue (expr.container);
var cstart = get_cvalue (expr.start);
var cstop = get_cvalue (expr.stop);
var array_type = (ArrayType) expr.container.value_type;
var array = new CCodeFunctionCall (new CCodeIdentifier ("dova_array"));
array.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeCastExpression (new CCodeMemberAccess (ccontainer, "data"), get_ccode_name (array_type.element_type) + "*"), cstart));
array.add_argument (new CCodeBinaryExpression (CCodeBinaryOperator.MINUS, cstop, cstart));
set_cvalue (expr, array);
}
}
/* valadovaassignmentmodule.vala
*
* Copyright (C) 2006-2011 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
/**
* The link between an assignment and generated code.
*/
public class Vala.DovaAssignmentModule : DovaMemberAccessModule {
CCodeExpression? emit_simple_assignment (Assignment assignment) {
CCodeExpression rhs = get_cvalue (assignment.right);
CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
bool unref_old = requires_destroy (assignment.left.value_type);
if (unref_old) {
if (!is_pure_ccode_expression (lhs)) {
/* Assign lhs to temp var to avoid repeating side effect */
var lhs_value_type = assignment.left.value_type.copy ();
string lhs_temp_name = "_tmp%d_".printf (next_temp_var_id++);
var lhs_temp = new LocalVariable (lhs_value_type, "*" + lhs_temp_name);
emit_temp_var (lhs_temp);
ccode.add_assignment (get_variable_cexpression (lhs_temp_name), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, lhs));
lhs = new CCodeParenthesizedExpression (new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, get_variable_cexpression (lhs_temp_name)));
}
var temp_decl = get_temp_variable (assignment.left.value_type);
emit_temp_var (temp_decl);
ccode.add_assignment (get_variable_cexpression (temp_decl.name), rhs);
if (unref_old) {
/* unref old value */
ccode.add_expression (get_unref_expression (lhs, assignment.left.value_type, assignment.left));
}
rhs = get_variable_cexpression (temp_decl.name);
}
var cop = CCodeAssignmentOperator.SIMPLE;
if (assignment.operator == AssignmentOperator.BITWISE_OR) {
cop = CCodeAssignmentOperator.BITWISE_OR;
} else if (assignment.operator == AssignmentOperator.BITWISE_AND) {
cop = CCodeAssignmentOperator.BITWISE_AND;
} else if (assignment.operator == AssignmentOperator.BITWISE_XOR) {
cop = CCodeAssignmentOperator.BITWISE_XOR;
} else if (assignment.operator == AssignmentOperator.ADD) {
cop = CCodeAssignmentOperator.ADD;
} else if (assignment.operator == AssignmentOperator.SUB) {
cop = CCodeAssignmentOperator.SUB;
} else if (assignment.operator == AssignmentOperator.MUL) {
cop = CCodeAssignmentOperator.MUL;
} else if (assignment.operator == AssignmentOperator.DIV) {
cop = CCodeAssignmentOperator.DIV;
} else if (assignment.operator == AssignmentOperator.PERCENT) {
cop = CCodeAssignmentOperator.PERCENT;
} else if (assignment.operator == AssignmentOperator.SHIFT_LEFT) {
cop = CCodeAssignmentOperator.SHIFT_LEFT;
} else if (assignment.operator == AssignmentOperator.SHIFT_RIGHT) {
cop = CCodeAssignmentOperator.SHIFT_RIGHT;
}
CCodeExpression codenode = new CCodeAssignment (lhs, rhs, cop);
ccode.add_expression (codenode);
if (assignment.parent_node is ExpressionStatement) {
return null;
} else {
return lhs;
}
}
CCodeExpression? emit_fixed_length_array_assignment (Assignment assignment, ArrayType array_type) {
CCodeExpression rhs = get_cvalue (assignment.right);
CCodeExpression lhs = (CCodeExpression) get_ccodenode (assignment.left);
// it is necessary to use memcpy for fixed-length (stack-allocated) arrays
// simple assignments do not work in C
var sizeof_call = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
sizeof_call.add_argument (new CCodeIdentifier (get_ccode_name (array_type.element_type)));
var size = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeConstant ("%d".printf (array_type.length)), sizeof_call);
var ccopy = new CCodeFunctionCall (new CCodeIdentifier ("memcpy"));
ccopy.add_argument (lhs);
ccopy.add_argument (rhs);
ccopy.add_argument (size);
ccode.add_expression (ccopy);
if (assignment.parent_node is ExpressionStatement) {
return null;
} else {
return lhs;
}
}
public override void visit_assignment (Assignment assignment) {
if (assignment.left.error || assignment.right.error) {
assignment.error = true;
return;
}
if (assignment.left.symbol_reference is Property) {
var ma = assignment.left as MemberAccess;
var prop = (Property) assignment.left.symbol_reference;
store_property (prop, ma.inner, assignment.right.target_value);
set_cvalue (assignment, get_ccodenode (assignment.right));
} else {
var array_type = assignment.left.value_type as ArrayType;
if (array_type != null && array_type.fixed_length) {
set_cvalue (assignment, emit_fixed_length_array_assignment (assignment, array_type));
} else {
set_cvalue (assignment, emit_simple_assignment (assignment));
}
}
}
public virtual void store_variable (Variable variable, TargetValue lvalue, TargetValue value, bool initializer) {
if (!initializer && requires_destroy (variable.variable_type)) {
/* unref old value */
ccode.add_expression (destroy_value (lvalue));
}
ccode.add_assignment (get_cvalue_ (lvalue), get_cvalue_ (value));
}
public override void store_local (LocalVariable local, TargetValue value, bool initializer) {
store_variable (local, get_local_cvalue (local), value, initializer);
}
public override void store_parameter (Parameter param, TargetValue value) {
store_variable (param, get_parameter_cvalue (param), value, false);
}
public override void store_field (Field field, TargetValue? instance, TargetValue value) {
store_variable (field, get_field_cvalue (field, instance), value, false);
}
}
This diff is collapsed.
/* valadovacontrolflowmodule.vala
*
* Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
public abstract class Vala.DovaControlFlowModule : DovaMethodModule {
public override void visit_if_statement (IfStatement stmt) {
ccode.open_if (get_cvalue (stmt.condition));
stmt.true_statement.emit (this);
if (stmt.false_statement != null) {
ccode.add_else ();
stmt.false_statement.emit (this);
}
ccode.close ();
}
public override void visit_switch_statement (SwitchStatement stmt) {
ccode.open_switch (get_cvalue (stmt.expression));
foreach (SwitchSection section in stmt.get_sections ()) {
if (section.has_default_label ()) {
ccode.add_default ();
}
section.emit (this);
}
ccode.close ();
}
public override void visit_switch_label (SwitchLabel label) {
if (label.expression != null) {
label.expression.emit (this);
visit_end_full_expression (label.expression);
ccode.add_case (get_cvalue (label.expression));
}
}
public override void visit_loop (Loop stmt) {
ccode.open_while (new CCodeConstant ("true"));
stmt.body.emit (this);
ccode.close ();
}
public override void visit_break_statement (BreakStatement stmt) {
append_local_free (current_symbol, true);
ccode.add_break ();
}
public override void visit_continue_statement (ContinueStatement stmt) {
append_local_free (current_symbol, true);
ccode.add_continue ();
}
}
/* valadovadelegatemodule.vala
*
* Copyright (C) 2006-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
* Raffaele Sandrini <raffaele@sandrini.ch>
*/
/**
* The link between a delegate and generated code.
*/
public class Vala.DovaDelegateModule : DovaValueModule {
public override void generate_delegate_declaration (Delegate d, CCodeFile decl_space) {
if (add_symbol_declaration (decl_space, d, get_ccode_name (d))) {
return;
}
decl_space.add_type_declaration (new CCodeTypeDefinition ("struct _%s".printf (get_ccode_name (d)), new CCodeVariableDeclarator (get_ccode_name (d))));
generate_class_declaration (type_class, decl_space);
generate_method_declaration ((Method) object_class.scope.lookup ("ref"), decl_space);
generate_method_declaration ((Method) object_class.scope.lookup ("unref"), decl_space);
var type_fun = new CCodeFunction ("%s_type_get".printf (get_ccode_lower_case_name (d)), "DovaType *");
if (d.is_internal_symbol ()) {
type_fun.modifiers = CCodeModifiers.STATIC;
}
decl_space.add_function_declaration (type_fun);
var type_init_fun = new CCodeFunction ("%s_type_init".printf (get_ccode_lower_case_name (d)));
if (d.is_internal_symbol ()) {
type_init_fun.modifiers = CCodeModifiers.STATIC;
}
type_init_fun.add_parameter (new CCodeParameter ("type", "DovaType *"));
decl_space.add_function_declaration (type_init_fun);
generate_type_declaration (d.return_type, decl_space);
var function = generate_new_function (d, decl_space);
function.block = null;
decl_space.add_function_declaration (function);
function = generate_invoke_function (d, decl_space);
function.block = null;
decl_space.add_function_declaration (function);
}
CCodeFunction generate_new_function (Delegate d, CCodeFile decl_space) {
var function = new CCodeFunction ("%s_new".printf (get_ccode_lower_case_name (d)), "%s*".printf (get_ccode_name (d)));
if (d.is_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
}
function.add_parameter (new CCodeParameter ("target", "DovaObject *"));
function.add_parameter (new CCodeParameter ("(*method) (void)", "void"));
function.block = new CCodeBlock ();
var alloc_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_object_alloc"));
alloc_call.add_argument (new CCodeFunctionCall (new CCodeIdentifier ("%s_type_get".printf (get_ccode_lower_case_name (d)))));
var cdecl = new CCodeDeclaration ("%s*".printf (get_ccode_name (d)));
cdecl.add_declarator (new CCodeVariableDeclarator ("this", alloc_call));
function.block.add_statement (cdecl);
var init_call = new CCodeFunctionCall (new CCodeIdentifier ("dova_delegate_init"));
init_call.add_argument (new CCodeIdentifier ("this"));
init_call.add_argument (new CCodeIdentifier ("target"));
function.block.add_statement (new CCodeExpressionStatement (init_call));
var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (d))));
priv.add_argument (new CCodeIdentifier ("this"));
var assignment = new CCodeAssignment (new CCodeMemberAccess.pointer (priv, "method"), new CCodeIdentifier ("method"));
function.block.add_statement (new CCodeExpressionStatement (assignment));
function.block.add_statement (new CCodeReturnStatement (new CCodeIdentifier ("this")));
return function;
}
CCodeFunction generate_invoke_function (Delegate d, CCodeFile decl_space) {
var function = new CCodeFunction ("%s_invoke".printf (get_ccode_lower_case_name (d)));
if (d.is_internal_symbol ()) {
function.modifiers |= CCodeModifiers.STATIC;
}
function.add_parameter (new CCodeParameter ("this", "%s*".printf (get_ccode_name (d))));
string param_list = "";
foreach (Parameter param in d.get_parameters ()) {
generate_type_declaration (param.variable_type, decl_space);
function.add_parameter (new CCodeParameter (param.name, get_ccode_name (param.variable_type)));
if (param_list != "") {
param_list += ", ";
}
param_list += get_ccode_name (param.variable_type);
}
if (d.return_type is GenericType) {
function.add_parameter (new CCodeParameter ("result", "void *"));
if (param_list != "") {
param_list += ", ";
}
param_list += "void *";
} else {
function.return_type = get_ccode_name (d.return_type);
}
function.block = new CCodeBlock ();
var get_target = new CCodeFunctionCall (new CCodeIdentifier ("dova_delegate_get_target"));
get_target.add_argument (new CCodeIdentifier ("this"));
var cdecl = new CCodeDeclaration ("DovaObject*");
cdecl.add_declarator (new CCodeVariableDeclarator ("target", get_target));
function.block.add_statement (cdecl);
var priv = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_PRIVATE".printf (get_ccode_upper_case_name (d))));
priv.add_argument (new CCodeIdentifier ("this"));
string instance_param_list = "(DovaObject *";
if (param_list != "") {
instance_param_list += ",";
instance_param_list += param_list;
}
instance_param_list += ")";
var instance_block = new CCodeBlock ();
var instance_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (function.return_type, instance_param_list)));
instance_call.add_argument (new CCodeIdentifier ("target"));
string static_param_list = "(";
if (param_list != "") {
static_param_list += param_list;
} else {
static_param_list += "void";
}
static_param_list += ")";
var static_block = new CCodeBlock ();
var static_call = new CCodeFunctionCall (new CCodeCastExpression (new CCodeMemberAccess.pointer (priv, "method"), "%s (*) %s".printf (function.return_type, static_param_list)));
foreach (Parameter param in d.get_parameters ()) {
instance_call.add_argument (new CCodeIdentifier (param.name));
static_call.add_argument (new CCodeIdentifier (param.name));
}
if (d.return_type is VoidType) {
instance_block.add_statement (new CCodeExpressionStatement (instance_call));
static_block.add_statement (new CCodeExpressionStatement (static_call));
} else if (d.return_type is GenericType) {
instance_call.add_argument (new CCodeIdentifier ("result"));
static_call.add_argument (new CCodeIdentifier ("result"));
instance_block.add_statement (new CCodeExpressionStatement (instance_call));
static_block.add_statement (new CCodeExpressionStatement (static_call));
} else {
instance_block.add_statement (new CCodeReturnStatement (instance_call));
static_block.add_statement (new CCodeReturnStatement (static_call));
}
function.block.add_statement (new CCodeIfStatement (new CCodeIdentifier ("target"), instance_block, static_block));
return function;
}
public override void visit_delegate (Delegate d) {
d.accept_children (this);
generate_delegate_declaration (d, cfile);
if (!d.is_internal_symbol ()) {
generate_delegate_declaration (d, header_file);
}
generate_type_get_function (d, delegate_class);
var instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (get_ccode_name (d)));
instance_priv_struct.add_field ("void", "(*method) (void)");
cfile.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (instance_priv_struct.name), new CCodeVariableDeclarator ("%sPrivate".printf (get_ccode_name (d)))));
cfile.add_type_definition (instance_priv_struct);
string macro = "((%sPrivate *) (((char *) o) + _%s_object_offset))".printf (get_ccode_name (d), get_ccode_lower_case_name (d));
cfile.add_type_member_declaration (new CCodeMacroReplacement ("%s_GET_PRIVATE(o)".printf (get_ccode_upper_case_name (d, null)), macro));
var cdecl = new CCodeDeclaration ("intptr_t");
cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_object_offset".printf (get_ccode_lower_case_name (d)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
cdecl = new CCodeDeclaration ("intptr_t");
cdecl.add_declarator (new CCodeVariableDeclarator ("_%s_type_offset".printf (get_ccode_lower_case_name (d)), new CCodeConstant ("0")));
cdecl.modifiers = CCodeModifiers.STATIC;
cfile.add_type_member_declaration (cdecl);
cfile.add_function (generate_new_function (d, cfile));
cfile.add_function (generate_invoke_function (d, cfile));
}
}
/* valadovaerrormodule.vala
*
* Copyright (C) 2008-2010 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
* Thijs Vermeir <thijsvermeir@gmail.com>
*/
public class Vala.DovaErrorModule : DovaDelegateModule {
private int current_try_id = 0;
private int next_try_id = 0;
private bool is_in_catch = false;
public override void visit_throw_statement (ThrowStatement stmt) {
ccode.add_assignment (new CCodeIdentifier ("dova_error"), get_cvalue (stmt.error_expression));
add_simple_check (stmt, true);
}
public void return_with_exception () {
// propagate error
// nothing to do
// free local variables
append_local_free (current_symbol, false);
if (current_method is CreationMethod && current_method.parent_symbol is Class) {
var cl = current_method.parent_symbol as Class;
var unref_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_unref_function (cl)));
unref_call.add_argument (new CCodeIdentifier ("this"));
ccode.add_expression (unref_call);
ccode.add_return ();
} else if (current_return_type is VoidType) {
ccode.add_return ();
} else {
ccode.add_return (default_value_for_type (current_return_type, false));
}
}
void uncaught_error_statement () {
// free local variables
append_local_free (current_symbol, false);
// TODO log uncaught error as critical warning
if (current_method is CreationMethod) {
ccode.add_return ();
} else if (current_return_type is VoidType) {
ccode.add_return ();
} else if (current_return_type != null) {