+2007-06-15 Jürg Billeter <j@bitron.ch>
+
+ * vala/valaattributeprocessor.vala, vala/valacodevisitor.vala,
+ vala/valainterfacewriter.vala, vala/valamemorymanager.vala,
+ vala/valasemanticanalyzer.vala, vala/valasymbolbuilder.vala,
+ vala/valasymbolresolver.vala, vala/valaconstant.vala,
+ vala/valaconstructor.vala, vala/valacreationmethod.vala,
+ vala/valadestructor.vala, vala/valafield.vala,
+ vala/valaformalparameter.vala, vala/valamethod.vala,
+ vala/valaproperty.vala, vala/valapropertyaccessor.vala,
+ vala/valasignal.vala, gobject/valacodegenerator.vala,
+ gobject/valacodegeneratormethod.vala,
+ gobject/valacodegeneratorsignal.vala: move iteration of symbol nodes
+ from accept to accept_children method
+
2007-06-15 Jürg Billeter <j@bitron.ch>
* vala/valaattributeprocessor.vala, vala/valacodevisitor.vala,
}
public override void visit_constant (Constant! c) {
+ c.accept_children (this);
+
if (c.symbol.parent_symbol.node is DataType) {
var t = (DataType) c.symbol.parent_symbol.node;
var cdecl = new CCodeDeclaration (c.type_reference.get_const_cname ());
}
public override void visit_field (Field! f) {
+ f.accept_children (this);
+
CCodeExpression lhs = null;
CCodeStruct st = null;
}
public override void visit_formal_parameter (FormalParameter! p) {
+ p.accept_children (this);
+
if (!p.ellipsis) {
p.ccodenode = new CCodeFormalParameter (p.name, p.type_reference.get_cname (false, !p.type_reference.takes_ownership));
}
}
- public override void visit_end_property (Property! prop) {
+ public override void visit_property (Property! prop) {
+ prop.accept_children (this);
+
prop_enum.add_value (prop.get_upper_case_cname (), null);
}
- public override void visit_begin_property_accessor (PropertyAccessor! acc) {
+ public override void visit_property_accessor (PropertyAccessor! acc) {
var prop = (Property) acc.symbol.parent_symbol.node;
if (acc.readable) {
// void
current_return_type = new TypeReference ();
}
- }
- public override void visit_end_property_accessor (PropertyAccessor! acc) {
- var prop = (Property) acc.symbol.parent_symbol.node;
+ acc.accept_children (this);
current_return_type = null;
}
}
- public override void visit_end_constructor (Constructor! c) {
+ public override void visit_constructor (Constructor! c) {
+ c.accept_children (this);
+
var cl = (Class) c.symbol.parent_symbol.node;
function = new CCodeFunction ("%s_constructor".printf (cl.get_lower_case_cname (null)), "GObject *");
source_type_member_definition.append (function);
}
+ public override void visit_destructor (Destructor! d) {
+ d.accept_children (this);
+ }
+
public override void visit_begin_block (Block! b) {
current_symbol = b.symbol;
}
using GLib;
public class Vala.CodeGenerator {
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
current_symbol = m.symbol;
current_return_type = m.return_type;
- }
-
- private ref CCodeStatement create_method_type_check_statement (Method! m, DataType! t, bool non_null, string! var_name) {
- return create_type_check_statement (m, m.return_type.data_type, t, non_null, var_name);
- }
-
- private ref CCodeStatement create_property_type_check_statement (Property! prop, bool getter, DataType! t, bool non_null, string! var_name) {
- if (getter) {
- return create_type_check_statement (prop, prop.type_reference.data_type, t, non_null, var_name);
- } else {
- return create_type_check_statement (prop, null, t, non_null, var_name);
- }
- }
-
- private ref CCodeStatement create_type_check_statement (CodeNode! method_node, DataType ret_type, DataType! t, bool non_null, string! var_name) {
- var ccheck = new CCodeFunctionCall ();
-
- if (t is Class || t is Interface) {
- var ctype_check = new CCodeFunctionCall (new CCodeIdentifier (t.get_upper_case_cname ("IS_")));
- ctype_check.add_argument (new CCodeIdentifier (var_name));
-
- ref CCodeExpression cexpr = ctype_check;
- if (!non_null) {
- var cnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier (var_name), new CCodeConstant ("NULL"));
-
- cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.OR, cnull, ctype_check);
- }
- ccheck.add_argument (cexpr);
- } else if (!non_null) {
- return null;
- } else {
- var cnonnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier (var_name), new CCodeConstant ("NULL"));
- ccheck.add_argument (cnonnull);
- }
-
- if (ret_type == null) {
- /* void function */
- ccheck.call = new CCodeIdentifier ("g_return_if_fail");
- } else {
- ccheck.call = new CCodeIdentifier ("g_return_val_if_fail");
-
- if (ret_type.is_reference_type () || ret_type is Pointer) {
- ccheck.add_argument (new CCodeConstant ("NULL"));
- } else if (ret_type.get_default_value () != null) {
- ccheck.add_argument (new CCodeConstant (ret_type.get_default_value ()));
- } else {
- Report.warning (method_node.source_reference, "not supported return type for runtime type checks");
- return new CCodeExpressionStatement (new CCodeConstant ("0"));
- }
+
+ if (m is CreationMethod) {
+ in_creation_method = true;
}
-
- return new CCodeExpressionStatement (ccheck);
- }
- private DataType find_parent_type (CodeNode node) {
- var sym = node.symbol;
- while (sym != null) {
- if (sym.node is DataType) {
- return (DataType) sym.node;
+ m.accept_children (this);
+
+ if (m is CreationMethod) {
+ if (current_class != null && m.body != null) {
+ add_object_creation ((CCodeBlock) m.body.ccodenode);
}
- sym = sym.parent_symbol;
+
+ in_creation_method = false;
}
- return null;
- }
-
- private ref string! get_array_length_cname (string! array_cname, int dim) {
- return "%s_length%d".printf (array_cname, dim);
- }
- public override void visit_end_method (Method! m) {
current_symbol = current_symbol.parent_symbol;
current_return_type = null;
}
}
- public override void visit_begin_creation_method (CreationMethod! m) {
- current_symbol = m.symbol;
- current_return_type = m.return_type;
- in_creation_method = true;
+ private ref CCodeStatement create_method_type_check_statement (Method! m, DataType! t, bool non_null, string! var_name) {
+ return create_type_check_statement (m, m.return_type.data_type, t, non_null, var_name);
}
- public override void visit_end_creation_method (CreationMethod! m) {
- if (current_class != null && m.body != null) {
- add_object_creation ((CCodeBlock) m.body.ccodenode);
+ private ref CCodeStatement create_property_type_check_statement (Property! prop, bool getter, DataType! t, bool non_null, string! var_name) {
+ if (getter) {
+ return create_type_check_statement (prop, prop.type_reference.data_type, t, non_null, var_name);
+ } else {
+ return create_type_check_statement (prop, null, t, non_null, var_name);
+ }
+ }
+
+ private ref CCodeStatement create_type_check_statement (CodeNode! method_node, DataType ret_type, DataType! t, bool non_null, string! var_name) {
+ var ccheck = new CCodeFunctionCall ();
+
+ if (t is Class || t is Interface) {
+ var ctype_check = new CCodeFunctionCall (new CCodeIdentifier (t.get_upper_case_cname ("IS_")));
+ ctype_check.add_argument (new CCodeIdentifier (var_name));
+
+ ref CCodeExpression cexpr = ctype_check;
+ if (!non_null) {
+ var cnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, new CCodeIdentifier (var_name), new CCodeConstant ("NULL"));
+
+ cexpr = new CCodeBinaryExpression (CCodeBinaryOperator.OR, cnull, ctype_check);
+ }
+ ccheck.add_argument (cexpr);
+ } else if (!non_null) {
+ return null;
+ } else {
+ var cnonnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier (var_name), new CCodeConstant ("NULL"));
+ ccheck.add_argument (cnonnull);
}
+
+ if (ret_type == null) {
+ /* void function */
+ ccheck.call = new CCodeIdentifier ("g_return_if_fail");
+ } else {
+ ccheck.call = new CCodeIdentifier ("g_return_val_if_fail");
+
+ if (ret_type.is_reference_type () || ret_type is Pointer) {
+ ccheck.add_argument (new CCodeConstant ("NULL"));
+ } else if (ret_type.get_default_value () != null) {
+ ccheck.add_argument (new CCodeConstant (ret_type.get_default_value ()));
+ } else {
+ Report.warning (method_node.source_reference, "not supported return type for runtime type checks");
+ return new CCodeExpressionStatement (new CCodeConstant ("0"));
+ }
+ }
+
+ return new CCodeExpressionStatement (ccheck);
+ }
- in_creation_method = false;
+ private DataType find_parent_type (CodeNode node) {
+ var sym = node.symbol;
+ while (sym != null) {
+ if (sym.node is DataType) {
+ return (DataType) sym.node;
+ }
+ sym = sym.parent_symbol;
+ }
+ return null;
+ }
+
+ private ref string! get_array_length_cname (string! array_cname, int dim) {
+ return "%s_length%d".printf (array_cname, dim);
+ }
- visit_end_method (m);
+ public override void visit_creation_method (CreationMethod! m) {
+ visit_method (m);
}
private bool is_possible_entry_point (Method! m, ref bool return_value, ref bool args_parameter) {
return signature;
}
- public override void visit_end_signal (Signal! sig) {
+ public override void visit_signal (Signal! sig) {
+ sig.accept_children (this);
+
string signature;
var params = sig.get_parameters ();
int n_params, i;
fl.process_attributes ();
}
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
m.process_attributes ();
}
- public override void visit_begin_creation_method (CreationMethod! m) {
+ public override void visit_creation_method (CreationMethod! m) {
m.process_attributes ();
}
- public override void visit_begin_property (Property! prop) {
+ public override void visit_property (Property! prop) {
prop.process_attributes ();
}
f.process_attributes ();
}
- public override void visit_begin_signal (Signal! sig) {
+ public override void visit_signal (Signal! sig) {
sig.process_attributes ();
}
}
}
/**
- * Visit operation called for Members.
+ * Visit operation called for members.
*
* @param m a member
*/
}
/**
- * Visit operation called at beginning of methods.
+ * Visit operation called for methods.
*
* @param m a method
*/
- public virtual void visit_begin_method (Method! m) {
+ public virtual void visit_method (Method! m) {
}
/**
- * Visit operation called at end of methods.
+ * Visit operation called for creation methods.
*
* @param m a method
*/
- public virtual void visit_end_method (Method! m) {
- }
-
- /**
- * Visit operation called at beginning of creation methods.
- *
- * @param m a method
- */
- public virtual void visit_begin_creation_method (CreationMethod! m) {
- }
-
- /**
- * Visit operation called at end of creation methods.
- *
- * @param m a method
- */
- public virtual void visit_end_creation_method (CreationMethod! m) {
+ public virtual void visit_creation_method (CreationMethod! m) {
}
/**
}
/**
- * Visit operation called at beginning of properties.
- *
- * @param prop a property
- */
- public virtual void visit_begin_property (Property! prop) {
- }
-
- /**
- * Visit operation called at end of properties.
+ * Visit operation called for properties.
*
* @param prop a property
*/
- public virtual void visit_end_property (Property! prop) {
- }
-
- /**
- * Visit operation called at beginning of property accessors.
- *
- * @param acc a property accessor
- */
- public virtual void visit_begin_property_accessor (PropertyAccessor! acc) {
+ public virtual void visit_property (Property! prop) {
}
/**
- * Visit operation called at end of property accessors.
+ * Visit operation called for property accessors.
*
* @param acc a property accessor
*/
- public virtual void visit_end_property_accessor (PropertyAccessor! acc) {
+ public virtual void visit_property_accessor (PropertyAccessor! acc) {
}
/**
- * Visit operation called at beginning of signals.
+ * Visit operation called for signals.
*
* @param sig a signal
*/
- public virtual void visit_begin_signal (Signal! sig) {
+ public virtual void visit_signal (Signal! sig) {
}
/**
- * Visit operation called at end of signals.
- *
- * @param sig a signal
- */
- public virtual void visit_end_signal (Signal! sig) {
- }
-
- /**
- * Visit operation called at beginning of constructors.
+ * Visit operation called for constructors.
*
* @param c a constructor
*/
- public virtual void visit_begin_constructor (Constructor! c) {
- }
-
- /**
- * Visit operation called at end of constructors.
- *
- * @param c a constructor
- */
- public virtual void visit_end_constructor (Constructor! c) {
- }
-
- /**
- * Visit operation called at beginning of destructors.
- *
- * @param d a destructor
- */
- public virtual void visit_begin_destructor (Destructor! d) {
+ public virtual void visit_constructor (Constructor! c) {
}
/**
- * Visit operation called at end of destructors.
+ * Visit operation called for destructors.
*
* @param d a destructor
*/
- public virtual void visit_end_destructor (Destructor! d) {
+ public virtual void visit_destructor (Destructor! d) {
}
/**
/* valaconstant.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
initializer = init;
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
-
+
+ visitor.visit_constant (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
type_reference.accept (visitor);
if (initializer != null) {
initializer.accept (visitor);
}
-
- visitor.visit_constant (this);
}
-
+
/**
* Returns the name of this constant as it is used in C code.
*
/* valaconstructor.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
public Constructor (SourceReference source) {
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_constructor (this);
-
+ visitor.visit_constructor (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
if (body != null) {
body.accept (visitor);
}
-
- visitor.visit_end_constructor (this);
}
}
}
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_creation_method (this);
-
+ visitor.visit_creation_method (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
foreach (FormalParameter param in get_parameters()) {
param.accept (visitor);
}
if (body != null) {
body.accept (visitor);
}
-
- visitor.visit_end_creation_method (this);
}
public override ref string! get_default_cname () {
/* valadestructor.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
public Destructor (SourceReference source) {
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_destructor (this);
-
+ visitor.visit_destructor (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
if (body != null) {
body.accept (visitor);
}
-
- visitor.visit_end_destructor (this);
}
}
/* valafield.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
initializer = init;
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
+ visitor.visit_field (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
type_reference.accept (visitor);
if (initializer != null) {
initializer.accept (visitor);
}
-
- visitor.visit_field (this);
}
/**
ellipsis = true;
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
+ visitor.visit_formal_parameter (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
if (!ellipsis) {
type_reference.accept (visitor);
default_expression.accept (visitor);
}
}
-
- visitor.visit_formal_parameter (this);
}
public ref List<weak FormalParameter> get_parameters () {
write_newline ();
}
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
if (m.access == MemberAccessibility.PRIVATE || m.overrides) {
return;
}
write_newline ();
}
- public override void visit_begin_creation_method (CreationMethod! m) {
- visit_begin_method (m);
+ public override void visit_creation_method (CreationMethod! m) {
+ visit_method (m);
}
- public override void visit_begin_property (Property! prop) {
+ public override void visit_property (Property! prop) {
if (prop.no_accessor_method) {
write_indent ();
write_string ("[NoAccessorMethod]");
write_newline ();
}
- public override void visit_begin_signal (Signal! sig) {
+ public override void visit_signal (Signal! sig) {
if (sig.access == MemberAccessibility.PRIVATE) {
return;
}
}
}
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
current_symbol = m.symbol;
+
+ m.accept_children (this);
}
- public override void visit_begin_creation_method (CreationMethod! m) {
- current_symbol = m.symbol;
+ public override void visit_creation_method (CreationMethod! m) {
+ visit_method (m);
}
- public override void visit_begin_property (Property! prop) {
+ public override void visit_property (Property! prop) {
current_symbol = prop.symbol;
+
+ prop.accept_children (this);
+ }
+
+ public override void visit_property_accessor (PropertyAccessor! acc) {
+ acc.accept_children (this);
+ }
+
+ public override void visit_constructor (Constructor! c) {
+ c.accept_children (this);
+ }
+
+ public override void visit_destructor (Destructor! d) {
+ d.accept_children (this);
}
public override void visit_named_argument (NamedArgument! n) {
public bool is_invokable () {
return true;
}
-
+
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_method (this);
-
+ visitor.visit_method (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
if (return_type != null) {
return_type.accept (visitor);
}
if (body != null) {
body.accept (visitor);
}
-
- visitor.visit_end_method (this);
}
/**
set_accessor = _set_accessor;
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
- visitor.visit_begin_property (this);
+ visitor.visit_property (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
type_reference.accept (visitor);
if (get_accessor != null) {
if (set_accessor != null) {
set_accessor.accept (visitor);
}
-
- visitor.visit_end_property (this);
}
-
+
/**
* Returns the C name of this property in upper case. Words are
* separated by underscores. The upper case C name of the class is
/* valapropertyaccessor.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
body = _body;
source_reference = source;
}
-
+
public override void accept (CodeVisitor! visitor) {
- visitor.visit_begin_property_accessor (this);
+ visitor.visit_property_accessor (this);
+ }
+ public override void accept_children (CodeVisitor! visitor) {
if (body != null) {
body.accept (visitor);
}
-
- visitor.visit_end_property_accessor (this);
}
}
}
public override void visit_constant (Constant! c) {
+ c.accept_children (this);
+
if (!current_source_file.pkg) {
if (c.initializer == null) {
c.error = true;
}
public override void visit_field (Field! f) {
+ f.accept_children (this);
+
if (f.access != MemberAccessibility.PRIVATE) {
if (f.type_reference.data_type != null) {
/* is null if it references a type parameter */
}
}
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
current_symbol = m.symbol;
current_return_type = m.return_type;
/* is null if it is void or a reference to a type parameter */
current_source_file.add_symbol_dependency (m.return_type.data_type.symbol, SourceFileDependencyType.HEADER_SHALLOW);
}
+
+ m.accept_children (this);
+
+ current_symbol = current_symbol.parent_symbol;
+ current_return_type = null;
+
+ if (current_symbol.parent_symbol != null &&
+ current_symbol.parent_symbol.node is Method) {
+ /* lambda expressions produce nested methods */
+ var up_method = (Method) current_symbol.parent_symbol.node;
+ current_return_type = up_method.return_type;
+ }
+
+ if (current_symbol.node is Class) {
+ if (!(m is CreationMethod)) {
+ find_base_interface_method (m, (Class) current_symbol.node);
+ if (m.is_virtual || m.overrides) {
+ find_base_class_method (m, (Class) current_symbol.node);
+ if (m.base_method == null) {
+ Report.error (m.source_reference, "%s: no suitable method found to override".printf (m.symbol.get_full_name ()));
+ }
+ }
+ }
+ } else if (current_symbol.node is Struct) {
+ if (m.is_abstract || m.is_virtual || m.overrides) {
+ Report.error (m.source_reference, "A struct member `%s' cannot be marked as override, virtual, or abstract".printf (m.symbol.get_full_name ()));
+ return;
+ }
+ }
}
private void find_base_class_method (Method! m, Class! cl) {
}
}
- public override void visit_end_method (Method! m) {
+ public override void visit_creation_method (CreationMethod! m) {
+ m.return_type = new TypeReference ();
+ m.return_type.data_type = (DataType) current_symbol.node;
+ m.return_type.transfers_ownership = true;
+
+ if (current_symbol.node is Class) {
+ // check for floating reference
+ var cl = (Class) current_symbol.node;
+ while (cl != null) {
+ if (cl == initially_unowned_type) {
+ m.return_type.floating_reference = true;
+ break;
+ }
+
+ cl = cl.base_class;
+ }
+ }
+
+ current_symbol = m.symbol;
+ current_return_type = m.return_type;
+
+ m.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
current_return_type = null;
return;
}
}
- }
-
- public override void visit_begin_creation_method (CreationMethod! m) {
- m.return_type = new TypeReference ();
- m.return_type.data_type = (DataType) current_symbol.node;
- m.return_type.transfers_ownership = true;
-
- if (current_symbol.node is Class) {
- // check for floating reference
- var cl = (Class) current_symbol.node;
- while (cl != null) {
- if (cl == initially_unowned_type) {
- m.return_type.floating_reference = true;
- break;
- }
-
- cl = cl.base_class;
- }
- }
-
- current_symbol = m.symbol;
- current_return_type = m.return_type;
- }
-
- public override void visit_end_creation_method (CreationMethod! m) {
- visit_end_method (m);
if (m.body != null && current_class != null) {
int n_params = 0;
}
public override void visit_formal_parameter (FormalParameter! p) {
+ p.accept_children (this);
+
if (!p.ellipsis) {
if (p.type_reference.data_type != null) {
/* is null if it references a type parameter */
}
}
- public override void visit_end_property (Property! prop) {
+ public override void visit_property (Property! prop) {
+ prop.accept_children (this);
+
if (prop.type_reference.data_type != null) {
/* is null if it references a type parameter */
current_source_file.add_symbol_dependency (prop.type_reference.data_type.symbol, SourceFileDependencyType.HEADER_SHALLOW);
}
}
- public override void visit_begin_property_accessor (PropertyAccessor! acc) {
+ public override void visit_property_accessor (PropertyAccessor! acc) {
var prop = (Property) acc.symbol.parent_symbol.node;
if (acc.readable) {
// void
current_return_type = new TypeReference ();
}
- }
- public override void visit_end_property_accessor (PropertyAccessor! acc) {
+ acc.accept_children (this);
+
current_return_type = null;
}
- public override void visit_begin_constructor (Constructor! c) {
- current_symbol = c.symbol;
+ public override void visit_signal (Signal! sig) {
+ sig.accept_children (this);
}
- public override void visit_end_constructor (Constructor! c) {
+ public override void visit_constructor (Constructor! c) {
+ current_symbol = c.symbol;
+
+ c.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_destructor (Destructor! d) {
+ public override void visit_destructor (Destructor! d) {
current_symbol = d.symbol;
- }
- public override void visit_end_destructor (Destructor! d) {
+ d.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
/* valasignal.vala
*
- * Copyright (C) 2006 Jürg Billeter
+ * Copyright (C) 2006-2007 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
return new CCodeConstant (str.str);
}
-
+
public override void accept (CodeVisitor! visitor) {
visitor.visit_member (this);
- visitor.visit_begin_signal (this);
-
+ visitor.visit_signal (this);
+ }
+
+ public override void accept_children (CodeVisitor! visitor) {
return_type.accept (visitor);
foreach (FormalParameter param in parameters) {
param.accept (visitor);
}
-
- visitor.visit_end_signal (this);
}
-
+
/**
* Process all associated attributes.
*/
}
public override void visit_callback (Callback! cb) {
+ if (cb.error) {
+ /* skip enums with errors */
+ return;
+ }
+
if (add_symbol (cb.name, cb) == null) {
return;
}
cb.accept_children (this);
- if (cb.error) {
- /* skip enums with errors */
- return;
- }
-
current_symbol = current_symbol.parent_symbol;
}
add_symbol (f.name, f);
}
- public override void visit_begin_method (Method! m) {
+ public override void visit_method (Method! m) {
if (add_symbol (m.name, m) == null) {
return;
}
}
current_symbol = m.symbol;
- }
-
- public override void visit_end_method (Method! m) {
- if (m.error) {
- /* skip methods with errors */
- return;
- }
-
+
+ m.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_creation_method (CreationMethod! m) {
+ public override void visit_creation_method (CreationMethod! m) {
if (add_symbol (m.name, m) == null) {
return;
}
}
current_symbol = m.symbol;
- }
-
- public override void visit_end_creation_method (CreationMethod! m) {
- if (m.error) {
- /* skip methods with errors */
- return;
- }
-
+
+ m.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
}
}
- public override void visit_begin_property (Property! prop) {
+ public override void visit_property (Property! prop) {
+ if (prop.error) {
+ /* skip properties with errors */
+ return;
+ }
+
if (add_symbol (prop.name, prop) == null) {
return;
}
prop.this_parameter.type_reference.data_type = (DataType) prop.symbol.parent_symbol.node;
prop.this_parameter.symbol = new Symbol (prop.this_parameter);
current_symbol.add (prop.this_parameter.name, prop.this_parameter.symbol);
- }
-
- public override void visit_end_property (Property! prop) {
- if (prop.error) {
- /* skip properties with errors */
- return;
- }
-
+
+ prop.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_property_accessor (PropertyAccessor! acc) {
+ public override void visit_property_accessor (PropertyAccessor! acc) {
acc.symbol = new Symbol (acc);
acc.symbol.parent_symbol = current_symbol;
- current_symbol = acc.symbol;
-
+
if (current_source_file.pkg) {
return;
}
+ current_symbol = acc.symbol;
+
if (acc.writable || acc.construction) {
acc.value_parameter = new FormalParameter ("value", ((Property) current_symbol.parent_symbol.node).type_reference);
acc.value_parameter.symbol = new Symbol (acc.value_parameter);
}
acc.body = block;
}
- }
-
- public override void visit_end_property_accessor (PropertyAccessor! acc) {
+
+ acc.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_signal (Signal! sig) {
- if (add_symbol (sig.name, sig) == null) {
+ public override void visit_signal (Signal! sig) {
+ if (sig.error) {
+ /* skip signals with errors */
return;
}
-
- current_symbol = sig.symbol;
- }
- public override void visit_end_signal (Signal! sig) {
- if (sig.error) {
- /* skip signals with errors */
+ if (add_symbol (sig.name, sig) == null) {
return;
}
+ current_symbol = sig.symbol;
+
+ sig.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_constructor (Constructor! c) {
+ public override void visit_constructor (Constructor! c) {
c.symbol = new Symbol (c);
c.symbol.parent_symbol = current_symbol;
current_symbol = c.symbol;
- }
- public override void visit_end_constructor (Constructor! c) {
+ c.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
- public override void visit_begin_destructor (Destructor! d) {
+ public override void visit_destructor (Destructor! d) {
d.symbol = new Symbol (d);
d.symbol.parent_symbol = current_symbol;
current_symbol = d.symbol;
- }
- public override void visit_end_destructor (Destructor! d) {
+ d.accept_children (this);
+
current_symbol = current_symbol.parent_symbol;
}
current_scope = current_scope.parent_symbol;
}
+ public override void visit_constant (Constant! c) {
+ c.accept_children (this);
+ }
+
+ public override void visit_field (Field! f) {
+ f.accept_children (this);
+ }
+
+ public override void visit_method (Method! m) {
+ m.accept_children (this);
+ }
+
+ public override void visit_creation_method (CreationMethod! m) {
+ m.accept_children (this);
+ }
+
public override void visit_formal_parameter (FormalParameter! p) {
+ p.accept_children (this);
+
if (!p.ellipsis && p.type_reference.is_ref) {
if ((p.type_reference.data_type != null &&
p.type_reference.data_type.is_reference_type ()) ||
}
}
+ public override void visit_property (Property! prop) {
+ prop.accept_children (this);
+ }
+
+ public override void visit_property_accessor (PropertyAccessor! acc) {
+ acc.accept_children (this);
+ }
+
+ public override void visit_signal (Signal! sig) {
+ sig.accept_children (this);
+ }
+
+ public override void visit_constructor (Constructor! c) {
+ c.accept_children (this);
+ }
+
+ public override void visit_destructor (Destructor! d) {
+ d.accept_children (this);
+ }
+
public override void visit_namespace_reference (NamespaceReference! ns) {
ns.namespace_symbol = current_scope.lookup (ns.name);
if (ns.namespace_symbol == null) {