Implement re-tag unary expression.
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"
24 #include "Structures.h"
31 class Scope : public PoolObject
34 PoolList<BoundName *> names_;
35 PoolList<Scope *> children_;
36 PoolList<Variable *> parameters_;
38 unsigned maxContainedLocals_;
39 unsigned numFunctions_;
41 PoolList<Variable *> envVars_;
45 return names_.length() == 0;
57 Scope(PoolAllocator &pool, Kind kind, Scope *enclosing);
63 Scope *enclosing() const {
66 unsigned locals() const {
69 unsigned maxContainedLocals() const {
70 return maxContainedLocals_;
72 unsigned numFunctions() const {
75 unsigned numNatives() const {
78 unsigned numArguments() const {
79 return parameters_.length();
81 unsigned numEnvironmentVars() const {
82 return envVars_.length();
84 Variable *getArgument(size_t index) {
85 return parameters_[index];
87 Variable *lifoSlot() {
90 void setUsesLifoHeap();
92 Scope *unlinkIfEmpty();
93 BoundName *localLookup(Handle<String> name);
94 BoundName *lookup(Handle<String> name);
96 NamedFunction *declareFunction(Handle<String> name, const SourcePosition &pos, TokenKind token);
97 Variable *declareVariable(Handle<String> name, const SourcePosition &pos);
98 Variable *declareArgument(Handle<String> name, const SourcePosition &pos);
99 NamedEnum *declareEnum(Handle<String> name, const SourcePosition &pos);
100 NamedConstant *declareConstant(Handle<String> name, const SourcePosition &pos);
102 EnvironmentMap *createEnvironmentMap(Zone *zone);
104 void allocate(Variable *var);
106 void allocateGlobals();
109 static bool Bind(CompileContext &cc, ParseTree *tree);
110 static void Allocate(ParseTree *tree);
119 #endif // _include_jitcraft_scopes_h_