git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix subscript operators
4a85558Andy Arvanitis
runtime/purescript.h+13−2
@@ -97,12 +97,12 @@ namespace purescript {
97 return f();
97 return f();
98 }
98 }
99
99
100− auto operator[](const char key[]) const -> const boxed& {
100+ auto operator[](const string& key) const -> const boxed& {
101 const auto& dict = *static_cast<const dict_t*>(get());
101 const auto& dict = *static_cast<const dict_t*>(get());
102 return dict.at(key);
102 return dict.at(key);
103 }
103 }
104
104
105− auto operator[](const char key[]) -> boxed& {
105+ auto operator[](const string& key) -> boxed& {
106 auto& dict = *static_cast<dict_t*>(get());
106 auto& dict = *static_cast<dict_t*>(get());
107 return dict[key];
107 return dict[key];
108 }
108 }
@@ -112,11 +112,22 @@ namespace purescript {
112 const auto& array = *static_cast<const array_t*>(get());
112 const auto& array = *static_cast<const array_t*>(get());
113 return array[index];
113 return array[index];
114 }
114 }
115+
116+ auto operator[](const int index) -> boxed& {
117+ auto& array = *static_cast<array_t*>(get());
118+ return array[index];
119+ }
115#else
120#else
116 auto operator[](const int index) const -> const boxed& {
121 auto operator[](const int index) const -> const boxed& {
117 const auto& array = *static_cast<const array_t*>(get());
122 const auto& array = *static_cast<const array_t*>(get());
118 return array.at(index);
123 return array.at(index);
119 }
124 }
125+
126+ auto operator[](const int index) -> boxed& {
127+ auto& array = *static_cast<array_t*>(get());
128+ return array.at(index);
129+ }
130+
120#endif // NDEBUG
131#endif // NDEBUG
121
132
122 }; // class boxed
133 }; // class boxed