Commit 6a7f133d authored by ksss's avatar ksss

include/mruby/opcode.h fix operation doc

src/vm.c fix operation doc
[ci skip]
parent 41b46ca1
......@@ -55,26 +55,26 @@ enum {
------------------------------------------------------------------------*/
OP_NOP=0,/* */
OP_MOVE,/* A B R(A) := R(B) */
OP_LOADL,/* A Bx R(A) := Lit(Bx) */
OP_LOADL,/* A Bx R(A) := Pool(Bx) */
OP_LOADI,/* A sBx R(A) := sBx */
OP_LOADSYM,/* A Bx R(A) := Sym(Bx) */
OP_LOADSYM,/* A Bx R(A) := Syms(Bx) */
OP_LOADNIL,/* A R(A) := nil */
OP_LOADSELF,/* A R(A) := self */
OP_LOADT,/* A R(A) := true */
OP_LOADF,/* A R(A) := false */
OP_GETGLOBAL,/* A Bx R(A) := getglobal(Sym(Bx)) */
OP_SETGLOBAL,/* A Bx setglobal(Sym(Bx), R(A)) */
OP_GETGLOBAL,/* A Bx R(A) := getglobal(Syms(Bx)) */
OP_SETGLOBAL,/* A Bx setglobal(Syms(Bx), R(A)) */
OP_GETSPECIAL,/*A Bx R(A) := Special[Bx] */
OP_SETSPECIAL,/*A Bx Special[Bx] := R(A) */
OP_GETIV,/* A Bx R(A) := ivget(Sym(Bx)) */
OP_SETIV,/* A Bx ivset(Sym(Bx),R(A)) */
OP_GETCV,/* A Bx R(A) := cvget(Sym(Bx)) */
OP_SETCV,/* A Bx cvset(Sym(Bx),R(A)) */
OP_GETCONST,/* A Bx R(A) := constget(Sym(Bx)) */
OP_SETCONST,/* A Bx constset(Sym(Bx),R(A)) */
OP_GETMCNST,/* A Bx R(A) := R(A)::Sym(Bx) */
OP_SETMCNST,/* A Bx R(A+1)::Sym(Bx) := R(A) */
OP_GETIV,/* A Bx R(A) := ivget(Syms(Bx)) */
OP_SETIV,/* A Bx ivset(Syms(Bx),R(A)) */
OP_GETCV,/* A Bx R(A) := cvget(Syms(Bx)) */
OP_SETCV,/* A Bx cvset(Syms(Bx),R(A)) */
OP_GETCONST,/* A Bx R(A) := constget(Syms(Bx)) */
OP_SETCONST,/* A Bx constset(Syms(Bx),R(A)) */
OP_GETMCNST,/* A Bx R(A) := R(A)::Syms(Bx) */
OP_SETMCNST,/* A Bx R(A+1)::Syms(Bx) := R(A) */
OP_GETUPVAR,/* A B C R(A) := uvget(B,C) */
OP_SETUPVAR,/* A B C uvset(B,C,R(A)) */
......@@ -88,31 +88,31 @@ enum {
OP_EPUSH,/* Bx ensure_push(SEQ[Bx]) */
OP_EPOP,/* A A.times{ensure_pop().call} */
OP_SEND,/* A B C R(A) := call(R(A),mSym(B),R(A+1),...,R(A+C)) */
OP_SENDB,/* A B C R(A) := call(R(A),mSym(B),R(A+1),...,R(A+C),&R(A+C+1))*/
OP_FSEND,/* A B C R(A) := fcall(R(A),mSym(B),R(A+1),...,R(A+C-1)) */
OP_CALL,/* A B C R(A) := self.call(R(A),.., R(A+C)) */
OP_SUPER,/* A B C R(A) := super(R(A+1),... ,R(A+C-1)) */
OP_SEND,/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C)) */
OP_SENDB,/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C),&R(A+C+1))*/
OP_FSEND,/* A B C R(A) := fcall(R(A),Syms(B),R(A+1),...,R(A+C-1)) */
OP_CALL,/* A R(A) := self.call(frame.argc, frame.argv) */
OP_SUPER,/* A C R(A) := super(R(A+1),... ,R(A+C+1)) */
OP_ARGARY,/* A Bx R(A) := argument array (16=6:1:5:4) */
OP_ENTER,/* Ax arg setup according to flags (23=5:5:1:5:5:1:1) */
OP_KARG,/* A B C R(A) := kdict[mSym(B)]; if C kdict.rm(mSym(B)) */
OP_KARG,/* A B C R(A) := kdict[Syms(B)]; if C kdict.rm(Syms(B)) */
OP_KDICT,/* A C R(A) := kdict */
OP_RETURN,/* A B return R(A) (B=normal,in-block return/break) */
OP_TAILCALL,/* A B C return call(R(A),mSym(B),*R(C)) */
OP_TAILCALL,/* A B C return call(R(A),Syms(B),*R(C)) */
OP_BLKPUSH,/* A Bx R(A) := block (16=6:1:5:4) */
OP_ADD,/* A B C R(A) := R(A)+R(A+1) (mSyms[B]=:+,C=1) */
OP_ADDI,/* A B C R(A) := R(A)+C (mSyms[B]=:+) */
OP_SUB,/* A B C R(A) := R(A)-R(A+1) (mSyms[B]=:-,C=1) */
OP_SUBI,/* A B C R(A) := R(A)-C (mSyms[B]=:-) */
OP_MUL,/* A B C R(A) := R(A)*R(A+1) (mSyms[B]=:*,C=1) */
OP_DIV,/* A B C R(A) := R(A)/R(A+1) (mSyms[B]=:/,C=1) */
OP_EQ,/* A B C R(A) := R(A)==R(A+1) (mSyms[B]=:==,C=1) */
OP_LT,/* A B C R(A) := R(A)<R(A+1) (mSyms[B]=:<,C=1) */
OP_LE,/* A B C R(A) := R(A)<=R(A+1) (mSyms[B]=:<=,C=1) */
OP_GT,/* A B C R(A) := R(A)>R(A+1) (mSyms[B]=:>,C=1) */
OP_GE,/* A B C R(A) := R(A)>=R(A+1) (mSyms[B]=:>=,C=1) */
OP_ADD,/* A B C R(A) := R(A)+R(A+1) (Syms[B]=:+,C=1) */
OP_ADDI,/* A B C R(A) := R(A)+C (Syms[B]=:+) */
OP_SUB,/* A B C R(A) := R(A)-R(A+1) (Syms[B]=:-,C=1) */
OP_SUBI,/* A B C R(A) := R(A)-C (Syms[B]=:-) */
OP_MUL,/* A B C R(A) := R(A)*R(A+1) (Syms[B]=:*,C=1) */
OP_DIV,/* A B C R(A) := R(A)/R(A+1) (Syms[B]=:/,C=1) */
OP_EQ,/* A B C R(A) := R(A)==R(A+1) (Syms[B]=:==,C=1) */
OP_LT,/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1) */
OP_LE,/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1) */
OP_GT,/* A B C R(A) := R(A)>R(A+1) (Syms[B]=:>,C=1) */
OP_GE,/* A B C R(A) := R(A)>=R(A+1) (Syms[B]=:>=,C=1) */
OP_ARRAY,/* A B C R(A) := ary_new(R(B),R(B+1)..R(B+C)) */
OP_ARYCAT,/* A B ary_cat(R(A),R(B)) */
......@@ -129,14 +129,14 @@ enum {
OP_RANGE,/* A B C R(A) := range_new(R(B),R(B+1),C) */
OP_OCLASS,/* A R(A) := ::Object */
OP_CLASS,/* A B R(A) := newclass(R(A),mSym(B),R(A+1)) */
OP_MODULE,/* A B R(A) := newmodule(R(A),mSym(B)) */
OP_CLASS,/* A B R(A) := newclass(R(A),Syms(B),R(A+1)) */
OP_MODULE,/* A B R(A) := newmodule(R(A),Syms(B)) */
OP_EXEC,/* A Bx R(A) := blockexec(R(A),SEQ[Bx]) */
OP_METHOD,/* A B R(A).newmethod(mSym(B),R(A+1)) */
OP_METHOD,/* A B R(A).newmethod(Syms(B),R(A+1)) */
OP_SCLASS,/* A B R(A) := R(B).singleton_class */
OP_TCLASS,/* A R(A) := target_class */
OP_DEBUG,/* A print R(A) */
OP_DEBUG,/* A B C print R(A),R(B),R(C) */
OP_STOP,/* stop VM */
OP_ERR,/* Bx raise RuntimeError with message Lit(Bx) */
......
......@@ -724,13 +724,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_LOADI) {
/* A Bx R(A) := sBx */
/* A sBx R(A) := sBx */
SET_INT_VALUE(regs[GETARG_A(i)], GETARG_sBx(i));
NEXT;
}
CASE(OP_LOADSYM) {
/* A B R(A) := Sym(B) */
/* A Bx R(A) := Syms(Bx) */
SET_SYM_VALUE(regs[GETARG_A(i)], syms[GETARG_Bx(i)]);
NEXT;
}
......@@ -754,13 +754,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_GETGLOBAL) {
/* A B R(A) := getglobal(Sym(B)) */
/* A Bx R(A) := getglobal(Syms(Bx)) */
regs[GETARG_A(i)] = mrb_gv_get(mrb, syms[GETARG_Bx(i)]);
NEXT;
}
CASE(OP_SETGLOBAL) {
/* setglobal(Sym(b), R(A)) */
/* setglobal(Syms(Bx), R(A)) */
mrb_gv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
NEXT;
}
......@@ -784,13 +784,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SETIV) {
/* ivset(Sym(B),R(A)) */
/* ivset(Syms(Bx),R(A)) */
mrb_vm_iv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
NEXT;
}
CASE(OP_GETCV) {
/* A B R(A) := ivget(Sym(B)) */
/* A Bx R(A) := cvget(Syms(Bx)) */
ERR_PC_SET(mrb, pc);
regs[GETARG_A(i)] = mrb_vm_cv_get(mrb, syms[GETARG_Bx(i)]);
ERR_PC_CLR(mrb);
......@@ -798,13 +798,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SETCV) {
/* ivset(Sym(B),R(A)) */
/* cvset(Syms(Bx),R(A)) */
mrb_vm_cv_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
NEXT;
}
CASE(OP_GETCONST) {
/* A B R(A) := constget(Sym(B)) */
/* A Bx R(A) := constget(Syms(Bx)) */
mrb_value val;
ERR_PC_SET(mrb, pc);
......@@ -816,13 +816,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SETCONST) {
/* A B constset(Sym(B),R(A)) */
/* A Bx constset(Syms(Bx),R(A)) */
mrb_vm_const_set(mrb, syms[GETARG_Bx(i)], regs[GETARG_A(i)]);
NEXT;
}
CASE(OP_GETMCNST) {
/* A B C R(A) := R(C)::Sym(B) */
/* A Bx R(A) := R(A)::Syms(Bx) */
mrb_value val;
int a = GETARG_A(i);
......@@ -835,7 +835,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SETMCNST) {
/* A B C R(A+1)::Sym(B) := R(A) */
/* A Bx R(A+1)::Syms(Bx) := R(A) */
int a = GETARG_A(i);
mrb_const_set(mrb, regs[a+1], syms[GETARG_Bx(i)], regs[a]);
......@@ -861,7 +861,6 @@ RETRY_TRY_BLOCK:
CASE(OP_SETUPVAR) {
/* A B C uvset(B,C,R(A)) */
/* A B C R(A) := uvget(B,C) */
int up = GETARG_C(i);
struct REnv *e = uvenv(mrb, up);
......@@ -891,7 +890,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_JMPNOT) {
/* A sBx if R(A) pc+=sBx */
/* A sBx if !R(A) pc+=sBx */
if (!mrb_test(regs[GETARG_A(i)])) {
pc += GETARG_sBx(i);
JUMP;
......@@ -918,6 +917,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_POPERR) {
/* A A.times{rescue_pop()} */
int a = GETARG_A(i);
while (a--) {
......@@ -962,7 +962,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_LOADNIL) {
/* A B R(A) := nil */
/* A R(A) := nil */
int a = GETARG_A(i);
SET_NIL_VALUE(regs[a]);
......@@ -970,12 +970,13 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SENDB) {
/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C),&R(A+C+1))*/
/* fall through */
};
L_SEND:
CASE(OP_SEND) {
/* A B C R(A) := call(R(A),Sym(B),R(A+1),... ,R(A+C-1)) */
/* A B C R(A) := call(R(A),Syms(B),R(A+1),...,R(A+C)) */
int a = GETARG_A(i);
int n = GETARG_C(i);
struct RProc *m;
......@@ -1077,7 +1078,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_FSEND) {
/* A B C R(A) := fcall(R(A),Sym(B),R(A+1),... ,R(A+C)) */
/* A B C R(A) := fcall(R(A),Syms(B),R(A+1),... ,R(A+C-1)) */
NEXT;
}
......@@ -1141,7 +1142,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_SUPER) {
/* A B C R(A) := super(R(A+1),... ,R(A+C-1)) */
/* A C R(A) := super(R(A+1),... ,R(A+C+1)) */
mrb_value recv;
mrb_callinfo *ci = mrb->c->ci;
struct RProc *m;
......@@ -1268,7 +1269,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_ENTER) {
/* Ax arg setup according to flags (24=5:5:1:5:5:1:1) */
/* Ax arg setup according to flags (23=5:5:1:5:5:1:1) */
/* number of optional arguments times OP_JMP should follow */
mrb_aspec ax = GETARG_Ax(i);
int m1 = (ax>>18)&0x1f;
......@@ -1356,7 +1357,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_KARG) {
/* A B C R(A) := kdict[Sym(B)]; if C kdict.rm(Sym(B)) */
/* A B C R(A) := kdict[Syms(B)]; if C kdict.rm(Syms(B)) */
/* if C == 2; raise unless kdict.empty? */
/* OP_JMP should follow to skip init code */
NEXT;
......@@ -1371,7 +1372,7 @@ RETRY_TRY_BLOCK:
i = MKOP_AB(OP_RETURN, GETARG_A(i), OP_R_NORMAL);
/* fall through */
CASE(OP_RETURN) {
/* A return R(A) */
/* A B return R(A) (B=normal,in-block return/break) */
if (mrb->exc) {
mrb_callinfo *ci;
int eidx;
......@@ -1509,7 +1510,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_TAILCALL) {
/* A B C return call(R(A),Sym(B),R(A+1),... ,R(A+C-1)) */
/* A B C return call(R(A),Syms(B),R(A+1),... ,R(A+C+1)) */
int a = GETARG_A(i);
int n = GETARG_C(i);
struct RProc *m;
......@@ -1944,7 +1945,7 @@ RETRY_TRY_BLOCK:
} while(0)
CASE(OP_EQ) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:==,C=1)*/
/* A B C R(A) := R(A)==R(A+1) (Syms[B]=:==,C=1)*/
int a = GETARG_A(i);
if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {
SET_TRUE_VALUE(regs[a]);
......@@ -1970,14 +1971,14 @@ RETRY_TRY_BLOCK:
}
CASE(OP_GT) {
/* A B C R(A) := R(A)<R(A+1) (Syms[B]=:<,C=1)*/
/* A B C R(A) := R(A)>R(A+1) (Syms[B]=:>,C=1)*/
int a = GETARG_A(i);
OP_CMP(>);
NEXT;
}
CASE(OP_GE) {
/* A B C R(A) := R(A)<=R(A+1) (Syms[B]=:<=,C=1)*/
/* A B C R(A) := R(A)>=R(A+1) (Syms[B]=:>=,C=1)*/
int a = GETARG_A(i);
OP_CMP(>=);
NEXT;
......@@ -2123,7 +2124,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_CLASS) {
/* A B R(A) := newclass(R(A),Sym(B),R(A+1)) */
/* A B R(A) := newclass(R(A),Syms(B),R(A+1)) */
struct RClass *c = 0;
int a = GETARG_A(i);
mrb_value base, super;
......@@ -2141,7 +2142,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_MODULE) {
/* A B R(A) := newmodule(R(A),Sym(B)) */
/* A B R(A) := newmodule(R(A),Syms(B)) */
struct RClass *c = 0;
int a = GETARG_A(i);
mrb_value base;
......@@ -2202,7 +2203,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_METHOD) {
/* A B R(A).newmethod(Sym(B),R(A+1)) */
/* A B R(A).newmethod(Syms(B),R(A+1)) */
int a = GETARG_A(i);
struct RClass *c = mrb_class_ptr(regs[a]);
......@@ -2219,7 +2220,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_TCLASS) {
/* A B R(A) := target_class */
/* A R(A) := target_class */
if (!mrb->c->ci->target_class) {
mrb_value exc = mrb_exc_new_str_lit(mrb, E_TYPE_ERROR, "no target class or module");
mrb->exc = mrb_obj_ptr(exc);
......@@ -2238,7 +2239,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_DEBUG) {
/* A debug print R(A),R(B),R(C) */
/* A B C debug print R(A),R(B),R(C) */
#ifdef ENABLE_DEBUG
mrb->debug_op_hook(mrb, irep, pc, regs);
#else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment