Added support for ISourcePawnEngine natives.
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"
23 #include "NameBinding.h"
27 class Scope : public PoolObject
30 PoolList<BoundName *> names_;
31 PoolList<Scope *> children_;
32 PoolList<Variable *> parameters_;
34 unsigned maxContainedLocals_;
35 unsigned numFunctions_;
40 return names_.length() == 0;
52 Scope(PoolAllocator &pool, Kind kind, Scope *enclosing);
58 Scope *enclosing() const {
61 unsigned locals() const {
64 unsigned maxContainedLocals() const {
65 return maxContainedLocals_;
67 unsigned numFunctions() const {
70 unsigned numNatives() const {
73 unsigned numArguments() const {
74 return parameters_.length();
76 Variable *getArgument(size_t index) {
77 return parameters_[index];
79 Variable *lifoSlot() {
82 void setUsesLifoHeap();
84 Scope *unlinkIfEmpty();
85 BoundName *localLookup(Handle<String> name);
86 BoundName *lookup(Handle<String> name);
88 NamedFunction *declareFunction(Handle<String> name, const SourcePosition &pos, TokenKind token);
89 Variable *declareVariable(Handle<String> name, const SourcePosition &pos);
90 Variable *declareArgument(Handle<String> name, const SourcePosition &pos);
91 NamedEnum *declareEnum(Handle<String> name, const SourcePosition &pos);
92 NamedConstant *declareConstant(Handle<String> name, const SourcePosition &pos);
94 void allocate(Variable *var);
96 void allocateGlobals();
99 static bool Bind(ParseTree *tree);
100 static void Allocate(ParseTree *tree);
109 #endif // _include_jitcraft_scopes_h_