Convert AST std::vector to PoolList.
Convert AST std::vector to PoolList.
1.1 --- a/jitcraft/AST.h Sat Jul 07 20:58:13 2012 -0700
1.2 +++ b/jitcraft/AST.h Sat Jul 07 21:01:39 2012 -0700
1.3 @@ -21,7 +21,6 @@
1.4 #include "PoolAllocator.h"
1.5 #include "Token.h"
1.6 #include "NameBinding.h"
1.7 -#include <vector>
1.8 #include "Vector.h"
1.9
1.10 namespace jc {
1.11 @@ -612,7 +611,7 @@
1.12 }
1.13 };
1.14
1.15 -typedef std::vector<Parameter *> ParameterList;
1.16 +typedef PoolList<Parameter *> ParameterList;
1.17
1.18 class FunctionStatement : public Statement
1.19 {
1.20 @@ -703,7 +702,7 @@
1.21 }
1.22 };
1.23
1.24 - typedef std::vector<Entry> EntryList;
1.25 + typedef PoolList<Entry> EntryList;
1.26
1.27 public:
1.28 EnumStatement(const SourcePosition &pos, Handle<String> name, EntryList *entries)
1.29 @@ -764,7 +763,7 @@
1.30
1.31 class Scope;
1.32
1.33 -typedef std::vector<NameProxy *> NameProxyList;
1.34 +typedef PoolList<NameProxy *> NameProxyList;
1.35
1.36 class ParseTree : public PoolObject
1.37 {
2.1 --- a/jitcraft/Parser.cpp Sat Jul 07 20:58:13 2012 -0700
2.2 +++ b/jitcraft/Parser.cpp Sat Jul 07 21:01:39 2012 -0700
2.3 @@ -33,7 +33,7 @@
2.4 scope_(NULL),
2.5 unbound_(NULL)
2.6 {
2.7 - unbound_ = new std::vector<NameProxy *>();
2.8 + unbound_ = new (pool_) PoolList<NameProxy *>();
2.9 }
2.10
2.11 bool
2.12 @@ -69,8 +69,8 @@
2.13 {
2.14 BoundName *bound = scope_->lookup(name);
2.15 NameProxy *proxy = new (pool_) NameProxy(scanner_.begin(), name, bound);
2.16 - if (!bound)
2.17 - unbound_->push_back(proxy);
2.18 + if (!bound && !unbound_->append(proxy))
2.19 + return NULL;
2.20 return proxy;
2.21 }
2.22
2.23 @@ -804,7 +804,7 @@
2.24 return NULL;
2.25 }
2.26
2.27 - EnumStatement::EntryList *entries = new EnumStatement::EntryList();
2.28 + EnumStatement::EntryList *entries = new (pool_) EnumStatement::EntryList();
2.29
2.30 if (!expect(TOK_LBRACE))
2.31 return NULL;
2.32 @@ -832,7 +832,8 @@
2.33 return NULL;
2.34 }
2.35
2.36 - entries->push_back(EnumStatement::Entry(constant, expr));
2.37 + if (!entries->append(EnumStatement::Entry(constant, expr)))
2.38 + return NULL;
2.39 } while (match(TOK_COMMA));
2.40 if (!expect(TOK_RBRACE))
2.41 return NULL;
2.42 @@ -864,7 +865,7 @@
2.43 if (!scope)
2.44 return NULL;
2.45
2.46 - ParameterList *parameters = new ParameterList();
2.47 + ParameterList *parameters = new (pool_) ParameterList();
2.48
2.49 if (!expect(TOK_LPAREN))
2.50 return NULL;
2.51 @@ -886,7 +887,8 @@
2.52
2.53 Local<String> tag(zone_);
2.54 Parameter *parameter = new (pool_) Parameter(arg, tag, ref);
2.55 - parameters->push_back(parameter);
2.56 + if (!parameters->append(parameter))
2.57 + return NULL;
2.58
2.59 if (!match(TOK_COMMA))
2.60 break;
2.61 @@ -1080,7 +1082,7 @@
2.62 prefix();
2.63 fprintf(fp_, "[ EnumStatement (%s)\n", node->name() ? node->name()->chars() : "<anonymous>");
2.64 indent();
2.65 - for (size_t i = 0; i < node->entries()->size(); i++) {
2.66 + for (size_t i = 0; i < node->entries()->length(); i++) {
2.67 prefix();
2.68 fprintf(fp_, "%s =\n", node->entries()->at(i).name->name()->chars());
2.69 if (node->entries()->at(i).expr) {
3.1 --- a/jitcraft/Parser.h Sat Jul 07 20:58:13 2012 -0700
3.2 +++ b/jitcraft/Parser.h Sat Jul 07 21:01:39 2012 -0700
3.3 @@ -34,7 +34,7 @@
3.4 PoolAllocator &pool_;
3.5 Scanner scanner_;
3.6 Scope *scope_;
3.7 - std::vector<NameProxy *> *unbound_;
3.8 + PoolList<NameProxy *> *unbound_;
3.9
3.10 private:
3.11 void redeclarationError(BoundName *name);
4.1 --- a/jitcraft/Scopes.cpp Sat Jul 07 20:58:13 2012 -0700
4.2 +++ b/jitcraft/Scopes.cpp Sat Jul 07 21:01:39 2012 -0700
4.3 @@ -192,7 +192,7 @@
4.4 Scope::Bind(ParseTree *tree)
4.5 {
4.6 Local<String> name(ZONE());
4.7 - for (size_t i = 0; i < tree->unbound()->size(); i++) {
4.8 + for (size_t i = 0; i < tree->unbound()->length(); i++) {
4.9 NameProxy *proxy = tree->unbound()->at(i);
4.10 name = proxy->name();
4.11 BoundName *binding = tree->scope()->lookup(name);
5.1 --- a/jitcraft/SemanticAnalysis.cpp Sat Jul 07 20:58:13 2012 -0700
5.2 +++ b/jitcraft/SemanticAnalysis.cpp Sat Jul 07 21:01:39 2012 -0700
5.3 @@ -523,12 +523,12 @@
5.4 bool
5.5 SemanticAnalysis::preanalyze(FunctionStatement *node)
5.6 {
5.7 - Local<FixedArray> args(zone_, FixedArray::New(zone_, node->parameters()->size(), Heap::Tenure_Old));
5.8 + Local<FixedArray> args(zone_, FixedArray::New(zone_, node->parameters()->length(), Heap::Tenure_Old));
5.9 if (!args)
5.10 return false;
5.11
5.12 // Apply types to arguments.
5.13 - for (size_t i = 0; i < node->parameters()->size(); i++) {
5.14 + for (size_t i = 0; i < node->parameters()->length(); i++) {
5.15 Parameter *parameter = node->parameters()->at(i);
5.16
5.17 Local<String> tag(zone_, parameter->tag());
5.18 @@ -767,7 +767,7 @@
5.19 return;
5.20
5.21 int value = 0;
5.22 - for (size_t i = 0; i < node->entries()->size(); i++) {
5.23 + for (size_t i = 0; i < node->entries()->length(); i++) {
5.24 EnumStatement::Entry &entry = node->entries()->at(i);
5.25
5.26 BoxedPrimitive box = BoxedPrimitive::Int(value);