public virtual int Remove(ArrayNI ni, Variant @ref, bool removeall) { int count = 0; IntVector todelete = new IntVector(); int arrayCount = ni.mItems.Count; for (int i = 0; i < arrayCount; i++) { Variant v = ni.mItems[i]; if (@ref.DiscernCompareInternal(v)) { count++; todelete.Add(i); if (!removeall) { break; } } } // list objects up int delCount = todelete.Size(); for (int i_1 = 0; i_1 < delCount; i_1++) { int pos = todelete.Get(i_1); Variant v = ni.mItems[pos]; v.Clear(); } // remove items found for (int i_2 = delCount - 1; i_2 >= 0; i_2--) { ni.mItems.Remove(todelete.Get(i_2)); } todelete = null; return count; }
private void GenerateLineVector() { mLineVector = new IntVector(); mLineLengthVector = new IntVector(); int count = mText.Length; int lastCR = 0; int i; for (i = 0; i < count; i++) { int c = mText[i]; if (c == CARRIAGE_RETURN || c == LINE_FEED) { mLineVector.Add(lastCR); mLineLengthVector.Add(i - lastCR); lastCR = i + 1; if ((i + 1) < count) { c = mText[i + 1]; if (c == CARRIAGE_RETURN || c == LINE_FEED) { i++; lastCR = i + 1; } } } } if (i != lastCR) { mLineVector.Add(lastCR); mLineLengthVector.Add(i - lastCR); } }
/// <exception cref="Kirikiri.Tjs2.VariantException"></exception> public virtual IntVector CheckJumpCode(int start, int end) { IntVector ret = new IntVector(); short[] ca = mCode; if (end <= 0) { end = ca.Length; } if (end > ca.Length) { end = ca.Length; } int size = 0; for (int i = start; i < end; ) { switch (ca[i]) { case VM_NOP: { size = 1; break; } case VM_NF: { size = 1; break; } case VM_CONST: { size = 3; break; } case VM_CP: { size = 3; break; } case VM_CEQ: { size = 3; break; } case VM_CDEQ: { size = 3; break; } case VM_CLT: { size = 3; break; } case VM_CGT: { size = 3; break; } case VM_CHKINS: { size = 3; break; } case VM_LOR: { size = 3; break; } case VM_LOR + 1: { size = 5; break; } case VM_LOR + 2: { size = 5; break; } case VM_LOR + 3: { size = 4; break; } case VM_LAND: { size = 3; break; } case VM_LAND + 1: { size = 5; break; } case VM_LAND + 2: { size = 5; break; } case VM_LAND + 3: { size = 4; break; } case VM_BOR: { size = 3; break; } case VM_BOR + 1: { size = 5; break; } case VM_BOR + 2: { size = 5; break; } case VM_BOR + 3: { size = 4; break; } case VM_BXOR: { size = 3; break; } case VM_BXOR + 1: { size = 5; break; } case VM_BXOR + 2: { size = 5; break; } case VM_BXOR + 3: { size = 4; break; } case VM_BAND: { size = 3; break; } case VM_BAND + 1: { size = 5; break; } case VM_BAND + 2: { size = 5; break; } case VM_BAND + 3: { size = 4; break; } case VM_SAR: { size = 3; break; } case VM_SAR + 1: { size = 5; break; } case VM_SAR + 2: { size = 5; break; } case VM_SAR + 3: { size = 4; break; } case VM_SAL: { size = 3; break; } case VM_SAL + 1: { size = 5; break; } case VM_SAL + 2: { size = 5; break; } case VM_SAL + 3: { size = 4; break; } case VM_SR: { size = 3; break; } case VM_SR + 1: { size = 5; break; } case VM_SR + 2: { size = 5; break; } case VM_SR + 3: { size = 4; break; } case VM_ADD: { size = 3; break; } case VM_ADD + 1: { size = 5; break; } case VM_ADD + 2: { size = 5; break; } case VM_ADD + 3: { size = 4; break; } case VM_SUB: { size = 3; break; } case VM_SUB + 1: { size = 5; break; } case VM_SUB + 2: { size = 5; break; } case VM_SUB + 3: { size = 4; break; } case VM_MOD: { size = 3; break; } case VM_MOD + 1: { size = 5; break; } case VM_MOD + 2: { size = 5; break; } case VM_MOD + 3: { size = 4; break; } case VM_DIV: { size = 3; break; } case VM_DIV + 1: { size = 5; break; } case VM_DIV + 2: { size = 5; break; } case VM_DIV + 3: { size = 4; break; } case VM_IDIV: { size = 3; break; } case VM_IDIV + 1: { size = 5; break; } case VM_IDIV + 2: { size = 5; break; } case VM_IDIV + 3: { size = 4; break; } case VM_MUL: { size = 3; break; } case VM_MUL + 1: { size = 5; break; } case VM_MUL + 2: { size = 5; break; } case VM_MUL + 3: { size = 4; break; } case VM_TT: { size = 2; break; } case VM_TF: { size = 2; break; } case VM_SETF: { size = 2; break; } case VM_SETNF: { size = 2; break; } case VM_LNOT: { size = 2; break; } case VM_BNOT: { size = 2; break; } case VM_ASC: { size = 2; break; } case VM_CHR: { size = 2; break; } case VM_NUM: { size = 2; break; } case VM_CHS: { size = 2; break; } case VM_CL: { size = 2; break; } case VM_INV: { size = 2; break; } case VM_CHKINV: { size = 2; break; } case VM_TYPEOF: { size = 2; break; } case VM_EVAL: { size = 2; break; } case VM_EEXP: { size = 2; break; } case VM_INT: { size = 2; break; } case VM_REAL: { size = 2; break; } case VM_STR: { size = 2; break; } case VM_OCTET: { size = 2; break; } case VM_CCL: { size = 3; break; } case VM_INC: { size = 2; break; } case VM_INC + 1: { size = 4; break; } case VM_INC + 2: { size = 4; break; } case VM_INC + 3: { size = 3; break; } case VM_DEC: { size = 2; break; } case VM_DEC + 1: { size = 4; break; } case VM_DEC + 2: { size = 4; break; } case VM_DEC + 3: { size = 3; break; } case VM_JF: { ret.Add(ca[i + 1] + i); size = 2; break; } case VM_JNF: { ret.Add(ca[i + 1] + i); size = 2; break; } case VM_JMP: { ret.Add(ca[i + 1] + i); size = 2; break; } case VM_CALL: case VM_CALLD: case VM_CALLI: case VM_NEW: { int st; // start of arguments if (ca[i] == VM_CALLD || ca[i] == VM_CALLI) { st = 5; } else { st = 4; } int num = ca[i + st - 1]; // st-1 = argument count if (num == -1) { // omit arg size = st; } else { if (num == -2) { // expand arg st++; num = ca[i + st - 1]; size = st + num * 2; } else { // normal operation size = st + num; } } break; } case VM_GPD: case VM_GPDS: { size = 4; break; } case VM_SPD: case VM_SPDE: case VM_SPDEH: case VM_SPDS: { size = 4; break; } case VM_GPI: case VM_GPIS: { size = 4; break; } case VM_SPI: case VM_SPIE: case VM_SPIS: { size = 4; break; } case VM_SETP: { size = 3; break; } case VM_GETP: { size = 3; break; } case VM_DELD: case VM_TYPEOFD: { size = 4; break; } case VM_DELI: case VM_TYPEOFI: { size = 4; break; } case VM_SRV: { size = 2; break; } case VM_RET: { size = 1; break; } case VM_ENTRY: { ret.Add(ca[i + 1] + i); // catch アドレス size = 3; break; } case VM_EXTRY: { size = 1; break; } case VM_THROW: { size = 2; break; } case VM_CHGTHIS: { size = 3; break; } case VM_GLOBAL: { size = 2; break; } case VM_ADDCI: { size = 3; break; } case VM_REGMEMBER: { size = 1; break; } case VM_DEBUGGER: { size = 1; break; } default: { size = 1; break; break; } } i += size; } return ret; }