var sym = node as Symbol;
if (sym != null) {
if (sym is Constant && !(sym is EnumValue)) {
+ if (sym.parent_symbol is Block) {
+ // local constant
+ return sym.name;
+ }
return "%s%s".printf (CCodeBaseModule.get_ccode_lower_case_prefix (sym.parent_symbol).up (), sym.name);
} else if (sym is Field) {
if (((Field) sym).binding == MemberBinding.STATIC) {
if (source_reference != null) {
context.analyzer.current_source_file = source_reference.file;
}
- context.analyzer.current_symbol = this;
+ if (!(parent_symbol is Block)) {
+ // non-local constant
+ context.analyzer.current_symbol = this;
+ }
type_reference.check (context);
public Method? current_method {
get {
unowned Symbol sym = current_symbol;
- while (sym is Block || sym is Constant) {
+ while (sym is Block) {
sym = sym.parent_symbol;
}
return sym as Method;
public Method? current_async_method {
get {
unowned Symbol sym = current_symbol;
- while (sym is Block || sym is Constant || sym is Method) {
+ while (sym is Block || sym is Method) {
var m = sym as Method;
if (m != null && m.coroutine) {
break;
public PropertyAccessor? current_property_accessor {
get {
unowned Symbol sym = current_symbol;
- while (sym is Block || sym is Constant) {
+ while (sym is Block) {
sym = sym.parent_symbol;
}
return sym as PropertyAccessor;
public Symbol? current_method_or_property_accessor {
get {
unowned Symbol sym = current_symbol;
- while (sym is Block || sym is Constant) {
+ while (sym is Block) {
sym = sym.parent_symbol;
}
if (sym is Method) {
}
public Method? find_parent_method (Symbol sym) {
- while (sym is Block || sym is Constant) {
+ while (sym is Block) {
sym = sym.parent_symbol;
}
return sym as Method;
}
public Symbol? find_parent_method_or_property_accessor (Symbol sym) {
- while (sym is Block || sym is Constant) {
+ while (sym is Block) {
sym = sym.parent_symbol;
}
if (sym is Method) {
public override void visit_constant (Constant c) {
var old_scope = current_scope;
- current_scope = c.scope;
+ if (!(c.parent_symbol is Block)) {
+ // non-local constant
+ current_scope = c.scope;
+ }
c.accept_children (this);