mirror of https://github.com/aamine/cbc
* net/loveruby/cflat/ast/ToplevelScope.java: use SemanticException instead of SemanticError for duplicated declarations/definitions.
git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4098 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
b469db1b82
commit
545515b5e0
|
|
@ -1,3 +1,12 @@
|
|||
Sun Dec 7 17:09:17 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/ast/ToplevelScope.java: use SemanticException
|
||||
instead of SemanticError for duplicated declarations/definitions.
|
||||
|
||||
Sun Dec 7 17:08:26 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test: test declaration override (error path).
|
||||
|
||||
Sun Dec 7 16:55:56 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* test: test declaration override.
|
||||
|
|
|
|||
|
|
@ -28,21 +28,25 @@ public class ToplevelScope extends Scope {
|
|||
|
||||
/** Declare variable or function globally. */
|
||||
// #@@range/declareEntity{
|
||||
public void declareEntity(Entity ent) {
|
||||
if (entities.containsKey(ent.name())) {
|
||||
throw new Error("duplicated declaration: " + ent.name());
|
||||
public void declareEntity(Entity entity) throws SemanticException {
|
||||
Entity e = entities.get(entity.name());
|
||||
if (e != null) {
|
||||
throw new SemanticException("duplicated declaration: " +
|
||||
entity.name() + ": " +
|
||||
e.location() + " and " + entity.location());
|
||||
}
|
||||
entities.put(ent.name(), ent);
|
||||
entities.put(entity.name(), entity);
|
||||
}
|
||||
// #@@}
|
||||
|
||||
/** Define variable or function globally. */
|
||||
// #@@range/defineEntity{
|
||||
public void defineEntity(Entity entity) {
|
||||
Entity ent = entities.get(entity.name());
|
||||
if (ent != null && ent.isDefined()) {
|
||||
throw new Error("duplicated definition: " + entity.name() + ": " +
|
||||
ent.location() + " and " + entity.location());
|
||||
public void defineEntity(Entity entity) throws SemanticException {
|
||||
Entity e = entities.get(entity.name());
|
||||
if (e != null && e.isDefined()) {
|
||||
throw new SemanticException("duplicated definition: " +
|
||||
entity.name() + ": " +
|
||||
e.location() + " and " + entity.location());
|
||||
}
|
||||
entities.put(entity.name(), entity);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue