# HG changeset patch # User Aziz K?ksal # Date 1198877552 -3600 # Node ID 3c867a683258f00e6940383e0509cafd50d640ea # Parent c838ed7f2ac93eca81a1f6e1af57c290b00d3e3b Fixed VariableDeclaration.semantic(). diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/dil/Declarations.d --- a/trunk/src/dil/Declarations.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/dil/Declarations.d Fri Dec 28 22:32:32 2007 +0100 @@ -15,6 +15,7 @@ import dil.Semantics; import dil.Symbols; import dil.TypeSystem; +import common; abstract class Declaration : Node { @@ -31,8 +32,11 @@ void semantic(Scope sc) { foreach (node; this.children) + { + assert(node !is null); if (node.category == NodeCategory.Declaration) (cast(Declaration)cast(void*)node).semantic(sc); + } } final bool isStatic() @@ -463,7 +467,8 @@ foreach (i, ident; idents) { // Perform semantic analysis on value. - values[i] = values[i].semantic(scop); + if (values[i]) + values[i] = values[i].semantic(scop); // Create a new variable symbol. auto variable = new Variable(stc, linkageType, type, ident, this); variables ~= variable; diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/dil/Location.d --- a/trunk/src/dil/Location.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/dil/Location.d Fri Dec 28 22:32:32 2007 +0100 @@ -4,6 +4,7 @@ +/ module dil.Location; import dil.LexerFuncs; +import dil.Unicode; import common; final class Location @@ -40,7 +41,6 @@ void set(size_t lineNum, char* lineBegin, char* to) { - assert(lineBegin !is null && to !is null); assert(lineBegin <= to); this.lineNum = lineNum; this.lineBegin = lineBegin; @@ -61,13 +61,15 @@ { uint col; auto p = lineBegin; + if (!p) + return 0; for (; p <= to; ++p) { assert(delegate () { // Check that there is no newline between p and to. // But 'to' may point to a newline. - if (p != to && (*p == '\n' || *p == '\r')) + if (p != to && isNewline(*p)) return false; if (to-p >= 2 && isUnicodeNewline(p)) return false; @@ -76,7 +78,7 @@ ); // Skip this byte if it is a trail byte of a UTF-8 sequence. - if ((*p & 0xC0) == 0x80) + if (isTrailByte(*p)) continue; // *p == 0b10xx_xxxx // Only count ASCII characters and the first byte of a UTF-8 sequence. ++col; diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/dil/Module.d --- a/trunk/src/dil/Module.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/dil/Module.d Fri Dec 28 22:32:32 2007 +0100 @@ -91,6 +91,7 @@ // Create module scope. auto scop = new Scope(); scop.symbol = this; // Set this module as the scope's symbol. + scop.infoMan = this.infoMan; this.root.semantic(scop); } diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/dil/Scope.d --- a/trunk/src/dil/Scope.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/dil/Scope.d Fri Dec 28 22:32:32 2007 +0100 @@ -55,6 +55,7 @@ { auto sc = new Scope(); sc.parent = this; + sc.infoMan = this.infoMan; return sc; } diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/dil/SymbolTable.d --- a/trunk/src/dil/SymbolTable.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/dil/SymbolTable.d Fri Dec 28 22:32:32 2007 +0100 @@ -13,7 +13,7 @@ +/ struct SymbolTable { - protected Symbol[char[]] table; + Symbol[char[]] table; /// Look up ident in the table. Symbol lookup(Identifier* ident) diff -r c838ed7f2ac9 -r 3c867a683258 trunk/src/main.d --- a/trunk/src/main.d Fri Dec 28 20:11:58 2007 +0100 +++ b/trunk/src/main.d Fri Dec 28 22:32:32 2007 +0100 @@ -44,7 +44,10 @@ foreach (filePath; filePaths) { auto mod = new Module(filePath, infoMan); + // Parse the file. mod.parse(); + // Start semantic analysis. + mod.semantic(); } foreach (info; infoMan.info)