git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix subscript operators
commit4a85558507e3254d5d62afaecb3705da471165c3 authorAndy Arvanitis <andyarvanitis@gmail.com> dateTue 14 Aug 2018, 19:15 (8 years ago) parent715a171
1 file changed+13−2
runtime/purescript.h+13−2
runtime/purescript.h+13−2
@@ -97,12 +97,12 @@ namespace purescript {
9797 return f();
9898 }
9999
100− auto operator[](const char key[]) const -> const boxed& {
100+ auto operator[](const string& key) const -> const boxed& {
101101 const auto& dict = *static_cast<const dict_t*>(get());
102102 return dict.at(key);
103103 }
104104
105− auto operator[](const char key[]) -> boxed& {
105+ auto operator[](const string& key) -> boxed& {
106106 auto& dict = *static_cast<dict_t*>(get());
107107 return dict[key];
108108 }
@@ -112,11 +112,22 @@ namespace purescript {
112112 const auto& array = *static_cast<const array_t*>(get());
113113 return array[index];
114114 }
115+
116+ auto operator[](const int index) -> boxed& {
117+ auto& array = *static_cast<array_t*>(get());
118+ return array[index];
119+ }
115120#else
116121 auto operator[](const int index) const -> const boxed& {
117122 const auto& array = *static_cast<const array_t*>(get());
118123 return array.at(index);
119124 }
125+
126+ auto operator[](const int index) -> boxed& {
127+ auto& array = *static_cast<array_t*>(get());
128+ return array.at(index);
129+ }
130+
120131#endif // NDEBUG
121132
122133 }; // class boxed