// SPDX-License-Identifier: MIT OR MPL-2.0 OR LGPL-2.1-or-later OR GPL-2.0-or-later // Copyright 2010, SIL International, All rights reserved.
#pragma once // This file will be pulled into and integrated into a machine implmentation // DO NOT build directly and under no circumstances ever #include headers in // here or you will break the direct_machine. // // Implementers' notes // ================== // You have access to a few primitives and the full C++ code: // declare_params(n) Tells the interpreter how many bytes of parameter // space to claim for this instruction uses and // initialises the param pointer. You *must* before the // first use of param. // use_params(n) Claim n extra bytes of param space beyond what was // claimed using delcare_param. // param A const byte pointer for the parameter space claimed by // this instruction. // binop(op) Implement a binary operation on the stack using the // specified C++ operator. // NOT_IMPLEMENTED Any instruction body containing this will exit the // program with an assertion error. Instructions that are // not implemented should also be marked NILOP in the // opcodes tables this will cause the code class to spot // them in a live code stream and throw a runtime_error // instead. // push(n) Push the value n onto the stack. // pop() Pop the top most value and return it. // // You have access to the following named fast 'registers': // sp = The pointer to the current top of stack, the last value // pushed. // seg = A reference to the Segment this code is running over. // is = The current slot index // isb = The original base slot index at the start of this rule // isf = The first positioned slot // isl = The last positioned slot // ip = The current instruction pointer // endPos = Position of advance of last cluster // dir = writing system directionality of the font
#define binop(op) const uint32 a = pop(); *sp = uint32(*sp) op a #define sbinop(op) const int32 a = pop(); *sp = int32(*sp) op a #define use_params(n) dp += n
STARTOP(insert) if (smap.decMax() <= 0) DIE;
Slot *newSlot = seg.newSlot(); if (!newSlot) DIE;
Slot *iss = is; while (iss && iss->isDeleted()) iss = iss->next(); if (!iss)
{ if (seg.last())
{
seg.last()->next(newSlot);
newSlot->prev(seg.last());
newSlot->before(seg.last()->before());
seg.last(newSlot);
} else
{
seg.first(newSlot);
seg.last(newSlot);
}
} elseif (iss->prev())
{
iss->prev()->next(newSlot);
newSlot->prev(iss->prev());
newSlot->before(iss->prev()->after());
} else
{
newSlot->prev(NULL);
newSlot->before(iss->before());
seg.first(newSlot);
}
newSlot->next(iss); if (iss)
{
iss->prev(newSlot);
newSlot->originate(iss->original());
newSlot->after(iss->before());
} elseif (newSlot->prev())
{
newSlot->originate(newSlot->prev()->original());
newSlot->after(newSlot->prev()->after());
} else
{
newSlot->originate(seg.defaultOriginal());
} if (is == smap.highwater())
smap.highpassed(false);
is = newSlot;
seg.extendLength(1); if (map != &smap[-1])
--map;
ENDOP
STARTOP(delete_) if (!is || is->isDeleted()) DIE
is->markDeleted(true); if (is->prev())
is->prev()->next(is->next()); else
seg.first(is->next());
if (is->next())
is->next()->prev(is->prev()); else
seg.last(is->prev());
if (is == smap.highwater())
smap.highwater(is->next()); if (is->prev())
is = is->prev();
seg.extendLength(-1);
ENDOP
STARTOP(assoc)
declare_params(1); unsignedint num = uint8(*param); const int8 * assocs = reinterpret_cast<const int8 *>(param+1);
use_params(num); int max = -1; int min = -1;
while (num-- > 0)
{ int sr = *assocs++;
slotref ts = slotat(sr); if (ts && (min == -1 || ts->before() < min)) min = ts->before(); if (ts && ts->after() > max) max = ts->after();
} if (min > -1) // implies max > -1
{
is->before(min);
is->after(max);
}
ENDOP
STARTOP(cntxt_item) // It turns out this is a cunningly disguised condition forward jump.
declare_params(3); constint is_arg = int8(param[0]); const size_t iskip = uint8(param[1]),
dskip = uint8(param[2]);
if (mapb + is_arg != map)
{
ip += iskip;
dp += dskip;
push(true);
}
ENDOP
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.