Example #1
0
void bhvm::exec_instruction (const std::string& instruction)
{
    if (instruction == "pop")
    {
        exec_pop();
    }
    else if (instruction == "nop")
    {
        exec_nop();
    }
    else if (instruction == "calle")
    {
        exec_calle();
    }
    else if (instruction == "jump")
    {
        exec_jump();
    }
    else if (instruction.substr(0, 5) == "push ")
    {
        exec_push(instruction.substr(5));
    }
    else
        throw Alarm(MTK_HERE, "bhvm",  MTK_SS("unknown command " << instruction), alPriorCritic);
}
Example #2
0
void
stask_step_state(sched_task_t stask, executor_t exec)
{
  assert(stask != NULL);
  assert(stask->task->state >= TASK_TRANSITION_TO_WAITING);

  switch (stask->task->state)
    {
    case TASK_TRANSITION_TO_RUNNABLE:
      stask->task->state = TASK_RUNNABLE;
      exec_push(exec, stask);
      break;
    case TASK_TRANSITION_TO_WAITING:
      /* printf("%p set to waiting\n", stask); */
      stask->task->state = TASK_WAITING;
      break;
    case TASK_TRANSITION_TO_FINISHED:
      stask->task->state = TASK_FINISHED;
      // assert("How to free the processor? cast up?" && 0);
      stask_free(stask);
      break;
    default:
      break;
    }
}
Example #3
0
void
stask_wake(sched_task_t stask, executor_t exec)
{ 
  assert(exec != NULL);
  assert(stask != NULL);
  while(task_get_state(stask->task) != TASK_WAITING);
  task_set_state(stask->task, TASK_RUNNABLE);
  exec_push(exec, stask);
  /* sync_data_enqueue_runnable(proc->task->sync_data, proc); */
}
Example #4
0
void exec(Pystat stat){
    Arg arg0 = stat->args[0];
    Arg arg1 = stat->args[1];
    switch(stat->op){
        case Y_PUSH: {
            exec_push(arg0.ival, pc+1); // num_objects
            break;
        }
        case Y_GOTO: {
            exec_goto(arg0.ival); // absolute line
            break;
        }
        case Y_POP: {
            exec_pop();
            break;
        }
        case Y_NEW: {
            exec_new(arg0.ival); // obj size
            break;
        }
        case Y_NEWS: {
            exec_news(arg0.ival); // obj size
            break;
        }
        case Y_LDC: {
            exec_ldc(arg0.ival);
            break;
        }
        case Y_LDI: {
            exec_ldi(arg0.ival);
            break;
        }
        case Y_LDR: {
            exec_ldr(arg0.rval);
            break;
        }
        case Y_LDS: {
            exec_lds(arg0.sval);
            break;
        }
        case Y_LOD: {
            exec_lod(arg0.ival); // oid
            break;
        }
        case Y_GLOD: {
            exec_glod(arg0.ival); // oid
            break;
        }
        case Y_CAT: {
            exec_cat(arg0.ival, arg1.ival); // num fields, record/array size
            break;
        }
        case Y_LDA: {
            exec_lda(arg0.ival); // oid
            break;
        }
        case Y_GLDA: {
            exec_glda(arg0.ival); // oid
            break;
        }
        case Y_FDA: {
            exec_fda(arg0.ival); // field offset
            break;
        }
        case Y_EIL: {
            exec_eil(arg0.ival); // field size, embedded
            break;
        }
        case Y_SIL: {
            exec_sil(arg0.ival); // field size, on stack
            break;
        }
        case Y_IXA: {
            exec_ixa(arg0.ival); // elem size
            break;
        }
        case Y_STO: {
            exec_sto(arg0.ival); // oid
            break;
        }
        case Y_GSTO: {
            exec_gsto(arg0.ival); // oid
            break;
        }
        case Y_IST: {
            exec_ist(); // indirect store
            break;
        }
        case Y_JMF: {
            exec_jmf(arg0.ival); // offset
            break;
        }
        case Y_JMP: {
            exec_jmp(arg0.ival); // offset
            break;
        }
        case Y_EQU: {
            exec_equ(); // for all types of objects
            break;
        }
        case Y_NEQ: {
            exec_neq(); // for all types of objects
            break;
        }
        case Y_IGT: {
            exec_igt();
            break;
        }
        case Y_IGE: {
            exec_ige();
            break;
        }
        case Y_ILT: {
            exec_ilt();
            break;
        }
        case Y_ILE: {
            exec_ile();
            break;
        }
        case Y_RGT: {
            exec_rgt();
            break;
        }
        case Y_RGE: {
            exec_rge();
            break;
        }
        case Y_RLT: {
            exec_rlt();
            break;
        }
        case Y_RLE: {
            exec_rle();
            break;
        }
        case Y_SGT: {
            exec_sgt();
            break;
        }
        case Y_SGE: {
            exec_sge();
            break;
        }
        case Y_SLT: {
            exec_slt();
            break;
        }
        case Y_SLE: {
            exec_sle();
            break;
        }
        case Y_IPLUS: {
            exec_iplus();
            break;
        }
        case Y_IMINUS: {
            exec_iminus();
            break;
        }
        case Y_ITIMES: {
            exec_itimes();
            break;
        }
        case Y_IDIV: {
            exec_idiv();
            break;
        }
        case Y_RPLUS: {
            exec_rplus();
            break;
        }
        case Y_RMINUS: {
            exec_rminus();
            break;
        }
        case Y_RTIMES: {
            exec_rtimes();
            break;
        }
        case Y_RDIV: {
            exec_rdiv();
            break;
        }
        case Y_IUMI: {
            exec_iumi();
            break;
        }
        case Y_RUMI: {
            exec_rumi();
            break;
        }
        case Y_NEG: {
            exec_neg();
            break;
        }
        case Y_WR: {
            exec_wr(arg0.sval, 1, stdout); // schema
            break;
        }
        case Y_FWR: {
            exec_fwr(arg0.sval); // schema
            break;
        }
        case Y_RD: {
            exec_rd(arg0.sval, 1, stdin); // schema
            break;
        }
        case Y_FRD: {
            exec_frd(arg0.sval); // schema
            break;
        }
        case Y_TOINT: {
            exec_toint();
            break;
        }
        case Y_TOINTUP: {
            exec_tointup();
            break;
        }
        case Y_TOREAL: {
            exec_toreal();
            break;
        }
        case Y_READ: {
            exec_read(arg0.ival, arg1.sval, 1, stdin); // oid, schema
            break;
        }
        case Y_GREAD: {
            exec_gread(arg0.ival, arg1.sval, 1, stdin); // oid, schema
            break;
        }
        case Y_FREAD: {
            exec_fread(arg0.ival, arg1.sval); // oid, schema
            break;
        }
        case Y_GFREAD: {
            exec_gfread(arg0.ival, arg1.sval); // oid, schema
            break;
        }
        case Y_WRITE: {
            exec_write(arg0.sval); // schema
            break;
        }
        case Y_FWRITE: {
            exec_fwrite(arg0.sval); // schema
            break;
        }
        case Y_TDUP: {
            exec_tdup();
            break;
        }
        case Y_TPOP: {
            exec_tpop(arg0.ival); // num objects
            break;
        }
        case Y_MODULE: {
            // nothing to do here, the instruction is useless
            break;
        }
        case Y_RETURN: {
            exec_return();
            break;
        }
        default: {
            machine_error("Unknown instruction.");
            break;
        }
    }
}