}
if (!first) {
- if (en.get_methods ().size > 0) {
+ if (en.get_methods ().size > 0 || en.get_constants ().size > 0) {
write_string (";");
}
write_newline ();
foreach (Method m in en.get_methods ()) {
m.accept (this);
}
+ foreach (Constant c in en.get_constants ()) {
+ c.accept (this);
+ }
current_scope = current_scope.parent_scope;
write_end_block ();
private List<EnumValue> values = new ArrayList<EnumValue> ();
private List<Method> methods = new ArrayList<Method> ();
+ private List<Constant> constants = new ArrayList<Constant> ();
private string cname;
private string cprefix;
private string lower_case_cprefix;
scope.add (m.name, m);
}
+ /**
+ * Adds the specified constant as a member to this enum.
+ *
+ * @param c a constant
+ */
+ public void add_constant (Constant c) {
+ constants.add (c);
+ scope.add (c.name, c);
+ }
+
/**
* Returns a copy of the list of enum values.
*
return methods;
}
+ /**
+ * Returns a copy of the list of constants.
+ *
+ * @return list of constants
+ */
+ public List<Constant> get_constants () {
+ return constants;
+ }
+
public override void accept (CodeVisitor visitor) {
visitor.visit_enum (this);
}
foreach (Method m in methods) {
m.accept (visitor);
}
+
+ foreach (Constant c in constants) {
+ c.accept (visitor);
+ }
}
public override string get_cname (bool const_type = false) {
m.check (analyzer);
}
+ foreach (Constant c in constants) {
+ c.check (analyzer);
+ }
+
analyzer.current_source_file = old_source_file;
analyzer.current_symbol = old_symbol;
var member_sym = parse_declaration ();
if (member_sym is Method) {
en.add_method ((Method) member_sym);
+ } else if (member_sym is Constant) {
+ en.add_constant ((Constant) member_sym);
} else {
Report.error (member_sym.source_reference, "unexpected declaration in enum");
}