| 293 | |
| 294 | |
| 295 | void ScriptCallable::genArgs(CppiaCompiler *compiler, CppiaExpr *inThis, Expressions &inArgs, const JitVal &inThisVal) |
| 296 | { |
| 297 | int inCount = inArgs.size(); |
| 298 | bool badCount = argCount<inCount; |
| 299 | |
| 300 | for(int i=inCount;i<argCount && !badCount;i++) |
| 301 | if (!hasDefault[i]) |
| 302 | badCount = true; |
| 303 | |
| 304 | if (badCount) |
| 305 | { |
| 306 | printf("Arg count mismatch %d!=%d ?\n", argCount, (int)inArgs.size()); |
| 307 | printf(" %s at %s:%d %s\n", getName(), filename, line, functionName); |
| 308 | CPPIA_CHECK(0); |
| 309 | throw Dynamic(HX_CSTRING("Arg count error")); |
| 310 | //return; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | int framePos = compiler->getCurrentFrameSize(); |
| 315 | // Push this ... |
| 316 | if (inThis) |
| 317 | { |
| 318 | inThis->genCode(compiler, JitFramePos(framePos), etObject); |
| 319 | } |
| 320 | else if (inThisVal.valid()) |
| 321 | { |
| 322 | compiler->move( JitFramePos(framePos), inThisVal ); |
| 323 | } |
| 324 | else |
| 325 | { |
| 326 | compiler->move( JitFramePos(framePos), JitVal( (void *)0 )); |
| 327 | } |
| 328 | compiler->addFrame(etObject); |
| 329 | |
| 330 | |
| 331 | for(int a=0;a<argCount;a++) |
| 332 | { |
| 333 | CppiaStackVar &var = args[a]; |
| 334 | if (a>=inCount) |
| 335 | { |
| 336 | int framePos = compiler->getCurrentFrameSize(); |
| 337 | switch(var.argType) |
| 338 | { |
| 339 | case etInt: |
| 340 | compiler->move( JitFramePos(framePos).as(jtInt), 0 ); |
| 341 | break; |
| 342 | case etObject: |
| 343 | compiler->move( JitFramePos(framePos).as(jtPointer), (void *)0 ); |
| 344 | break; |
| 345 | case etFloat: |
| 346 | compiler->move( JitFramePos(framePos).as(jtInt), 0 ); |
| 347 | compiler->move( JitFramePos(framePos).as(jtInt) + 4, 0 ); |
| 348 | break; |
| 349 | case etString: |
| 350 | compiler->move( JitFramePos(framePos).as(jtInt), 0 ); |
| 351 | compiler->move( JitFramePos(framePos).as(jtPointer) + StringOffset::Ptr, (void *)0 ); |
| 352 | break; |
no test coverage detected