Example #1
0
O_TYPE O_while(O_ARGS)
/* while/for loop */
{
    mpdm_t r = NULL;

    for (mpdm_void(M3); !*f && is_true_uf(M1); mpdm_void(M4)) {
        UF(r);
        r = RF(M2);
    }

    if (*f == 1)
        *f = 0;

    return UFND(r);
}
Example #2
0
O_TYPE O_imulti(O_ARGS)
{
    mpdm_t v = RF(M1);

    if (!*f)
        mpdm_void(M2);

    return UFND(v);
}
Example #3
0
/**
 * mpsl_set_symbol - Sets value to a symbol.
 * @s: symbol name
 * @v: value
 * @l: local symbol table
 *
 * Assigns the value @v to the @s symbol. If the value exists as
 * a local symbol, it's assigned to it; otherwise, it's set as a global
 * symbol (and created if it does not exist).
 */
mpdm_t mpsl_set_symbol(mpdm_t s, mpdm_t v, mpdm_t l)
{
    int n;
    mpdm_t r, p, w;

    mpdm_ref(l);
    mpdm_ref(s);
    mpdm_ref(v);

    /* get the local or global symbol table */
    if ((r = find_local_symtbl(s, l)) == NULL)
        r = mpdm_root();

    /* splits the path, if needed */
    if (MPDM_IS_ARRAY(s))
        p = mpdm_ref(s);
    else
        p = mpdm_ref(mpdm_split_s(s, L"."));

    w = r;

    for (n = 0; w != NULL && n < mpdm_size(p); n++) {
        /* is executable? run it and take its output */
        while (MPDM_IS_EXEC(w))
            w = mpdm_exec(w, NULL, NULL);

        /* last component? */
        if (n == mpdm_size(p) - 1) {
            /* yes; do the setting */
            if (MPDM_IS_HASH(w))
                w = mpdm_hset(w, mpdm_aget(p, n), v);
            else
            if (MPDM_IS_ARRAY(w))
                w = mpdm_aset(w, v, mpdm_ival(mpdm_aget(p, n)));
        }
        else {
            if (MPDM_IS_HASH(w))
                w = mpdm_hget(w, mpdm_aget(p, n));
            else
            if (MPDM_IS_ARRAY(w))
                w = mpdm_aget(w, mpdm_ival(mpdm_aget(p, n)));
            else {
                mpdm_void(w);
                w = NULL;
            }
        }
    }

    mpdm_unref(p);
    mpdm_unref(v);
    mpdm_unref(s);
    mpdm_unref(l);

    return w;
}
Example #4
0
O_TYPE O_multi(O_ARGS)
{
    mpdm_t v = M1;

    if (!*f) {
        mpdm_void(v);
        v = M2;
    }

    return v;
}
Example #5
0
O_TYPE O_or(O_ARGS)
{
    mpdm_t v = M1;
    mpdm_t r;

    if (!mpsl_is_true(v)) {
        mpdm_void(v);
        r = M2;
    }
    else
        r = v;

    return r;
}
Example #6
0
static mpdm_t nc_getkey(mpdm_t args, mpdm_t ctxt)
/* reads a key and converts to an action */
{
    static int shift = 0;
    wchar_t *f = NULL;
    mpdm_t k = NULL;

    /* any pending key? return it */
    if ((k = mp_pending_key()) != NULL)
        return k;

    f = nc_getwch();

    if (f[0] == -1) {
        mpdm_void(mpdm_exec(timer_func, NULL, NULL));
        return NULL;
    }

    if (shift) {
        switch (f[0]) {
        case L'0':
            f = L"f10";
            break;
        case L'1':
            f = L"f1";
            break;
        case L'2':
            f = L"f2";
            break;
        case L'3':
            f = L"f3";
            break;
        case L'4':
            f = L"f4";
            break;
        case L'5':
            f = L"f5";
            break;
        case L'6':
            f = L"f6";
            break;
        case L'7':
            f = L"f7";
            break;
        case L'8':
            f = L"f8";
            break;
        case L'9':
            f = L"f9";
            break;
        case KEY_LEFT:
            f = L"alt-cursor-left";
            break;
        case KEY_RIGHT:
            f = L"alt-cursor-right";
            break;
        case KEY_DOWN:
            f = L"alt-cursor-down";
            break;
        case KEY_UP:
            f = L"alt-cursor-up";
            break;
        case KEY_END:
            f = L"alt-end";
            break;
        case KEY_HOME:
            f = L"alt-home";
            break;
        case L'\r':
            f = L"alt-enter";
            break;
        case L'\e':
            f = L"escape";
            break;
        case KEY_ENTER:
            f = L"alt-enter";
            break;
        case L' ':
            f = L"alt-space";
            break;
        case L'a':
            f = L"alt-a";
            break;
        case L'b':
            f = L"alt-b";
            break;
        case L'c':
            f = L"alt-c";
            break;
        case L'd':
            f = L"alt-d";
            break;
        case L'e':
            f = L"alt-e";
            break;
        case L'f':
            f = L"alt-f";
            break;
        case L'g':
            f = L"alt-g";
            break;
        case L'h':
            f = L"alt-h";
            break;
        case L'i':
            f = L"alt-i";
            break;
        case L'j':
            f = L"alt-j";
            break;
        case L'k':
            f = L"alt-k";
            break;
        case L'l':
            f = L"alt-l";
            break;
        case L'm':
            f = L"alt-m";
            break;
        case L'n':
            f = L"alt-n";
            break;
        case L'o':
            f = L"alt-o";
            break;
        case L'p':
            f = L"alt-p";
            break;
        case L'q':
            f = L"alt-q";
            break;
        case L'r':
            f = L"alt-r";
            break;
        case L's':
            f = L"alt-s";
            break;
        case L't':
            f = L"alt-t";
            break;
        case L'u':
            f = L"alt-u";
            break;
        case L'v':
            f = L"alt-v";
            break;
        case L'w':
            f = L"alt-w";
            break;
        case L'x':
            f = L"alt-x";
            break;
        case L'y':
            f = L"alt-y";
            break;
        case L'z':
            f = L"alt-z";
            break;
        case L'\'':
            f = L"alt-'";
            break;
        case L',':
            f = L"alt-,";
            break;
        case L'-':
            f = L"alt--";
            break;
        case L'.':
            f = L"alt-.";
            break;
        case L'/':
            f = L"alt-/";
            break;
        case L'=':
            f = L"alt-=";
            break;
        }

        shift = 0;
    }
    else {
        switch (f[0]) {