MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / evalByteCode

Function evalByteCode

modules/dasUnitTest/bytecode.cpp:7–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5namespace das {
6
7int32_t evalByteCode ( const ByteCode * cur, Context * ctx, LineInfoArg * at ) {
8 if ( !cur ) {
9 ctx->throw_error_at(at, "null bytecode");
10 return 0;
11 }
12 int32_t a = 0, b = 0, c = 0;
13 bool cmp = false;
14 while ( true ) {
15 switch ( cur->op_code ) {
16 case OpCode::op_nop: break;
17 case OpCode::op_mov_a_arg: a = *(int32_t *)(ctx->abiThisBlockArguments()+cur->high); break;
18 case OpCode::op_mov_arg_b: *(int32_t *)(ctx->abiThisBlockArguments()+cur->high) = b; break;
19 case OpCode::op_dec_a: --a; break;
20 case OpCode::op_cmple_a_low_zx: cmp = (a <= cur->low); break;
21 case OpCode::op_cjmp: if ( cmp ) { cur += cur->low; continue; } break;
22 case OpCode::op_mov_c_a: c = a; break;
23 case OpCode::op_mov_a_low_zx: a = cur->low; break;
24 case OpCode::op_mov_b_low_zx: b = cur->low; break;
25 case OpCode::op_xchange_a_b: { int32_t T=a; a=b; b=T; } break;
26 case OpCode::op_add_b_a: b += a; break;
27 case OpCode::op_loop: if ( --c > 0 ) { cur += cur->low; continue; } else { } break;
28 case OpCode::op_return_b: return b;
29 default: ctx->throw_error_at(at, "invalid op-code %i", (int)cur->op_code); return 0;
30 }
31 ++cur;
32 }
33}
34
35}

Callers

nothing calls this directly

Calls 1

throw_error_atMethod · 0.80

Tested by

no test coverage detected