10. Line16 Runt Words

10.1. Runt Loader

All runt words are loaded with the function line16_runt_loader. It is loaded at init time.

<<line16_function_declarations>>=
static int line16_runt_loader(monolith_d *m);
<<line16_functions>>=
<<line16_runt_functions>>
static int line16_runt_loader(monolith_d *m)
{
<<line16_runt_keywords>>
    monolith_runt_mark_set(m);
    return RUNT_OK;
}
<<line16_runtime_init>>=
line16_runt_loader(m);

10.2. line16

Call this once inside a graforge patch. Computes the line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16", 6,
                      rproc_line16,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    rgf_param in;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    /* runt_stacklet *out; */
    monolith_page *pg;
    page_line16_d *line16;

    m = runt_to_cptr(p);
    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);

    name = runt_to_string(s->p);

    rc = rgf_get_param(vm, &in);
    RUNT_ERROR_CHECK(rc);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_line16(node, line16);

    rgf_set_param(vm, node, &in, 0);
    return RUNT_OK;
}

10.3. line16line

Retrives the line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16line", 10,
                      rproc_line16line,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16line(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    runt_stacklet *out;
    monolith_page *pg;
    page_line16_d *line16;

    m = runt_to_cptr(p);
    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);

    name = runt_to_string(s->p);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    rc = runt_ppush(vm, &out);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_line(node, line16);

    rgf_push_output(vm, node, out, 0);
    return RUNT_OK;
}

10.4. line16gpr

Retrives the line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16gpr", 9,
                      rproc_line16gpr,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16gpr(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    rgf_param in;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    monolith_page *pg;
    page_line16_d *line16;

    m = runt_to_cptr(p);
    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);

    name = runt_to_string(s->p);


    rc = rgf_get_param(vm, &in);
    RUNT_ERROR_CHECK(rc);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_gpr(node, line16);

    rgf_set_param(vm, node, &in, 0);
    return RUNT_OK;
}

10.5. line16lpr

Retrives the line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16lpr", 9,
                      rproc_line16lpr,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16lpr(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    rgf_param in;
    rgf_param line;
    rgf_param pos;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    monolith_page *pg;
    page_line16_d *line16;

    m = runt_to_cptr(p);
    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);

    name = runt_to_string(s->p);

    rc = rgf_get_param(vm, &pos);
    RUNT_ERROR_CHECK(rc);

    rc = rgf_get_param(vm, &line);
    RUNT_ERROR_CHECK(rc);

    rc = rgf_get_param(vm, &in);
    RUNT_ERROR_CHECK(rc);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_lpr(node, line16);


    rgf_set_param(vm, node, &in, 0);
    rgf_set_param(vm, node, &line, 1);
    rgf_set_param(vm, node, &pos, 2);
    return RUNT_OK;
}

10.6. line16aux

Retrives the line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16aux", 9,
                      rproc_line16aux,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16aux(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    rgf_param in;
    rgf_param aux;
    rgf_param line;
    rgf_param pos;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    monolith_page *pg;
    page_line16_d *line16;

    m = runt_to_cptr(p);
    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);

    name = runt_to_string(s->p);

    rc = rgf_get_param(vm, &pos);
    RUNT_ERROR_CHECK(rc);

    rc = rgf_get_param(vm, &line);
    RUNT_ERROR_CHECK(rc);

    rc = rgf_get_param(vm, &aux);
    RUNT_ERROR_CHECK(rc);

    rc = rgf_get_param(vm, &in);
    RUNT_ERROR_CHECK(rc);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_aux(node, line16);


    rgf_set_param(vm, node, &in, 0);
    rgf_set_param(vm, node, &aux, 1);
    rgf_set_param(vm, node, &line, 2);
    rgf_set_param(vm, node, &pos, 3);
    return RUNT_OK;
}

10.7. line16lline

Makes a local line.

<<line16_runt_keywords>>=
monolith_runt_keyword(m,
                      "line16lline", 11,
                      rproc_line16lline,
                      m);
<<line16_runt_functions>>=
static runt_int rproc_line16lline(runt_vm *vm, runt_ptr p)
{
    monolith_d *m;
    runt_int rc;
    gf_patch *patch;
    gf_node *node;
    const char *name;
    runt_stacklet *s;
    runt_stacklet *out;
    monolith_page *pg;
    page_line16_d *line16;
    rgf_param in;
    int linepos;
    line16_line *line;


    m = runt_to_cptr(p);

    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);
    name = runt_to_string(s->p);

    rc = runt_monolith_lookup_page(vm, m,
                                   name,
                                   "line16",
                                   is_line16,
                                   &pg);
    RUNT_ERROR_CHECK(rc);

    rc = runt_ppop(vm, &s);
    RUNT_ERROR_CHECK(rc);
    linepos = s->f;

    rc = rgf_get_param(vm, &in);
    RUNT_ERROR_CHECK(rc);


    if (linepos < 0 || linepos >= 16) {
        runt_print(vm,
                   "line position out of range: %d\n",
                   linepos);
    }

    rc = runt_ppush(vm, &out);
    RUNT_ERROR_CHECK(rc);

    line16 = monolith_page_data_get(pg);

    line = &line16->lines[linepos];

    patch = monolith_graforge_get(m);
    rc = gf_patch_new_node(patch, &node);
    GF_RUNT_ERROR_CHECK(rc);
    node_lline(node, line16, line);

    rgf_set_param(vm, node, &in, 0);
    rgf_push_output(vm, node, out, 1);
    return RUNT_OK;
}



prev | home | next