Commit ca020bf0 authored by Jürg Billeter's avatar Jürg Billeter

Drop POSIX profile

parent 5ea6dc05
......@@ -56,14 +56,8 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
return;
}
CCodeFunctionCall gnew;
if (context.profile == Profile.POSIX) {
cfile.add_include ("stdlib.h");
gnew = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
} else {
gnew = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
var gnew = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
gnew.add_argument (new CCodeIdentifier (get_ccode_name (expr.element_type)));
}
bool first = true;
CCodeExpression cexpr = null;
......@@ -88,12 +82,6 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
gnew.add_argument (cexpr);
if (context.profile == Profile.POSIX) {
var csizeof = new CCodeFunctionCall (new CCodeIdentifier ("sizeof"));
csizeof.add_argument (new CCodeIdentifier (get_ccode_name (expr.element_type)));
gnew.add_argument (csizeof);
}
var temp_var = get_temp_variable (expr.value_type, true, expr);
var name_cnode = get_variable_cexpression (temp_var.name);
int i = 0;
......
......@@ -606,24 +606,16 @@ public class Vala.CCodeAttribute : AttributeCache {
} else if (node is ErrorType) {
return "GError*";
} else if (node is GenericType) {
if (CodeContext.get ().profile == Profile.GOBJECT) {
var type = (GenericType) node;
if (type.value_owned) {
return "gpointer";
} else {
return "gconstpointer";
}
} else {
return "void *";
}
} else if (node is MethodType) {
return "gpointer";
} else if (node is NullType) {
if (CodeContext.get ().profile == Profile.GOBJECT) {
return "gpointer";
} else {
return "void *";
}
} else if (node is PointerType) {
var type = (PointerType) node;
if (type.base_type.data_type != null && type.base_type.data_type.is_reference_type ()) {
......
......@@ -440,7 +440,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
unichar_type = new IntegerType (unichar_struct);
}
if (context.profile == Profile.GOBJECT) {
var glib_ns = root_symbol.scope.lookup ("GLib");
gtype_type = (TypeSymbol) glib_ns.scope.lookup ("Type");
......@@ -488,7 +487,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
dbus_proxy_type = (TypeSymbol) glib_ns.scope.lookup ("DBusProxy");
}
header_file = new CCodeFile ();
header_file.is_header = true;
......@@ -522,12 +520,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// generate C header file for public API
if (context.header_filename != null) {
bool ret;
if (context.profile == Profile.GOBJECT) {
ret = header_file.store (context.header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
} else {
ret = header_file.store (context.header_filename, null, context.version_header, false);
}
bool ret = header_file.store (context.header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
if (!ret) {
Report.error (null, "unable to open `%s' for writing".printf (context.header_filename));
}
......@@ -535,12 +528,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// generate C header file for internal API
if (context.internal_header_filename != null) {
bool ret;
if (context.profile == Profile.GOBJECT) {
ret = internal_header_file.store (context.internal_header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
} else {
ret = internal_header_file.store (context.internal_header_filename, null, context.version_header, false);
}
bool ret = internal_header_file.store (context.internal_header_filename, null, context.version_header, false, "G_BEGIN_DECLS", "G_END_DECLS");
if (!ret) {
Report.error (null, "unable to open `%s' for writing".printf (context.internal_header_filename));
}
......@@ -722,12 +710,10 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
wrappers = new HashSet<string> (str_hash, str_equal);
generated_external_symbols = new HashSet<Symbol> ();
if (context.profile == Profile.GOBJECT) {
header_file.add_include ("glib.h");
internal_header_file.add_include ("glib.h");
cfile.add_include ("glib.h");
cfile.add_include ("glib-object.h");
}
source_file.accept_children (this);
......@@ -3004,7 +2990,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public CCodeExpression? get_destroy_func_expression (DataType type, bool is_chainup = false) {
if (context.profile == Profile.GOBJECT && (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type || type.data_type == gqueue_type)) {
if (type.data_type == glist_type || type.data_type == gslist_type || type.data_type == gnode_type || type.data_type == gqueue_type) {
// create wrapper function to free list elements if necessary
bool elements_require_free = false;
......@@ -3088,17 +3074,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
return get_variable_cexpression (func_name);
}
} else if (type is ArrayType) {
if (context.profile == Profile.POSIX) {
return new CCodeIdentifier ("free");
} else {
return new CCodeIdentifier ("g_free");
}
} else if (type is PointerType) {
if (context.profile == Profile.POSIX) {
return new CCodeIdentifier ("free");
} else {
return new CCodeIdentifier ("g_free");
}
} else {
return new CCodeConstant ("NULL");
}
......@@ -3299,7 +3277,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
/* set freed references to NULL to prevent further use */
var ccomma = new CCodeCommaExpression ();
if (context.profile == Profile.GOBJECT) {
if (type.data_type != null && !is_reference_counting (type.data_type) &&
(type.data_type.is_subtype_of (gstringbuilder_type)
|| type.data_type.is_subtype_of (garray_type)
......@@ -3338,7 +3315,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
}
}
}
ccomma.append_expression (ccall);
ccomma.append_expression (new CCodeConstant ("NULL"));
......@@ -3777,12 +3753,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public override void visit_boolean_literal (BooleanLiteral expr) {
if (context.profile == Profile.GOBJECT) {
set_cvalue (expr, new CCodeConstant (expr.value ? "TRUE" : "FALSE"));
} else {
cfile.add_include ("stdbool.h");
set_cvalue (expr, new CCodeConstant (expr.value ? "true" : "false"));
}
}
public override void visit_character_literal (CharacterLiteral expr) {
......@@ -3895,9 +3866,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
}
public override void visit_null_literal (NullLiteral expr) {
if (context.profile != Profile.GOBJECT) {
cfile.add_include ("stddef.h");
}
set_cvalue (expr, new CCodeConstant ("NULL"));
var array_type = expr.target_type as ArrayType;
......@@ -4157,9 +4125,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
dup0_func = dupid.name;
} else if (add_wrapper (dup0_func)) {
string pointer_cname = "gpointer";
if (context.profile == Profile.POSIX) {
pointer_cname = "void*";
}
var dup0_fun = new CCodeFunction (dup0_func, pointer_cname);
dup0_fun.add_parameter (new CCodeParameter ("self", pointer_cname));
dup0_fun.modifiers = CCodeModifiers.STATIC;
......@@ -5010,7 +4975,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var cl = expr.type_reference.data_type as Class;
var iface = expr.type_reference.data_type as Interface;
if (context.profile == Profile.GOBJECT && (iface != null || (cl != null && !cl.is_compact))) {
if (iface != null || (cl != null && !cl.is_compact)) {
// checked cast for strict subtypes of GTypeInstance
if (expr.is_silent_cast) {
var cexpr = get_cvalue (expr.inner);
......@@ -5250,27 +5215,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
set_cvalue (expr, new CCodeConstant ("%s %s".printf (left, right)));
return;
} else {
if (context.profile == Profile.POSIX) {
// convert to strcat(strcpy(malloc(1+strlen(a)+strlen(b)),a),b)
var strcat = new CCodeFunctionCall (new CCodeIdentifier ("strcat"));
var strcpy = new CCodeFunctionCall (new CCodeIdentifier ("strcpy"));
var malloc = new CCodeFunctionCall (new CCodeIdentifier ("malloc"));
var strlen_a = new CCodeFunctionCall (new CCodeIdentifier ("strlen"));
strlen_a.add_argument(cleft);
var strlen_b = new CCodeFunctionCall (new CCodeIdentifier ("strlen"));
strlen_b.add_argument(cright);
var newlength = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, new CCodeIdentifier("1"),
new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, strlen_a, strlen_b));
malloc.add_argument(newlength);
strcpy.add_argument(malloc);
strcpy.add_argument(cleft);
strcat.add_argument(strcpy);
strcat.add_argument(cright);
set_cvalue (expr, strcat);
} else {
// convert to g_strconcat (a, b, NULL)
var temp_value = create_temp_value (expr.value_type, false, expr);
......@@ -5282,7 +5226,6 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
ccode.add_assignment (get_cvalue_ (temp_value), ccall);
expr.target_value = temp_value;
}
return;
}
} else if (expr.operator == BinaryOperator.EQUALITY
......@@ -5507,13 +5450,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
bool unboxing = (type is ValueType && type.nullable
&& target_type is ValueType && !target_type.nullable);
bool gvalue_boxing = (context.profile == Profile.GOBJECT
&& target_type != null
bool gvalue_boxing = (target_type != null
&& target_type.data_type == gvalue_type
&& !(type is NullType)
&& get_ccode_type_id (type) != "G_TYPE_VALUE");
bool gvariant_boxing = (context.profile == Profile.GOBJECT
&& target_type != null
bool gvariant_boxing = (target_type != null
&& target_type.data_type == gvariant_type
&& !(type is NullType)
&& type.data_type != gvariant_type);
......
......@@ -55,13 +55,11 @@ public class Vala.CCodeCompiler {
if (!context.compile_only) {
pc += " --libs";
}
if (context.profile == Profile.GOBJECT) {
use_pkgconfig = true;
pc += " gobject-2.0";
if (context.thread) {
pc += " gthread-2.0";
}
}
foreach (string pkg in context.get_packages ()) {
if (package_exists (pkg)) {
use_pkgconfig = true;
......
......@@ -206,12 +206,7 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
}
public override void visit_loop (Loop stmt) {
if (context.profile == Profile.GOBJECT) {
ccode.open_while (new CCodeConstant ("TRUE"));
} else {
cfile.add_include ("stdbool.h");
ccode.open_while (new CCodeConstant ("true"));
}
stmt.body.emit (this);
......
......@@ -48,8 +48,6 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
// Enum.VALUE.to_string()
var en = (Enum) ma.inner.value_type.data_type;
ccall.call = new CCodeIdentifier (generate_enum_tostring_function (en));
} else if (context.profile == Profile.POSIX && ma.inner != null && ma.inner.value_type != null && ma.inner.value_type.data_type == string_type.data_type && ma.member_name == "printf") {
ccall.call = new CCodeIdentifier (generate_string_printf_function ());
}
} else if (itype is SignalType) {
var sig_type = (SignalType) itype;
......@@ -123,13 +121,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
if (m is CreationMethod && m.parent_symbol is Class) {
if (context.profile == Profile.GOBJECT) {
if (!((Class) m.parent_symbol).is_compact) {
ccall.add_argument (get_variable_cexpression ("object_type"));
}
} else {
ccall.add_argument (get_this_cexpression ());
}
if (!current_class.is_compact) {
if (current_class != m.parent_symbol) {
......@@ -281,7 +275,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
param.accept (this);
}
generate_dynamic_method_wrapper ((DynamicMethod) m);
} else if (m is CreationMethod && context.profile == Profile.GOBJECT && m.parent_symbol is Class) {
} else if (m is CreationMethod && m.parent_symbol is Class) {
ccode.add_assignment (get_this_cexpression (), new CCodeCastExpression (ccall, CCodeBaseModule.get_ccode_name (current_class) + "*"));
if (current_method.body.captured) {
......@@ -837,80 +831,5 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
return to_string_func;
}
private string generate_string_printf_function () {
if (!add_wrapper ("string_printf")) {
// wrapper already defined
return "string_printf";
}
// declaration
var function = new CCodeFunction ("string_printf", "char*");
function.add_parameter (new CCodeParameter ("format", "const char*"));
function.add_parameter (new CCodeParameter.with_ellipsis ());
function.modifiers = CCodeModifiers.STATIC;
// definition
push_context (new EmitContext ());
push_function (function);
ccode.add_declaration ("int", new CCodeVariableDeclarator ("length"));
ccode.add_declaration ("va_list", new CCodeVariableDeclarator ("ap"));
ccode.add_declaration ("char*", new CCodeVariableDeclarator ("result"));
var va_start = new CCodeFunctionCall (new CCodeIdentifier ("va_start"));
va_start.add_argument (new CCodeIdentifier ("ap"));
va_start.add_argument (new CCodeIdentifier ("format"));
ccode.add_expression (va_start);
var vsnprintf = new CCodeFunctionCall (new CCodeIdentifier ("vsnprintf"));
vsnprintf.add_argument (new CCodeConstant ("NULL"));
vsnprintf.add_argument (new CCodeConstant ("0"));
vsnprintf.add_argument (new CCodeIdentifier ("format"));
vsnprintf.add_argument (new CCodeIdentifier ("ap"));
ccode.add_assignment (new CCodeIdentifier ("length"), new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, vsnprintf, new CCodeConstant ("1")));
var va_end = new CCodeFunctionCall (new CCodeIdentifier ("va_end"));
va_end.add_argument (new CCodeIdentifier ("ap"));
ccode.add_expression (va_end);
var malloc = new CCodeFunctionCall (new CCodeIdentifier ("malloc"));
malloc.add_argument (new CCodeIdentifier ("length"));
ccode.add_assignment (new CCodeIdentifier ("result"), malloc);
va_start = new CCodeFunctionCall (new CCodeIdentifier ("va_start"));
va_start.add_argument (new CCodeIdentifier ("ap"));
va_start.add_argument (new CCodeIdentifier ("format"));
ccode.add_expression (va_start);
vsnprintf = new CCodeFunctionCall (new CCodeIdentifier ("vsnprintf"));
vsnprintf.add_argument (new CCodeIdentifier ("result"));
vsnprintf.add_argument (new CCodeIdentifier ("length"));
vsnprintf.add_argument (new CCodeIdentifier ("format"));
vsnprintf.add_argument (new CCodeIdentifier ("ap"));
ccode.add_expression (vsnprintf);
va_end = new CCodeFunctionCall (new CCodeIdentifier ("va_end"));
va_end.add_argument (new CCodeIdentifier ("ap"));
ccode.add_expression (va_end);
ccode.add_return (new CCodeIdentifier ("result"));
// append to file
cfile.add_include ("stdarg.h");
cfile.add_function_declaration (function);
cfile.add_function (function);
pop_context ();
return "string_printf";
}
}
......@@ -827,7 +827,6 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
cmain.add_parameter (new CCodeParameter ("argv", "char **"));
push_function (cmain);
if (context.profile == Profile.GOBJECT) {
if (context.mem_profiler) {
var mem_profiler_init_call = new CCodeFunctionCall (new CCodeIdentifier ("g_mem_set_vtable"));
mem_profiler_init_call.line = cmain.line;
......@@ -843,7 +842,6 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
}
ccode.add_expression (new CCodeFunctionCall (new CCodeIdentifier ("g_type_init")));
}
var main_call = new CCodeFunctionCall (new CCodeIdentifier (function.name));
if (m.get_parameters ().size == 1) {
......
......@@ -53,7 +53,6 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
return;
}
if (context.profile == Profile.GOBJECT) {
if (get_ccode_has_type_id (st)) {
decl_space.add_type_declaration (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (get_ccode_lower_case_name (st, null));
......@@ -63,7 +62,6 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
type_fun.init_from_type (false, true);
decl_space.add_type_member_declaration (type_fun.get_declaration ());
}
}
var instance_struct = new CCodeStruct ("_%s".printf (get_ccode_name (st)));
instance_struct.deprecated = st.deprecated;
......@@ -204,17 +202,10 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
ccode.add_declaration (get_ccode_name (st) + "*", new CCodeVariableDeclarator ("dup"));
if (context.profile == Profile.GOBJECT) {
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
creation_call.add_argument (new CCodeConstant (get_ccode_name (st)));
creation_call.add_argument (new CCodeConstant ("1"));
ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
} else if (context.profile == Profile.POSIX) {
var creation_call = new CCodeFunctionCall (new CCodeIdentifier ("calloc"));
creation_call.add_argument (new CCodeConstant ("1"));
creation_call.add_argument (new CCodeIdentifier ("sizeof (%s*)".printf (get_ccode_name (st))));
ccode.add_assignment (new CCodeIdentifier ("dup"), creation_call);
}
if (st.is_disposable ()) {
var copy_call = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_copy_function (st)));
......@@ -257,15 +248,9 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
ccode.add_expression (destroy_call);
}
if (context.profile == Profile.GOBJECT) {
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("g_free"));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (free_call);
} else if (context.profile == Profile.POSIX) {
var free_call = new CCodeFunctionCall (new CCodeIdentifier ("free"));
free_call.add_argument (new CCodeIdentifier ("self"));
ccode.add_expression (free_call);
}
pop_function ();
......
......@@ -207,10 +207,7 @@ class Vala.Compiler {
context.thread = thread;
context.mem_profiler = mem_profiler;
context.save_temps = save_temps;
if (profile == "posix") {
context.profile = Profile.POSIX;
context.add_define ("POSIX");
} else if (profile == "gobject-2.0" || profile == "gobject" || profile == null) {
if (profile == "gobject-2.0" || profile == "gobject" || profile == null) {
// default profile
context.profile = Profile.GOBJECT;
context.add_define ("GOBJECT");
......@@ -234,12 +231,6 @@ class Vala.Compiler {
context.add_define ("VALA_0_%d".printf (i));
}
if (context.profile == Profile.POSIX) {
if (!nostdpkg) {
/* default package */
context.add_external_package ("posix");
}
} else if (context.profile == Profile.GOBJECT) {
int glib_major = 2;
int glib_minor = 18;
if (target_glib != null && target_glib.scanf ("%d.%d", out glib_major, out glib_minor) != 2) {
......@@ -261,7 +252,6 @@ class Vala.Compiler {
context.add_external_package ("glib-2.0");
context.add_external_package ("gobject-2.0");
}
}
if (packages != null) {
foreach (string package in packages) {
......@@ -282,11 +272,7 @@ class Vala.Compiler {
return quit ();
}
if (context.profile == Profile.GOBJECT) {
context.codegen = new GDBusServerModule ();
} else {
context.codegen = new CCodeDelegateModule ();
}
bool has_c_files = false;
......@@ -357,7 +343,6 @@ class Vala.Compiler {
if (library != null) {
if (gir != null) {
if (context.profile == Profile.GOBJECT) {
long gir_len = gir.length;
int last_hyphen = gir.last_index_of_char ('-');
......@@ -381,7 +366,6 @@ class Vala.Compiler {
gir_writer.write_file (context, gir_directory, gir_namespace, gir_version, library);
}
}
}
gir = null;
}
......
......@@ -157,7 +157,7 @@ public class Vala.ArrayType : ReferenceType {
}
public override bool compatible (DataType target_type) {
if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
if (target_type.data_type != null) {
if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type) && element_type.data_type == CodeContext.get ().root.scope.lookup ("string")) {
// allow implicit conversion from string[] to GValue
return true;
......
......@@ -127,11 +127,7 @@ public class Vala.CatchClause : CodeNode {
}
} else {
// generic catch clause
if (context.profile == Profile.GOBJECT) {
error_type = new ErrorType (null, null, source_reference);
} else {
error_type = context.analyzer.error_type;
}
}
error_type.check (context);
......
......@@ -407,17 +407,10 @@ public class Vala.CodeContext {
var source_file = new SourceFile (this, SourceFileType.SOURCE, rpath, null, cmdline);
source_file.relative_filename = filename;
if (profile == Profile.POSIX) {
// import the Posix namespace by default (namespace of backend-specific standard library)
var ns_ref = new UsingDirective (new UnresolvedSymbol (null, "Posix", null));
source_file.add_using_directive (ns_ref);
root.add_using_directive (ns_ref);
} else if (profile == Profile.GOBJECT) {
// import the GLib namespace by default (namespace of backend-specific standard library)
var ns_ref = new UsingDirective (new UnresolvedSymbol (null, "GLib", null));
source_file.add_using_directive (ns_ref);
root.add_using_directive (ns_ref);
}
add_source_file (source_file);
} else if (filename.has_suffix (".vapi") || filename.has_suffix (".gir")) {
......
......@@ -122,8 +122,7 @@ public class Vala.CreationMethod : Method {
// ensure we chain up to base constructor
if (!chain_up && cl != null && cl.base_class != null) {
if (context.profile == Profile.GOBJECT
&& cl.base_class.default_construction_method != null
if (cl.base_class.default_construction_method != null
&& !cl.base_class.default_construction_method.has_construct_function) {
// directly chain up to Object
var old_insert_block = context.analyzer.insert_block;
......
......@@ -262,7 +262,7 @@ public abstract class Vala.DataType : CodeNode {
return false;
}
if (CodeContext.get ().profile == Profile.GOBJECT && target_type.data_type != null) {
if (target_type.data_type != null) {
if (target_type.data_type.is_subtype_of (CodeContext.get ().analyzer.gvalue_type.data_type)) {
// allow implicit conversion to GValue
return true;
......
......@@ -141,7 +141,7 @@ public class Vala.ElementAccess : Expression {
value_type.value_owned = false;
} else {
var ma = container as MemberAccess;
if (context.profile == Profile.GOBJECT && ma != null && ma.symbol_reference is ArrayLengthField) {
if (ma != null && ma.symbol_reference is ArrayLengthField) {
// propagate lvalue for gobject length access
ma.inner.lvalue = true;
((MemberAccess) ma.inner).check_lvalue_access ();
......
......@@ -847,7 +847,6 @@ public class Vala.FlowAnalyzer : CodeVisitor {
// exceptional control flow
foreach (DataType error_data_type in node.get_error_types()) {
var error_type = error_data_type as ErrorType;
var error_class = error_data_type.data_type as Class;
current_block = last_block;
unreachable_reported = true;
......@@ -858,7 +857,6 @@ public class Vala.FlowAnalyzer : CodeVisitor {
mark_unreachable ();
break;
} else if (jump_target.is_error_target) {
if (context.profile == Profile.GOBJECT) {
if (jump_target.error_domain == null
|| (jump_target.error_domain == error_type.error_domain
&& (jump_target.error_code == null
......@@ -877,18 +875,6 @@ public class Vala.FlowAnalyzer : CodeVisitor {
// following catch clauses might still be reached by this error
current_block.connect (jump_target.basic_block);
}
} else if (jump_target.error_class == null || jump_target.error_class == error_class) {
// error can always be caught by this catch clause
// following catch clauses cannot be reached by this error
current_block.connect (jump_target.basic_block);
mark_unreachable ();
break;
} else if (jump_target.error_class.is_subtype_of (error_class)) {
// error might be caught by this catch clause
// unknown at compile time
// following catch clauses might still be reached by this error
current_block.connect (jump_target.basic_block);
}
} else if (jump_target.is_finally_clause) {
current_block.connect (jump_target.basic_block);
current_block = jump_target.last_block;
......@@ -957,13 +943,8 @@ public class Vala.FlowAnalyzer : CodeVisitor {
for (int i = catch_clauses.size - 1; i >= 0; i--) {
var catch_clause = catch_clauses[i];
if (catch_clause.error_type != null) {
if (context.profile == Profile.GOBJECT) {
var error_type = catch_clause.error_type as ErrorType;
jump_stack.add (new JumpTarget.error_target (new BasicBlock (), catch_clause, catch_clause.error_type.data_type as ErrorDomain, error_type.error_code, null));
} else {
var error_class = catch_clause.error_type.data_type as Class;
jump_stack.add (new JumpTarget.error_target (new BasicBlock (), catch_clause, null, null, error_class));
}
} else {
jump_stack.add (new JumpTarget.error_target (new BasicBlock (), catch_clause, null, null, null));
}
......@@ -996,18 +977,12 @@ public class Vala.FlowAnalyzer : CodeVisitor {
break;
}
if (context.profile == Profile.GOBJECT) {
if (prev_target.error_domain == jump_target.error_domain &&
prev_target.error_code == jump_target.error_code) {
Report.error (stmt.source_reference, "double catch clause of same error detected");
stmt.error = true;
return;
}
} else if (prev_target.error_class == jump_target.error_class) {
Report.error (stmt.source_reference, "double catch clause of same error detected");
stmt.error = true;
return;
}
}
if (jump_target.basic_block.get_predecessors ().size == 0) {
......
......@@ -174,7 +174,7 @@ public class Vala.ForeachStatement : Block {
array_type.inline_allocated = false;
return check_without_iterator (context, collection_type, array_type.element_type);
} else if (context.profile == Profile.GOBJECT && (collection_type.compatible (context.analyzer.glist_type) || collection_type.compatible (context.analyzer.gslist_type))) {
} else if (collection_type.compatible (context.analyzer.glist_type) || collection_type.compatible (context.analyzer.gslist_type)) {
if (collection_type.get_type_arguments ().size != 1) {
error = true;
Report.error (collection.source_reference, "missing type argument for collection");
......@@ -182,7 +182,7 @@ public class Vala.ForeachStatement : Block {
}
return check_without_iterator (context, collection_type, collection_type.get_type_arguments ().get (0));
} else if (context.profile == Profile.GOBJECT && collection_type.compatible (context.analyzer.gvaluearray_type)) {
} else if (collection_type.compatible (context.analyzer.gvaluearray_type)) {
return check_without_iterator (context, collection_type, context.analyzer.gvalue_type);
} else {
return check_with_iterator (context, collection_type);
......
......@@ -2341,11 +2341,8 @@ public class Vala.Genie.Parser : CodeVisitor {
if (is_root) {
return parse_main_method_declaration (attrs);
}
if (context.profile == Profile.GOBJECT) {
rollback (begin);
return parse_constructor_declaration (attrs);
}
break;
case TokenType.DELEGATE:
return parse_delegate_declaration (attrs);
case TokenType.DEF:
......@@ -3073,8 +3070,8 @@ public class Vala.Genie.Parser : CodeVisitor {
if (readonly) {
throw new ParseError.SYNTAX (get_error ("set block not allowed for a read only property"));
}
_construct = (context.profile == Profile.GOBJECT) && accept (TokenType.CONSTRUCT);
} else if (context.profile == Profile.GOBJECT && accept (TokenType.CONSTRUCT)) {
_construct = accept (TokenType.CONSTRUCT);
} else if (accept (TokenType.CONSTRUCT)) {
_construct = true;
} else if (!accept (TokenType.EOL)) {
throw new ParseError.SYNTAX (get_error ("expected get, set, or construct"));
......
......@@ -842,7 +842,7 @@ public class Vala.MemberAccess : Expression {
}
var this_access = inner.symbol_reference is Parameter && inner.symbol_reference.name == "this";
var struct_or_array = (inner.value_type is StructValueType && !inner.value_type.nullable) || (CodeContext.get ().profile == Profile.GOBJECT && inner.value_type is ArrayType);
var