Пример #1
0
    protocol::RedisReplyPtr AccumulateAndSend(Args ... values)
    {
        std::vector<std::string> command;
        push_all(command, values...);

        //  Now we can encode and send.
        std::string packet;
        protocol::EncodeBulkStringArray(command, packet);

        return SendEncodedPacket(packet);
    }
Пример #2
0
void gen_asm_call(IR *ir)
{
    // Open space for used save registers and arguments

    int offset = nr_arg * 4;
    emit_asm(addi, "$sp, $sp, -%d  # Open space for save and arguments", offset);

    sp_offset += offset;

    push_all();

    IR *arg = ir;  // IR is stored consecutively


    // Push all arguments onto stack, which is more like x86 ;-)
    for (int i = 1; i <= nr_arg; i++) {

        do { arg--; } while (arg->type != IR_ARG);  // ARG may not be consecutive,
                                                    // so we use a iteration to find the first ARG
                                                    // before the current IR.
                                                    // It is expected that there always have enough
                                                    // ARG IRs that match [nr_arg]

        int y = ensure(arg->rs);
        emit_asm(sw, "%s, %d($sp)", reg_to_s(y), (i - 1) * 4);

    }

    emit_asm(jal, "%s", ir->rs->name);

    clear_reg_state();

    int x = allocate(ir->rd);
    set_dirty(x);

    if (ir->rd->next_use != MAX_LINE || ir->rd->liveness) {
        emit_asm(move, "%s, $v0", reg_to_s(x));
    }

    emit_asm(addiu, "$sp, $sp, %d  # Drawback save and arguments space", offset);

    sp_offset -= offset;

    nr_arg = 0;  // After translating the call, clear arg state
}
Пример #3
0
static void
dfs (void)
{
	g_assert (dyn_array_ptr_size (&scan_stack) == 1);
	g_assert (dyn_array_ptr_size (&loop_stack) == 0);

	dyn_array_ptr_set_size (&color_merge_array, 0);

	while (dyn_array_ptr_size (&scan_stack) > 0) {
		ScanData *data = dyn_array_ptr_pop (&scan_stack);

		/**
		 * Ignore finished objects on stack, they happen due to loops. For example:
		 * A -> C
		 * A -> B
		 * B -> C
		 * C -> A
		 *
		 * We start scanning from A and push C before B. So, after the first iteration, the scan stack will have: A C B.
		 * We then visit B, which will find C in its initial state and push again.
		 * Finally after finish with C and B, the stack will be left with "A C" and at this point C should be ignored.
         *
         * The above explains FINISHED_ON_STACK, to explain FINISHED_OFF_STACK, consider if the root was D, which pointed
		 * to A and C. A is processed first, leaving C on stack after that in the mentioned state.
		 */
		if (data->state == FINISHED_ON_STACK || data->state == FINISHED_OFF_STACK)
			continue;

		if (data->state == INITIAL) {
			g_assert (data->index == -1);
			g_assert (data->low_index == -1);

			data->state = SCANNED;
			data->low_index = data->index = object_index++;
			dyn_array_ptr_push (&scan_stack, data);
			dyn_array_ptr_push (&loop_stack, data);

#if DUMP_GRAPH
			printf ("+scanning %s (%p) index %d color %p\n", safe_name_bridge (data->obj), data->obj, data->index, data->color);
#endif
			/*push all refs */
			push_all (data);
		} else {
			g_assert (data->state == SCANNED);
			data->state = FINISHED_ON_STACK;

#if DUMP_GRAPH
			printf ("-finishing %s (%p) index %d low-index %d color %p\n", safe_name_bridge (data->obj), data->obj, data->index, data->low_index, data->color);
#endif

			/* Compute low index */
			compute_low (data);

#if DUMP_GRAPH
			printf ("-finished %s (%p) index %d low-index %d color %p\n", safe_name_bridge (data->obj), data->obj, data->index, data->low_index, data->color);
#endif
			//SCC root
			if (data->index == data->low_index)
				create_scc (data);
		}
	}
}
Пример #4
0
 Heap<T, Compare>::Heap(InputIterator begin, InputIterator end, const Compare& compare):
   BaseList<T>(),
   m_compare (compare)
 {
   push_all(begin, end);
 }
Пример #5
0
 /** @return the next smallest number */
 int next() {
     TreeNode* tmp = m_stk.top();
     m_stk.pop();
     push_all(tmp->right);
     return tmp->val;
 }
Пример #6
0
 BSTIterator(TreeNode *root){
     push_all(root);
 }