MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / ArraySetter

Class ArraySetter

src/hx/cppia/ArrayBuiltin.cpp:103–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102template<typename ELEM, typename FUNC>
103struct ArraySetter : public ArrayBuiltinBase
104{
105 ArraySetter(CppiaExpr *inSrc, CppiaExpr *inThisExpr, Expressions &ioExpressions)
106 : ArrayBuiltinBase(inSrc,inThisExpr,ioExpressions)
107 {
108 }
109 const char *getName() HXCPP_OVERRIDE { return "ArraySetter"; }
110 ExprType getType() HXCPP_OVERRIDE
111 {
112 return (ExprType)ExprTypeOf<ELEM>::value;
113 }
114 int runInt(CppiaCtx *ctx) HXCPP_OVERRIDE
115 {
116 Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM>*>(thisExpr->runObject(ctx));
117 BCR_CHECK;
118 int i = args[0]->runInt(ctx);
119 BCR_CHECK;
120 ELEM &elem = thisVal->Item(i);
121 FUNC::run(elem, ctx, args[1]);
122 #ifdef HXCPP_GC_GENERATIONAL
123 if (hx::ContainsPointers<ELEM>())
124 HX_OBJ_WB_CTX(thisVal,hx::PointerOf(elem),ctx);
125 #endif
126 return ValToInt(elem);
127 }
128 Float runFloat(CppiaCtx *ctx) HXCPP_OVERRIDE
129 {
130 Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM>*>(thisExpr->runObject(ctx));
131 BCR_CHECK;
132 int i = args[0]->runInt(ctx);
133 BCR_CHECK;
134 ELEM &elem = thisVal->Item(i);
135 FUNC::run(elem, ctx, args[1]);
136 #ifdef HXCPP_GC_GENERATIONAL
137 if (hx::ContainsPointers<ELEM>())
138 HX_OBJ_WB_CTX(thisVal,hx::PointerOf(elem),ctx);
139 #endif
140 return ValToFloat(elem);
141 }
142 String runString(CppiaCtx *ctx) HXCPP_OVERRIDE
143 {
144 Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM>*>(thisExpr->runObject(ctx));
145 BCR_CHECK;
146 int i = args[0]->runInt(ctx);
147 BCR_CHECK;
148 ELEM &elem = thisVal->Item(i);
149 FUNC::run(elem, ctx, args[1]);
150 #ifdef HXCPP_GC_GENERATIONAL
151 if (hx::ContainsPointers<ELEM>())
152 HX_OBJ_WB_CTX(thisVal,hx::PointerOf(elem),ctx);
153 #endif
154 return ValToString(elem);
155 }
156 hx::Object *runObject(CppiaCtx *ctx) HXCPP_OVERRIDE
157 {
158 Array_obj<ELEM> *thisVal = reinterpret_cast<Array_obj<ELEM>*>(thisExpr->runObject(ctx));
159 BCR_CHECK;
160 int i = args[0]->runInt(ctx);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected