Skip to content

Commit

Permalink
Revert "Support chaining up to constructors in structs"
Browse files Browse the repository at this point in the history
This reverts commit e42d65d.
  • Loading branch information
phako committed Jan 30, 2010
1 parent d68c083 commit 7b3b56d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
12 changes: 2 additions & 10 deletions codegen/valaccodemethodcallmodule.vala
Expand Up @@ -62,12 +62,6 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
m = cl.default_construction_method;
generate_method_declaration (m, source_declarations);
ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
} else if (itype is StructValueType) {
// constructor
var st = (Struct) ((StructValueType) itype).type_symbol;
m = st.default_construction_method;
generate_method_declaration (m, source_declarations);
ccall = new CCodeFunctionCall (new CCodeIdentifier (m.get_real_cname ()));
} else if (itype is DelegateType) {
deleg = ((DelegateType) itype).delegate_symbol;
}
Expand Down Expand Up @@ -120,7 +114,7 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
}
}

if (m is CreationMethod && m.parent_symbol is Class) {
if (m is CreationMethod) {
if (context.profile == Profile.GOBJECT) {
if (!((Class) m.parent_symbol).is_compact) {
ccall.add_argument (new CCodeIdentifier ("object_type"));
Expand All @@ -135,8 +129,6 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
break;
}
}
} else if (m is CreationMethod && m.parent_symbol is Struct) {
ccall.add_argument (new CCodeIdentifier ("self"));
} else if (m != null && m.get_type_parameters ().size > 0) {
// generic method
add_generic_type_arguments (in_arg_map, ma.get_type_arguments (), expr);
Expand Down Expand Up @@ -252,7 +244,7 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
param.accept (codegen);
}
head.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 && context.profile == Profile.GOBJECT) {
ccall_expr = new CCodeAssignment (new CCodeIdentifier ("self"), new CCodeCastExpression (ccall, current_class.get_cname () + "*"));

if (!current_class.is_compact && current_class.get_type_parameters ().size > 0) {
Expand Down
9 changes: 0 additions & 9 deletions vala/valamethodcall.vala
Expand Up @@ -186,15 +186,6 @@ public class Vala.MethodCall : Expression {
((call.symbol_reference is CreationMethod
&& call.symbol_reference.parent_symbol is Struct)
|| call.symbol_reference is Struct)) {
var cm = analyzer.find_current_method () as CreationMethod;
if (cm != null) {
if (cm.chain_up) {
error = true;
Report.error (source_reference, "Multiple constructor calls in the same constructor are not permitted");
return false;
}
cm.chain_up = true;
}
var struct_creation_expression = new ObjectCreationExpression ((MemberAccess) call, source_reference);
struct_creation_expression.struct_creation = true;
foreach (Expression arg in get_argument_list ()) {
Expand Down
27 changes: 0 additions & 27 deletions vala/valastructvaluetype.vala
Expand Up @@ -30,33 +30,6 @@ public class Vala.StructValueType : ValueType {
base (type_symbol);
}

public override bool is_invokable () {
var st = type_symbol as Struct;
if (st != null && st.default_construction_method != null) {
return true;
} else {
return false;
}
}

public override DataType? get_return_type () {
var st = type_symbol as Struct;
if (st != null && st.default_construction_method != null) {
return st.default_construction_method.return_type;
} else {
return null;
}
}

public override List<FormalParameter>? get_parameters () {
var st = type_symbol as Struct;
if (st != null && st.default_construction_method != null) {
return st.default_construction_method.get_parameters ();
} else {
return null;
}
}

public override DataType copy () {
var result = new StructValueType ((Struct) type_symbol);
result.source_reference = source_reference;
Expand Down

0 comments on commit 7b3b56d

Please sign in to comment.