Implement dependent char arrays.
2 * Copyright (C) 2012 David Anderson
4 * This file is part of JITCraft.
6 * JITCraft is free software: you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
11 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * JITCraft. If not, see http://www.gnu.org/licenses/.
18 #ifndef _include_jitcraft_scopes_h_
19 #define _include_jitcraft_scopes_h_
21 #include "../PoolAllocator.h"
22 #include "../Structures.h"
24 #include "NameBinding.h"
32 class Scope : public PoolObject
36 PoolList<Symbol *> names_;
37 PoolList<Scope *> children_;
40 return names_.length() == 0;
53 Scope(PoolAllocator &pool, Kind kind, Scope *enclosing);
59 Scope *enclosing() const {
63 bool addSymbol(Symbol *symbol);
65 Scope *unlinkIfEmpty();
66 Symbol *localLookup(Handle<String> name);
67 Symbol *lookup(Handle<String> name);
69 EnvironmentMap *createEnvironmentMap(Zone *zone);
71 void setParent(Scope *parent) {
72 assert(!enclosing_ || enclosing_ == parent);
81 class ArgumentScope : public Scope
84 static ArgumentScope *New(PoolAllocator &pool);
87 ArgumentScope(PoolAllocator &pool);
90 class LocalScope : public Scope
93 static LocalScope *New(PoolAllocator &pool);
96 LocalScope(PoolAllocator &pool);
99 class GlobalScope : public Scope
102 static GlobalScope *New(PoolAllocator &pool, ImportScope *parent);
104 bool addPublic(Symbol *symbol);
105 Symbol *findPublic(Handle<String> name);
106 Struct *build(Zone *zone);
109 GlobalScope(PoolAllocator &pool, ImportScope *parent);
112 PoolList<Symbol *> publics_;
115 class ImportScope : public Scope
118 static ImportScope *New(PoolAllocator &pool);
121 ImportScope(PoolAllocator &pool);
126 #endif // _include_jitcraft_scopes_h_