void resolve(t_ps *ps) { int tmp_total_ops; int final_algo; if (ps->algo != -1) execute(ps); else { ps->algo = ps->total_elem > 500 ? SE : 0; tmp_total_ops = 0; solve_if_almost_sorted(ps); while (ps->algo < ALGOS_LEN) { execute(ps); if (is_resolved(ps) && (!tmp_total_ops || ps->total_ops < tmp_total_ops)) { final_algo = ps->algo; tmp_total_ops = ps->total_ops; } ps->algo++; } ps->algo = final_algo; ps->options |= OPT_EXEC; execute(ps); } }
void bubble_sort(t_ps *ps) { t_dlist_node *cursor; int min; min = find_min(ps->stack_a); while (!is_resolved(ps) && ps->total_ops < MAX_OPS) { cursor = ps->stack_a->first; if (NEXT_VAL(cursor) == min || !(CURR_VAL(cursor) > NEXT_VAL(cursor))) OP(RA); else OP(SA); } }
void interactive_mode(t_ps *ps) { char *line; char **tab; char **tmp; line = NULL; init_imode(ps); while (!is_resolved(ps) && get_next_line(1, &line) == 1) { if (ft_strequ(line, "exit")) exit(0); tab = ft_strsplit(line, ' '); tmp = tab; while (*tab) { recover_and_call_op(*tab, ps); tab++; } free(line); free_tab(&tmp); print_prompt(); } }
void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code, methodHandle method, int vtable_index) { assert(method->interpreter_entry() != NULL, "should have been set at this point"); assert(!method->is_old_version(), "attempt to write old method to cpCache"); bool change_to_virtual = (invoke_code == Bytecodes::_invokeinterface); int byte_no = -1; bool needs_vfinal_flag = false; switch (invoke_code) { case Bytecodes::_invokevirtual: case Bytecodes::_invokeinterface: { if (Klass::can_be_statically_bound(method())) { set_f2((intptr_t)method()); needs_vfinal_flag = true; } else { set_f2(vtable_index); } byte_no = 2; break; } case Bytecodes::_invokespecial: // Preserve the value of the vfinal flag on invokevirtual bytecode // which may be shared with this constant pool cache entry. needs_vfinal_flag = is_resolved(Bytecodes::_invokevirtual) && is_vfinal(); // fall through case Bytecodes::_invokestatic: set_f1(method()); byte_no = 1; break; default: ShouldNotReachHere(); break; } set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), needs_vfinal_flag, false, change_to_virtual, true)| method()->size_of_parameters()); // Note: byte_no also appears in TemplateTable::resolve. if (byte_no == 1) { set_bytecode_1(invoke_code); } else if (byte_no == 2) { if (change_to_virtual) { // NOTE: THIS IS A HACK - BE VERY CAREFUL!!! // // Workaround for the case where we encounter an invokeinterface, but we // should really have an _invokevirtual since the resolved method is a // virtual method in java.lang.Object. This is a corner case in the spec // but is presumably legal. javac does not generate this code. // // We set bytecode_1() to _invokeinterface, because that is the // bytecode # used by the interpreter to see if it is resolved. // We set bytecode_2() to _invokevirtual. // See also interpreterRuntime.cpp. (8/25/2000) set_bytecode_1(invoke_code); set_bytecode_2(Bytecodes::_invokevirtual); } else { set_bytecode_2(invoke_code); } } else { ShouldNotReachHere(); } verify(tty); }
Klass* get_klass() { assert(is_resolved(), "bad call"); return (Klass*)_ptr; }