Added support for fused math-assign ops (+=, etc).
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_
22 #include "PoolAllocator.h"
24 #include "NameBinding.h"
28 class Scope : public PoolObject
31 std::vector<BoundName *> names_;
32 std::vector<Scope *> children_;
33 std::vector<Variable *> parameters_;
35 unsigned maxContainedLocals_;
36 unsigned numFunctions_;
40 return names_.size() == 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 numArguments() const {
71 return parameters_.size();
73 Variable *getArgument(size_t index) {
74 return parameters_[index];
76 Variable *lifoSlot() {
79 void setUsesLifoHeap();
81 Scope *unlinkIfEmpty();
82 BoundName *localLookup(Name *name);
83 BoundName *lookup(Name *name);
84 NamedFunction *declareFunction(Name *name);
85 Variable *declareVariable(Name *name);
86 Variable *declareArgument(Name *name);
87 NamedEnum *declareEnum(Name *name);
88 NamedConstant *declareConstant(Name *name);
89 void allocate(Variable *var);
91 void allocateGlobals();
94 static bool Bind(ParseTree *tree);
95 static void Allocate(ParseTree *tree);
104 #endif // _include_jitcraft_scopes_h_