Mercurial > projects > dil
diff trunk/src/dil/Scope.d @ 562:b0533550d64c
Added semantic() to VariableDeclaration.
Renamed member type to typeNode in VariableDeclaration.
Added insert() and error() to class Scope.
Made class SymbolTable a struct.
Added insert() and lookup() to ScopeSymbol.
Added insert() to Aggregate.
Added semantic() to TypeNode.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 28 Dec 2007 17:48:47 +0100 |
parents | 709e223a8eb9 |
children | 3c867a683258 |
line wrap: on
line diff
--- a/trunk/src/dil/Scope.d Wed Dec 26 23:38:16 2007 +0100 +++ b/trunk/src/dil/Scope.d Fri Dec 28 17:48:47 2007 +0100 @@ -38,6 +38,16 @@ } + /// Insert a new variable symbol into this scope. + void insert(Variable var) + { + auto sym = symbol.lookup(var.ident); + if (sym) + error("variable '"~var.ident.str~"' conflicts with another definition in its scope"); + else + symbol.insert(var, var.ident); + } + /++ Create a new inner scope. +/ @@ -87,7 +97,12 @@ void error(Token* token, MID mid) { auto location = token.getLocation(); - auto error = new SemanticError(location, GetMsg(mid)); -// infoMan.add(error); + infoMan ~= new SemanticError(location, GetMsg(mid)); + } + + void error(char[] msg) + { + auto location = new Location("", 0); + infoMan ~= new SemanticError(location, msg); } }