本文整理汇总了C++中push_instr函数的典型用法代码示例。如果您正苦于以下问题:C++ push_instr函数的具体用法?C++ push_instr怎么用?C++ push_instr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了push_instr函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compile_if_statement
static HRESULT compile_if_statement(compile_ctx_t *ctx, if_statement_t *stat)
{
unsigned cnd_jmp, endif_label = -1;
elseif_decl_t *elseif_decl;
HRESULT hres;
hres = compile_expression(ctx, stat->expr);
if(FAILED(hres))
return hres;
cnd_jmp = push_instr(ctx, OP_jmp_false);
if(cnd_jmp == -1)
return E_OUTOFMEMORY;
hres = compile_statement(ctx, stat->if_stat);
if(FAILED(hres))
return hres;
if(stat->else_stat || stat->elseifs) {
endif_label = alloc_label(ctx);
if(endif_label == -1)
return E_OUTOFMEMORY;
hres = push_instr_addr(ctx, OP_jmp, endif_label);
if(FAILED(hres))
return hres;
}
for(elseif_decl = stat->elseifs; elseif_decl; elseif_decl = elseif_decl->next) {
instr_ptr(ctx, cnd_jmp)->arg1.uint = ctx->instr_cnt;
hres = compile_expression(ctx, elseif_decl->expr);
if(FAILED(hres))
return hres;
cnd_jmp = push_instr(ctx, OP_jmp_false);
if(cnd_jmp == -1)
return E_OUTOFMEMORY;
hres = compile_statement(ctx, elseif_decl->stat);
if(FAILED(hres))
return hres;
hres = push_instr_addr(ctx, OP_jmp, endif_label);
if(FAILED(hres))
return hres;
}
instr_ptr(ctx, cnd_jmp)->arg1.uint = ctx->instr_cnt;
if(stat->else_stat) {
hres = compile_statement(ctx, stat->else_stat);
if(FAILED(hres))
return hres;
}
if(endif_label != -1)
label_set_addr(ctx, endif_label);
return S_OK;
}
示例2: compile_foreach_statement
static HRESULT compile_foreach_statement(compile_ctx_t *ctx, foreach_statement_t *stat)
{
statement_ctx_t loop_ctx = {1};
unsigned loop_start;
HRESULT hres;
hres = compile_expression(ctx, stat->group_expr);
if(FAILED(hres))
return hres;
if(!push_instr(ctx, OP_newenum))
return E_OUTOFMEMORY;
loop_start = ctx->instr_cnt;
if(!(loop_ctx.for_end_label = alloc_label(ctx)))
return E_OUTOFMEMORY;
hres = push_instr_uint_bstr(ctx, OP_enumnext, loop_ctx.for_end_label, stat->identifier);
if(FAILED(hres))
return hres;
hres = compile_statement(ctx, &loop_ctx, stat->body);
if(FAILED(hres))
return hres;
hres = push_instr_addr(ctx, OP_jmp, loop_start);
if(FAILED(hres))
return hres;
label_set_addr(ctx, loop_ctx.for_end_label);
return S_OK;
}
示例3: compile_subscript
HRESULT compile_subscript(parser_ctx_t *parser, expression_t *expr, BOOL do_ret, unsigned *ret_off)
{
BOOL no_ret = FALSE;
HRESULT hres;
if(!parser->code) {
parser->code = heap_alloc_zero(sizeof(bytecode_t));
if(!parser->code)
return E_OUTOFMEMORY;
jsheap_init(&parser->code->heap);
}
if(!parser->compiler) {
parser->compiler = heap_alloc_zero(sizeof(compiler_ctx_t));
if(!parser->compiler)
return E_OUTOFMEMORY;
parser->compiler->parser = parser;
parser->compiler->code = parser->code;
}
*ret_off = parser->compiler->code_off;
hres = compile_expression_noret(parser->compiler, expr, do_ret ? NULL : &no_ret);
if(FAILED(hres))
return hres;
return push_instr(parser->compiler, OP_ret) == -1 ? E_OUTOFMEMORY : S_OK;
}
示例4: compile_unary_expression
static HRESULT compile_unary_expression(compile_ctx_t *ctx, unary_expression_t *expr, vbsop_t op)
{
HRESULT hres;
hres = compile_expression(ctx, expr->subexpr);
if(FAILED(hres))
return hres;
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
}
示例5: compile_interp_fallback
static HRESULT compile_interp_fallback(compiler_ctx_t *ctx, expression_t *expr)
{
unsigned instr;
instr = push_instr(ctx, OP_tree);
if(instr == -1)
return E_OUTOFMEMORY;
instr_ptr(ctx, instr)->arg1.expr = expr;
return S_OK;
}
示例6: push_instr_int
static HRESULT push_instr_int(compiler_ctx_t *ctx, jsop_t op, LONG arg)
{
unsigned instr;
instr = push_instr(ctx, op);
if(instr == -1)
return E_OUTOFMEMORY;
instr_ptr(ctx, instr)->arg1.lng = arg;
return S_OK;
}
示例7: push_instr_addr
static HRESULT push_instr_addr(compile_ctx_t *ctx, vbsop_t op, unsigned arg)
{
unsigned ret;
ret = push_instr(ctx, op);
if(ret == -1)
return E_OUTOFMEMORY;
instr_ptr(ctx, ret)->arg1.uint = arg;
return S_OK;
}
示例8: push_instr_int
static HRESULT push_instr_int(compile_ctx_t *ctx, vbsop_t op, LONG arg)
{
unsigned ret;
ret = push_instr(ctx, op);
if(!ret)
return E_OUTOFMEMORY;
instr_ptr(ctx, ret)->arg1.lng = arg;
return S_OK;
}
示例9: compile_binary_expression
static HRESULT compile_binary_expression(compile_ctx_t *ctx, binary_expression_t *expr, vbsop_t op)
{
HRESULT hres;
hres = compile_expression(ctx, expr->left);
if(FAILED(hres))
return hres;
hres = compile_expression(ctx, expr->right);
if(FAILED(hres))
return hres;
return push_instr(ctx, op) ? S_OK : E_OUTOFMEMORY;
}
示例10: compile_binary_expression
static HRESULT compile_binary_expression(compiler_ctx_t *ctx, binary_expression_t *expr, jsop_t op)
{
HRESULT hres;
hres = compile_expression(ctx, expr->expression1);
if(FAILED(hres))
return hres;
hres = compile_expression(ctx, expr->expression2);
if(FAILED(hres))
return hres;
return push_instr(ctx, op) == -1 ? E_OUTOFMEMORY : S_OK;
}