Exemplo n.º 1
0
void
CRB_set_command_line_args(CRB_Interpreter *interpreter,
                          int argc, char **argv)
{
    int i;
    CRB_Char *wc_str;
    CRB_Value args;
    CRB_Value elem;

    args.type = CRB_ARRAY_VALUE;
    args.u.object = crb_create_array_i(interpreter, argc);
    CRB_push_value(interpreter, &args);

    for (i = 0; i < argc; i++) {
        wc_str = CRB_mbstowcs_alloc(interpreter, NULL, 0, argv[i]);
        if (wc_str == NULL) {
            fprintf(stderr, "bad command line argument(%dth)", i);
            return;
        }
        elem.type = CRB_STRING_VALUE;
        elem.u.object = crb_create_crowbar_string_i(interpreter, wc_str);
        CRB_array_set(interpreter, NULL, args.u.object, i, &elem);
    }
    CRB_add_global_variable(interpreter, "ARGS", &args, CRB_TRUE);

    CRB_pop_value(interpreter);
}
Exemplo n.º 2
0
CRB_Object *
CRB_create_array(CRB_Interpreter *inter, CRB_LocalEnvironment *env,
                 int size)
{
    CRB_Object *ret;

    ret = crb_create_array_i(inter, size);
    add_ref_in_native_method(env, ret);

    return ret;
}
Exemplo n.º 3
0
static void
eval_array_expression(SIMCAR_Interpreter *inter,
                      SIMCAR_LocalEnvironment *env, ExpressionList *list)
{
    SIMCAR_Value   v;
    int         size;
    ExpressionList *pos;
    int         i;

    size = 0;
    for (pos = list; pos; pos = pos->next) {
        size++;
    }
    v.type = SIMCAR_ARRAY_VALUE;
    v.u.object = crb_create_array_i(inter, size);
    push_value(inter, &v);

    for (pos = list, i = 0; pos; pos = pos->next, i++) {
        eval_expression(inter, env, pos->expression);
        v.u.object->u.array.array[i] = pop_value(inter);
    }

}