# HG changeset patch # User Aziz K?ksal # Date 1201714101 -3600 # Node ID 4f971f6382c751ffd724d9fd4d88292f61f90a53 # Parent c89ffd9307279cc214a9fb84009d852099ff3c91 Added enum Status to class Symbol. diff -r c89ffd930727 -r 4f971f6382c7 trunk/src/dil/semantic/Pass2.d --- a/trunk/src/dil/semantic/Pass2.d Tue Jan 29 22:51:44 2008 +0100 +++ b/trunk/src/dil/semantic/Pass2.d Wed Jan 30 18:28:21 2008 +0100 @@ -87,26 +87,35 @@ D visit(EnumDeclaration d) { + d.symbol.setCompleting(); + Type type = Types.Int; // Default to int. if (d.baseType) type = visitT(d.baseType).type; d.symbol.type = new TypeEnum(d.symbol, type); + enterScope(d.symbol); + foreach (member; d.members) { Expression finalValue; + member.symbol.setCompleting(); if (member.value) { member.value = visitE(member.value); finalValue = interpret(member.value); if (finalValue is Interpreter.NAR) - continue; + finalValue = new IntExpression(0, d.symbol.type); } //else // TODO: increment a number variable and assign that to value. + member.symbol.type = d.symbol.type; // Assign TypeEnum. member.symbol.value = finalValue; + member.symbol.setComplete(); } + exitScope(); + d.symbol.setComplete(); return d; } diff -r c89ffd930727 -r 4f971f6382c7 trunk/src/dil/semantic/Symbol.d --- a/trunk/src/dil/semantic/Symbol.d Tue Jan 29 22:51:44 2008 +0100 +++ b/trunk/src/dil/semantic/Symbol.d Wed Jan 30 18:28:21 2008 +0100 @@ -31,10 +31,18 @@ +/ class Symbol { - SYM sid; + enum Status : ushort + { + Declared, /// The symbol has been declared. + Completing, /// The symbol is being processed. + Complete /// The symbol is complete. + } + + SYM sid; /// The ID of this symbol. + Status status; /// The semantic status of this symbol. Symbol parent; /// The parent this symbol belongs to. Identifier* name; /// The name of this symbol. - /// The AST node that produced this symbol. + /// The syntax tree node that produced this symbol. /// Useful for source code location info and retrieval of doc comments. Node node; @@ -45,6 +53,18 @@ this.node = node; } + void setCompleting() + { status = Status.Completing; } + + void setComplete() + { status = Status.Complete; } + + bool isCompleting() + { return status == Status.Completing; } + + bool isComplete() + { return status == Status.Complete; } + // A template macro for building isXYZ() methods. private template isX(char[] kind) {