Skip to content
Browse files

Merge branch 'no-boost'

  • Loading branch information...
2 parents 3c1b32a + bd6028b commit 3203d4a5e9901ca41a794620199d0d055adb97a3 @tokuhirom committed Dec 23, 2013
View
2 CMakeLists.txt
@@ -92,7 +92,7 @@ SET(TORA_SRCS
tora/object/env.cc tora/object/regexp.cc tora/value/code.cc
)
-set(libs re2 pthread dl icudata icuuc boost_system)
+set(libs re2 pthread dl icudata icuuc)
# libtora.a
ADD_LIBRARY(libtora_a ${TORA_SRCS})
View
9 tora/compiler.cc
@@ -7,9 +7,6 @@
#include "value/regexp.h"
#include "symbol_table.h"
#include "disasm.h"
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-#include <boost/shared_ptr.hpp>
#include <iostream>
using namespace tora;
@@ -953,7 +950,7 @@ void tora::Compiler::compile(const SharedPtr<Node> &node) {
int label2 = ops->size();
jump_if_false->operand.int_value = label2;
- BOOST_FOREACH(auto n, last_labels) {
+ for (auto n: last_labels) {
*n = label2 - 1;
}
last_labels.clear();
@@ -1208,7 +1205,7 @@ void tora::Compiler::compile(const SharedPtr<Node> &node) {
enter->operand.int_value = this->blocks->back().vars.size();
this->pop_block();
- BOOST_FOREACH(auto n, last_labels) {
+ for (auto n: last_labels) {
*n = label2;
}
last_labels.clear();
@@ -1282,7 +1279,7 @@ void tora::Compiler::compile(const SharedPtr<Node> &node) {
push_op(new OP(OP_LEAVE));
- BOOST_FOREACH(auto n, last_labels) {
+ for (auto n: last_labels) {
*n = label2;
}
last_labels.clear();
View
1 tora/compiler.h
@@ -8,6 +8,7 @@
#include <vector>
#include <string>
#include <memory>
+#include "value/bytes.h"
namespace tora {
View
2 tora/disasm.cc
@@ -36,7 +36,7 @@ void Disasm::disasm(const SharedPtr<OPArray>& ops) {
printf("-- OP DUMP --\n");
for (size_t i=0; i<ops->size(); i++) {
const OP* op = ops->at(i);
- printf("[%03d] %s", i, opcode2name[op->op_type]);
+ printf("[%03zu] %s", i, opcode2name[op->op_type]);
switch (op->op_type) {
case OP_GETDYNAMIC: {
int level = (op->operand.int_value >> 16) & 0x0000FFFF;
View
4 tora/frame.cc
@@ -86,7 +86,3 @@ void LexicalVarsFrame::dump_pad(VM *vm) {
pad_list->dump(vm);
}
-#ifdef ENABLE_OBJECT_POOL
-boost::object_pool<FunctionFrame> FunctionFrame::pool_;
-#endif
-
View
13 tora/frame.h
@@ -3,12 +3,6 @@
#include <vector>
-#ifdef ENABLE_OBJECT_POOL
-#include <boost/pool/object_pool.hpp>
-#endif
-
-#include <boost/shared_ptr.hpp>
-
#include "shared_ptr.h"
#include "inspector.h"
#include "value.h"
@@ -100,13 +94,6 @@ class FunctionFrame : public LexicalVarsFrame {
this->type = FRAME_TYPE_FUNCTION;
}
FunctionFrame(VM *vm, int vars_cnt, size_t top, const SharedPtr<Value>& self_) : LexicalVarsFrame(vm, vars_cnt, top), self(self_) { }
-#ifdef ENABLE_OBJECT_POOL
-public:
- void* operator new(size_t size) { return pool_.malloc(); }
- void operator delete(void* doomed, size_t) { pool_.free((FunctionFrame*)doomed); }
-private:
- static boost::object_pool<FunctionFrame> pool_;
-#endif
};
class ForeachFrame : public LexicalVarsFrame {
View
3 tora/inspector.cc
@@ -6,8 +6,7 @@
#include "value/range.h"
#include "value/object.h"
#include "value/regexp.h"
-
-#include <boost/format.hpp>
+#include "value/bytes.h"
using namespace tora;
View
2 tora/lexer.h
@@ -10,8 +10,6 @@
#include <fstream>
#include <queue>
-#include <boost/shared_ptr.hpp>
-
#include "node.h"
#include "prim.h"
View
4 tora/object.h
@@ -3,7 +3,7 @@
#include "shared_ptr.h"
#include <vector>
-#include <boost/shared_array.hpp>
+#include <memory>
#include <re2/re2.h>
namespace tora {
@@ -40,7 +40,7 @@ void Init_FilePackage(VM *vm);
SharedPtr<Value> Symbol_bless(VM * vm, Value* self, Value *data);
ObjectValue* Dir_new(VM *vm, StrValue *dirname);
SharedPtr<Value> File_open(VM *vm, Value *fname, Value *mode);
-SharedPtr<Value> RE2_Regexp_Matched_new(VM *vm, RE2RegexpValue* re, const boost::shared_array<re2::StringPiece> & matches);
+SharedPtr<Value> RE2_Regexp_Matched_new(VM *vm, RE2RegexpValue* re, const std::shared_ptr<std::vector<re2::StringPiece>> & matches);
void load_builtin_objects(VM *vm);
View
18 tora/object/re2_regexp_matched.cc
@@ -21,14 +21,14 @@ using namespace tora;
class RE2RegexpMatched {
private:
SharedPtr<RE2RegexpValue> re_;
- boost::shared_array<re2::StringPiece> matches_;
+ std::shared_ptr<std::vector<re2::StringPiece>> matches_;
public:
- RE2RegexpMatched(RE2RegexpValue* re, const boost::shared_array<re2::StringPiece> & matches) : re_(re), matches_(matches) {
+ RE2RegexpMatched(RE2RegexpValue* re, const std::shared_ptr<std::vector<re2::StringPiece>> & matches) : re_(re), matches_(matches) {
}
const SharedPtr<RE2RegexpValue>& re() const {
return re_;
}
- boost::shared_array<re2::StringPiece> matches() const {
+ const std::shared_ptr<std::vector<re2::StringPiece>>& matches() const {
return matches_;
}
};
@@ -56,8 +56,8 @@ static SharedPtr<Value> RE2_Regexp_Matched_to_array(VM * vm, Value* self) {
SharedPtr<ArrayValue> ary = new ArrayValue();
const SharedPtr<RE2RegexpValue>& re = SELF(self)->re();
for (int i=0; i<re->number_of_capturing_groups(); i++) {
- re2::StringPiece* res = &(SELF(self)->matches()[i]);
- ary->push_back(new StrValue(std::string(res->data(), res->length())));
+ const re2::StringPiece& res = SELF(self)->matches()->at(i);
+ ary->push_back(new StrValue(std::string(res.data(), res.length())));
}
return ary;
}
@@ -76,9 +76,9 @@ static SharedPtr<Value> RE2_Regexp_Matched_getitem(VM * vm, Value* self, Value *
if (index->to_int() > re->number_of_capturing_groups()) {
return UndefValue::instance();
}
- re2::StringPiece* res = &(SELF(self)->matches()[index->to_int()]);
- if(res->data()) {
- return new StrValue(std::string(res->data(), res->length()));
+ const re2::StringPiece& res = SELF(self)->matches()->at(index->to_int());
+ if(res.data()) {
+ return new StrValue(std::string(res.data(), res.length()));
} else {
return UndefValue::instance();
}
@@ -95,7 +95,7 @@ static SharedPtr<Value> RE2_Regexp_Matched_DESTROY(VM * vm, Value* self) {
return UndefValue::instance();
}
-SharedPtr<Value> tora::RE2_Regexp_Matched_new(VM *vm, RE2RegexpValue* re, const boost::shared_array<re2::StringPiece> & matches) {
+SharedPtr<Value> tora::RE2_Regexp_Matched_new(VM *vm, RE2RegexpValue* re, const std::shared_ptr<std::vector<re2::StringPiece>> & matches) {
return new ObjectValue(vm, vm->get_builtin_class(SYMBOL_RE2_REGEXP_MATCHED_CLASS).get(), new PointerValue(new RE2RegexpMatched(re, matches)));
}
View
1 tora/object/str.cc
@@ -4,6 +4,7 @@
#include "../shared_ptr.h"
#include "../value/regexp.h"
#include "../value/class.h"
+#include "../value/bytes.h"
#include "../symbols.gen.h"
#include <re2/re2.h>
#include <unicode/unistr.h>
View
1 tora/operator.cc
@@ -4,6 +4,7 @@
#include "value/object.h"
#include "value/array.h"
#include "ops.gen.h"
+#include "value/bytes.h"
#include <math.h>
using namespace tora;
View
1 tora/value.cc
@@ -6,6 +6,7 @@
#include "value/double.h"
#include "value/object.h"
#include "value/symbol.h"
+#include "value/bytes.h"
#include "symbols.gen.h"
#include "peek.h"
#include <stdarg.h>
View
11 tora/value.h
@@ -1,5 +1,5 @@
-#ifndef VALUE_H_
-#define VALUE_H_
+#ifndef TORA_VALUE_H_
+#define TORA_VALUE_H_
#include <sstream>
#include <cstdlib>
@@ -13,9 +13,6 @@
#include "tora.h"
#include "shared_ptr.h"
-#include "prim.h"
-#include "util.h"
-#include "op_array.h"
#include "exception.h"
namespace tora {
@@ -57,7 +54,6 @@ class ClassImpl;
class FilePackageImpl;
class CallbackFunction;
-class OPArray;
class RangeImpl {
friend class RangeValue;
@@ -156,10 +152,9 @@ class Value {
#include "value/undef.h"
#include "value/str.h"
-#include "value/bytes.h"
#include "value/bool.h"
#include "value/int.h"
#include "value/double.h"
#include "value/exception.h"
-#endif // VALUE_H_
+#endif // TORA_VALUE_H_
View
5 tora/value/bool.cc
@@ -2,9 +2,4 @@
using namespace tora;
-#ifdef ENABLE_OBJECT_POOL
-
-boost::object_pool<BoolValue> BoolValue::pool_;
-
-#endif
View
11 tora/value/bool.h
@@ -3,10 +3,6 @@
#include "../value.h"
-#ifdef ENABLE_OBJECT_POOL
-#include <boost/pool/object_pool.hpp>
-#endif
-
namespace tora {
class BoolValue: public Value {
@@ -24,13 +20,6 @@ class BoolValue: public Value {
return b ? BoolValue::true_instance() : BoolValue::false_instance();
}
bool bool_value() const { return this->bool_value_; }
-#ifdef ENABLE_OBJECT_POOL
-public:
- void* operator new(size_t size) { return pool_.malloc(); }
- void operator delete(void* doomed, size_t) { pool_.free((BoolValue*)doomed); }
-private:
- static boost::object_pool<BoolValue> pool_;
-#endif
};
};
View
4 tora/value/file_package.h
@@ -8,14 +8,14 @@ namespace tora {
class FilePackageImpl {
public:
ID name_id_;
- boost::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> data_;
+ std::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> data_;
};
class FilePackageValue : public tora::Value {
public:
typedef std::map<ID, SharedPtr<tora::Value>>::const_iterator const_iterator;
- FilePackageValue(ID name_id, const boost::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> & src) : tora::Value(VALUE_TYPE_FILE_PACKAGE) {
+ FilePackageValue(ID name_id, const std::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> & src) : tora::Value(VALUE_TYPE_FILE_PACKAGE) {
this->file_package_value_ = new FilePackageImpl();
this->file_package_value_->name_id_ = name_id;
this->file_package_value_->data_ = src;
View
3 tora/value/int.cc
@@ -2,6 +2,3 @@
using namespace tora;
-#ifdef ENABLE_OBJECT_POOL
-boost::object_pool<IntValue> IntValue::pool_;
-#endif
View
11 tora/value/int.h
@@ -3,10 +3,6 @@
#include "../value.h"
-#ifdef ENABLE_OBJECT_POOL
-#include <boost/pool/object_pool.hpp>
-#endif
-
namespace tora {
class IntValue: public Value {
@@ -39,13 +35,6 @@ class IntValue: public Value {
void int_value(int n) {
VAL() = n;
}
-#ifdef ENABLE_OBJECT_POOL
-public:
- void* operator new(size_t size) { return pool_.malloc(); }
- void operator delete(void* doomed, size_t) { pool_.free((IntValue*)doomed); }
-private:
- static boost::object_pool<IntValue> pool_;
-#endif
};
};
View
14 tora/value/regexp.cc
@@ -1,8 +1,6 @@
#include "regexp.h"
#include "array.h"
#include "../object.h"
-#include <boost/shared_array.hpp>
-#include <boost/scoped_array.hpp>
using namespace tora;
@@ -30,10 +28,10 @@ RE2RegexpValue::~RE2RegexpValue() {
}
SharedPtr<Value> RE2RegexpValue::match(VM *vm, const std::string &str) {
- boost::shared_array<re2::StringPiece> res(new re2::StringPiece[VAL()->NumberOfCapturingGroups() + 1]);
+ std::shared_ptr<std::vector<re2::StringPiece>> res(new std::vector<re2::StringPiece>(VAL()->NumberOfCapturingGroups() + 1));
if (VAL()->Match(
- str, 0, str.size(), RE2::UNANCHORED, res.get(), VAL()->NumberOfCapturingGroups()+1
+ str, 0, str.size(), RE2::UNANCHORED, res->data(), VAL()->NumberOfCapturingGroups()+1
)) {
return tora::RE2_Regexp_Matched_new(vm, this, res);
} else {
@@ -42,10 +40,10 @@ SharedPtr<Value> RE2RegexpValue::match(VM *vm, const std::string &str) {
}
bool RE2RegexpValue::match_bool(VM *vm, const std::string &str) {
- boost::shared_array<re2::StringPiece> res(new re2::StringPiece[VAL()->NumberOfCapturingGroups() + 1]);
+ std::vector<re2::StringPiece> res(VAL()->NumberOfCapturingGroups() + 1);
if (VAL()->Match(
- str, 0, str.size(), RE2::UNANCHORED, res.get(), VAL()->NumberOfCapturingGroups()+1
+ str, 0, str.size(), RE2::UNANCHORED, res.data(), VAL()->NumberOfCapturingGroups()+1
)) {
return true;
} else {
@@ -54,13 +52,13 @@ bool RE2RegexpValue::match_bool(VM *vm, const std::string &str) {
}
SharedPtr<Value> RE2RegexpValue::scan(VM *vm, const std::string &str) {
- boost::scoped_array<re2::StringPiece> buf(new re2::StringPiece[VAL()->NumberOfCapturingGroups() + 1]);
+ std::vector<re2::StringPiece> buf(VAL()->NumberOfCapturingGroups() + 1);
int start = 0;
int end = str.size();
SharedPtr<ArrayValue> res = new ArrayValue();
- while (VAL()->Match(str, start, end, RE2::UNANCHORED, buf.get(), VAL()->NumberOfCapturingGroups()+1)) {
+ while (VAL()->Match(str, start, end, RE2::UNANCHORED, buf.data(), VAL()->NumberOfCapturingGroups()+1)) {
if (VAL()->NumberOfCapturingGroups() != 0) {
SharedPtr<ArrayValue> av = new ArrayValue();
for (int i=1; i< VAL()->NumberOfCapturingGroups()+1; i++) {
View
18 tora/vm.cc
@@ -24,9 +24,6 @@
#include "builtin.h"
-#include <boost/scope_exit.hpp>
-#include <boost/foreach.hpp>
-
#include "lexer.h"
#include "parser.class.h"
#include "compiler.h"
@@ -293,21 +290,18 @@ void VM::require_package(const std::string &package) {
SharedPtr<tora::Value> realfilename_value(new StrValue(realfilename));
std::ifstream ifs(realfilename.c_str());
if (ifs.is_open()) {
- boost::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> orig_file_scope(this->file_scope_);
- boost::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> file_scope_tmp(new std::map<ID, SharedPtr<Value>>);
+ std::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> orig_file_scope(this->file_scope_);
+ std::shared_ptr<std::map<ID, SharedPtr<tora::Value>>> file_scope_tmp(new std::map<ID, SharedPtr<Value>>);
VM *vm = this;
- BOOST_SCOPE_EXIT( (&vm) (&orig_file_scope) ) {
- vm->file_scope_ = orig_file_scope;
- }
- BOOST_SCOPE_EXIT_END
- ;
this->file_scope_map_.insert(
- std::map<ID, boost::shared_ptr<std::map<ID, SharedPtr<Value>>>>::value_type(symbol_table->get_id(package), file_scope_tmp)
+ std::map<ID, std::shared_ptr<std::map<ID, SharedPtr<Value>>>>::value_type(symbol_table->get_id(package), file_scope_tmp)
);
this->file_scope_ = file_scope_tmp;
(void)vm->eval(&ifs, realfilename);
required->set_item(new StrValue(s), realfilename_value);
+
+ vm->file_scope_ = orig_file_scope;
return;
} else {
required->set_item(new StrValue(s), UndefValue::instance());
@@ -444,7 +438,7 @@ void VM::register_standard_methods() {
}
void VM::copy_all_public_symbols(ID srcid) {
- boost::shared_ptr<std::map<ID, SharedPtr<Value>>> src(this->file_scope_map_[srcid]);
+ std::shared_ptr<std::map<ID, SharedPtr<Value>>> src(this->file_scope_map_[srcid]);
for (auto iter = src->begin(); iter != src->end(); iter++) {
this->file_scope_->insert(file_scope_body_t::value_type(iter->first, iter->second));
View
1 tora/vm.gen.pl
@@ -75,7 +75,6 @@ sub vm_gen_cc {
#include <algorithm>
#include <functional>
#include <sys/stat.h>
-#include <boost/scoped_ptr.hpp>
using namespace tora;
? for my $k (@{$_[0]}) {
View
6 tora/vm.h
@@ -20,8 +20,6 @@ int swprintf (wchar_t *, size_t, const wchar_t *, ...);
#include "op_array.h"
#include "callback.h"
-#include <boost/shared_ptr.hpp>
-
namespace tora {
const int GLOBAL_VAR_ARGV = 0;
@@ -44,8 +42,8 @@ class VM {
SharedPtr<ClassValue> klass_;
bool dump_ops_;
typedef std::map<ID, SharedPtr<Value>> file_scope_body_t;
- boost::shared_ptr<file_scope_body_t> file_scope_;
- std::map<ID, boost::shared_ptr<std::map<ID, SharedPtr<Value>>>> file_scope_map_;
+ std::shared_ptr<file_scope_body_t> file_scope_;
+ std::map<ID, std::shared_ptr<std::map<ID, SharedPtr<Value>>>> file_scope_map_;
std::map<ID, SharedPtr<ClassValue>> builtin_classes_;
std::map<ID, SharedPtr<CodeValue>> builtin_functions_;
public:

0 comments on commit 3203d4a

Please sign in to comment.
Something went wrong with that request. Please try again.