git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: use 'data' type alias in more places (in runtime)
commitbe026ab35fc69c1be162a9cecac44499122ae710 authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 3 Mar 2016, 18:53 (11 years ago) parentaa8aa3e
2 files changed+15−16
pcc/include/purescript.cc+8−8 pcc/include/purescript.hh+7−8
pcc/include/purescript.cc+8−8
@@ -26,7 +26,7 @@ namespace PureScript {
2626 case Type::StringLiteral: r = src.r; break; \
2727 case Type::String: new (&s) shared<std::string>(src.s); break; \
2828 case Type::Map: new (&m) shared<map>(src.m); break; \
29− case Type::Vector: new (&v) shared<vector>(src.v); break; \
29+ case Type::Data: new (&v) shared<data>(src.v); break; \
3030 case Type::Array: new (&a) shared<array>(src.a); break; \
3131 case Type::Function: f = src.f; break; \
3232 case Type::Closure: new (&l) shared<closure>(src.l); break; \
@@ -46,7 +46,7 @@ namespace PureScript {
4646 case Type::StringLiteral: r = src.r; break; \
4747 case Type::String: new (&s) shared<std::string>(std::move(src.s)); break; \
4848 case Type::Map: new (&m) shared<map>(std::move(src.m)); break; \
49− case Type::Vector: new (&v) shared<vector>(std::move(src.v)); break; \
49+ case Type::Data: new (&v) shared<data>(std::move(src.v)); break; \
5050 case Type::Array: new (&a) shared<array>(std::move(src.a)); break; \
5151 case Type::Function: f = src.f; break; \
5252 case Type::Closure: new (&l) shared<closure>(std::move(src.l)); break; \
@@ -93,7 +93,7 @@ any::~any() {
9393 case Type::StringLiteral: ; break;
9494 case Type::String: s.~shared<std::string>(); break;
9595 case Type::Map: m.~shared<map>(); break;
96− case Type::Vector: v.~shared<vector>(); break;
96+ case Type::Data: v.~shared<data>(); break;
9797 case Type::Array: a.~shared<array>(); break;
9898 case Type::Function: ; break;
9999 case Type::Closure: l.~shared<closure>(); break;
@@ -152,10 +152,10 @@ auto any::cast() const -> typename std::enable_if<std::is_same<T, map>::value, c
152152template auto any::cast<any::map>() const -> const map&;
153153
154154template <typename T>
155−auto any::cast() const -> typename std::enable_if<std::is_same<T, vector>::value, const T&>::type {
156− RETURN_VALUE(Type::Vector, v, *)
155+auto any::cast() const -> typename std::enable_if<std::is_same<T, data>::value, const T&>::type {
156+ RETURN_VALUE(Type::Data, v, *)
157157}
158−template auto any::cast<any::vector>() const -> const vector&;
158+template auto any::cast<any::data>() const -> const data&;
159159
160160template <typename T>
161161auto any::cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type {
@@ -221,8 +221,8 @@ any::operator const map&() const {
221221 return cast<map>();
222222}
223223
224−any::operator const vector&() const {
225− return cast<vector>();
224+any::operator const data&() const {
225+ return cast<data>();
226226}
227227
228228any::operator const array&() const {
pcc/include/purescript.hh+7−8
@@ -73,7 +73,7 @@ class any {
7373 StringLiteral,
7474 String,
7575 Map,
76− Vector,
76+ Data,
7777 Array,
7878 Function,
7979 Closure,
@@ -84,7 +84,6 @@ class any {
8484
8585 private:
8686 mutable Type type = Type::Unknown;
87− using vector = std::vector<any>;
8887
8988 public:
9089 struct as_thunk {
@@ -92,7 +91,7 @@ class any {
9291 static constexpr as_thunk unthunk = as_thunk{};
9392
9493 using map = std::vector<std::pair<const char * const, const any>>;
95− using data = vector;
94+ using data = std::vector<any>;
9695 using array = std::deque<any>;
9796 using fn = auto (*)(const any&) -> any;
9897 using thunk = auto (*)(const as_thunk) -> const any&;
@@ -194,7 +193,7 @@ class any {
194193 mutable string r;
195194 mutable shared<std::string> s;
196195 mutable shared<map> m;
197− mutable shared<vector> v;
196+ mutable shared<data> v;
198197 mutable shared<array> a;
199198 mutable fn f;
200199 mutable shared<closure> l;
@@ -227,8 +226,8 @@ class any {
227226 any(const map& val) : type(Type::Map), m(make_shared<map>(val)) {}
228227 any(map&& val) noexcept : type(Type::Map), m(make_shared<map>(std::move(val))) {}
229228
230− any(const vector& val) : type(Type::Vector), v(make_shared<vector>(val)) {}
231− any(vector&& val) noexcept : type(Type::Vector), v(make_shared<vector>(std::move(val))) {}
229+ any(const data& val) : type(Type::Data), v(make_shared<data>(val)) {}
230+ any(data&& val) noexcept : type(Type::Data), v(make_shared<data>(std::move(val))) {}
232231
233232 any(const array& val) : type(Type::Array), a(make_shared<array>(val)) {}
234233 any(array&& val) noexcept : type(Type::Array), a(make_shared<array>(std::move(val))) {}
@@ -302,7 +301,7 @@ class any {
302301 auto cast() const -> typename std::enable_if<std::is_same<T, map>::value, const T&>::type;
303302
304303 template <typename T>
305− auto cast() const -> typename std::enable_if<std::is_same<T, vector>::value, const T&>::type;
304+ auto cast() const -> typename std::enable_if<std::is_same<T, data>::value, const T&>::type;
306305
307306 template <typename T>
308307 auto cast() const -> typename std::enable_if<std::is_same<T, array>::value, const T&>::type;
@@ -326,7 +325,7 @@ class any {
326325
327326 operator string() const;
328327 operator const map&() const;
329− operator const vector&() const;
328+ operator const data&() const;
330329 operator const array&() const;
331330
332331 auto operator[](const char[]) const -> const any&;