public Symbol root_symbol;
public Symbol current_symbol;
- public DataType current_return_type;
public TryStatement current_try;
+ public TypeSymbol? current_type_symbol {
+ get {
+ var sym = current_symbol;
+ while (sym != null) {
+ if (sym is TypeSymbol) {
+ return (TypeSymbol) sym;
+ }
+ sym = sym.parent_symbol;
+ }
+ return null;
+ }
+ }
+
+ public Class? current_class {
+ get { return current_type_symbol as Class; }
+ }
+
public Method? current_method {
get {
var sym = current_symbol;
}
}
- public TypeSymbol? current_type_symbol {
+ public DataType? current_return_type {
get {
- var sym = current_symbol;
- while (sym != null) {
- if (sym is TypeSymbol) {
- return (TypeSymbol) sym;
+ var m = current_method;
+ if (m != null) {
+ return m.return_type;
+ }
+
+ var acc = current_property_accessor;
+ if (acc != null) {
+ if (acc.readable) {
+ return acc.value_type;
+ } else {
+ return void_type;
}
- sym = sym.parent_symbol;
}
+
return null;
}
}
- public Class? current_class {
- get { return current_type_symbol as Class; }
- }
-
public CCodeDeclarationSpace header_declarations;
public CCodeDeclarationSpace internal_header_declarations;
public CCodeDeclarationSpace source_declarations;
public bool current_method_inner_error = false;
public int next_coroutine_state = 1;
+ public DataType void_type = new VoidType ();
public DataType bool_type;
public DataType char_type;
public DataType uchar_type;
bool returns_real_struct = prop.property_type.is_real_struct_type ();
- var old_return_type = current_return_type;
- if (acc.readable && !returns_real_struct) {
- current_return_type = acc.value_type;
- } else {
- current_return_type = new VoidType ();
- }
-
acc.accept_children (codegen);
var t = (ObjectTypeSymbol) prop.parent_symbol;
}
current_symbol = old_symbol;
- current_return_type = old_return_type;
current_method_inner_error = old_method_inner_error;
}
public override void visit_method (Method m) {
var old_symbol = current_symbol;
- DataType old_return_type = current_return_type;
bool old_method_inner_error = current_method_inner_error;
bool old_in_creation_method = in_creation_method;
int old_next_temp_var_id = next_temp_var_id;
var old_variable_name_map = variable_name_map;
var old_try = current_try;
current_symbol = m;
- current_return_type = m.return_type;
current_method_inner_error = false;
next_temp_var_id = 0;
temp_vars = new ArrayList<LocalVariable> ();
bool inner_error = current_method_inner_error;
current_symbol = old_symbol;
- current_return_type = old_return_type;
current_method_inner_error = old_method_inner_error;
next_temp_var_id = old_next_temp_var_id;
temp_vars = old_temp_vars;
var old_source_file = analyzer.current_source_file;
var old_symbol = analyzer.current_symbol;
- var old_return_type = analyzer.current_return_type;
if (source_reference != null) {
analyzer.current_source_file = source_reference.file;
}
analyzer.current_symbol = this;
- analyzer.current_return_type = return_type;
foreach (FormalParameter param in get_parameters()) {
param.check (analyzer);
analyzer.current_source_file = old_source_file;
analyzer.current_symbol = old_symbol;
- analyzer.current_return_type = old_return_type;
-
- if (analyzer.current_symbol.parent_symbol is Method) {
- /* lambda expressions produce nested methods */
- var up_method = (Method) analyzer.current_symbol.parent_symbol;
- analyzer.current_return_type = up_method.return_type;
- }
if (is_abstract || is_virtual || overrides) {
Report.error (source_reference, "The creation method `%s' cannot be marked as override, virtual, or abstract".printf (get_full_name ()));
var old_source_file = analyzer.current_source_file;
var old_symbol = analyzer.current_symbol;
- var old_return_type = analyzer.current_return_type;
if (source_reference != null) {
analyzer.current_source_file = source_reference.file;
}
analyzer.current_symbol = this;
- analyzer.current_return_type = return_type;
return_type.check (analyzer);
analyzer.current_source_file = old_source_file;
analyzer.current_symbol = old_symbol;
- analyzer.current_return_type = old_return_type;
- if (analyzer.current_symbol.parent_symbol is Method) {
- /* lambda expressions produce nested methods */
- var up_method = (Method) analyzer.current_symbol.parent_symbol;
- analyzer.current_return_type = up_method.return_type;
- }
-
- if (analyzer.current_symbol is Struct) {
+ if (analyzer.current_struct != null) {
if (is_abstract || is_virtual || overrides) {
Report.error (source_reference, "A struct member `%s' cannot be marked as override, virtual, or abstract".printf (get_full_name ()));
return false;
}
var old_symbol = analyzer.current_symbol;
- var old_return_type = analyzer.current_return_type;
analyzer.current_symbol = this;
- if (readable) {
- analyzer.current_return_type = value_type;
- } else {
- // void
- analyzer.current_return_type = new VoidType ();
- }
if (!prop.external_package) {
if (body == null && !prop.interface_only && !prop.is_abstract) {
}
analyzer.current_symbol = old_symbol;
- analyzer.current_return_type = old_return_type;
return !error;
}
public Symbol root_symbol;
public Symbol current_symbol { get; set; }
public SourceFile current_source_file { get; set; }
- public DataType current_return_type;
public TypeSymbol? current_type_symbol {
get {
get { return current_type_symbol as Struct; }
}
+ public Method? current_method {
+ get {
+ var sym = current_symbol;
+ while (sym is Block) {
+ sym = sym.parent_symbol;
+ }
+ return sym as Method;
+ }
+ }
+
+ public PropertyAccessor? current_property_accessor {
+ get {
+ var sym = current_symbol;
+ while (sym is Block) {
+ sym = sym.parent_symbol;
+ }
+ return sym as PropertyAccessor;
+ }
+ }
+
+ public DataType? current_return_type {
+ get {
+ var m = current_method;
+ if (m != null) {
+ return m.return_type;
+ }
+
+ var acc = current_property_accessor;
+ if (acc != null) {
+ if (acc.readable) {
+ return acc.value_type;
+ } else {
+ return void_type;
+ }
+ }
+
+ return null;
+ }
+ }
+
public Block insert_block;
+ public DataType void_type = new VoidType ();
public DataType bool_type;
public DataType string_type;
public DataType uchar_type;