header_declarations = new CCodeDeclarationSpace ();
-
source_declarations = new CCodeDeclarationSpace ();
module_init_fragment = new CCodeFragment ();
source_type_member_definition = new CCodeFragment ();
+ if (context.nostdpkg) {
+ header_declarations.add_include ("dova-types.h");
+ source_declarations.add_include ("dova-types.h");
+ } else {
+ header_declarations.add_include ("dova-base.h");
+ source_declarations.add_include ("dova-base.h");
+ }
+
next_temp_var_id = 0;
variable_name_map.clear ();
var pointer_type = (PointerType) type;
return get_dup_func_expression (pointer_type.base_type, source_reference);
} else {
- source_declarations.add_include ("stddef.h");
return new CCodeConstant ("NULL");
}
}
}
}
if (unref_function == null) {
- source_declarations.add_include ("stddef.h");
return new CCodeConstant ("NULL");
}
return new CCodeIdentifier (unref_function);
} else if (type is PointerType) {
return new CCodeIdentifier ("free");
} else {
- source_declarations.add_include ("stddef.h");
return new CCodeConstant ("NULL");
}
}
* if foo is of static type non-null
*/
- source_declarations.add_include ("stddef.h");
-
var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new CCodeConstant ("NULL"));
if (type.type_parameter != null) {
if (!(current_type_symbol is Class) || current_class.is_compact) {
var alloca_call = new CCodeFunctionCall (new CCodeIdentifier ("alloca"));
alloca_call.add_argument (value_size);
- // memset needs string.h
- source_declarations.add_include ("string.h");
var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
memset_call.add_argument (alloca_call);
memset_call.add_argument (new CCodeConstant ("0"));
vardecl.init0 = true;
} else if (local.variable_type.is_reference_type_or_type_parameter () ||
local.variable_type.nullable) {
- source_declarations.add_include ("stddef.h");
vardecl.initializer = new CCodeConstant ("NULL");
vardecl.init0 = true;
}
}
public override void visit_boolean_literal (BooleanLiteral expr) {
- source_declarations.add_include ("stdbool.h");
expr.ccodenode = new CCodeConstant (expr.value ? "true" : "false");
}
}
public override void visit_null_literal (NullLiteral expr) {
- source_declarations.add_include ("stddef.h");
expr.ccodenode = new CCodeConstant ("NULL");
}
var ctemp = get_variable_cexpression (decl.name);
- source_declarations.add_include ("stddef.h");
var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, ctemp, new CCodeConstant ("NULL"));
if (expression_type.type_parameter != null) {
// dup functions are optional for type parameters
if (expr.symbol_reference == null) {
// no creation method
if (expr.type_reference.data_type is Struct) {
- // memset needs string.h
- source_declarations.add_include ("string.h");
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
creation_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance));
creation_call.add_argument (new CCodeConstant ("0"));
}
public CCodeExpression? default_value_for_type (DataType type, bool initializer_expression) {
- source_declarations.add_include ("stddef.h");
-
var st = type.data_type as Struct;
var array_type = type as ArrayType;
if (type is GenericType) {
var alloca_call = new CCodeFunctionCall (new CCodeIdentifier ("alloca"));
alloca_call.add_argument (value_size);
- // memset needs string.h
- source_declarations.add_include ("string.h");
var memset_call = new CCodeFunctionCall (new CCodeIdentifier ("memset"));
memset_call.add_argument (alloca_call);
memset_call.add_argument (new CCodeConstant ("0"));
instance_struct.add_field ("DovaType *", "type");
decl_space.add_type_definition (instance_struct);
} else if (cl == type_class) {
- decl_space.add_include ("stdbool.h");
-
var value_copy_function = new CCodeFunction ("dova_type_value_copy");
value_copy_function.add_parameter (new CCodeFormalParameter ("type", "DovaType *"));
value_copy_function.add_parameter (new CCodeFormalParameter ("dest", "void *"));
}
public CCodeBlock generate_type_get_function (TypeSymbol cl, Class? base_class) {
- source_declarations.add_include ("stddef.h");
- // calloc
- source_declarations.add_include ("stdlib.h");
-
DataType? base_class_type = null;
if (base_class != null && cl is Class) {
foreach (DataType base_type in ((Class) cl).get_base_types ()) {
source_declarations.add_type_declaration (new CCodeTypeDefinition ("struct %s".printf (type_priv_struct.name), new CCodeVariableDeclarator ("%sTypePrivate".printf (iface.get_cname ()))));
source_declarations.add_type_definition (type_priv_struct);
- source_declarations.add_include ("stddef.h");
- // calloc
- source_declarations.add_include ("stdlib.h");
-
var cdecl = new CCodeDeclaration ("DovaType *");
cdecl.add_declarator (new CCodeVariableDeclarator ("%s_type".printf (iface.get_lower_case_cname ()), new CCodeConstant ("NULL")));
cdecl.modifiers = CCodeModifiers.STATIC;
cdecl.add_declarator (new CCodeVariableDeclarator ("this"));
vblock.add_statement (cdecl);
- source_declarations.add_include ("stddef.h");
-
var type_get = new CCodeFunctionCall (new CCodeIdentifier (current_class.get_lower_case_cname () + "_type_get"));
foreach (var type_param in current_class.get_type_parameters ()) {
type_get.add_argument (new CCodeIdentifier ("%s_type".printf (type_param.name.down ())));