Пример #1
0
void lily_list_join(lily_vm_state *vm, uint16_t argc, uint16_t *code)
{
    lily_value **vm_regs = vm->vm_regs;
    lily_value *result_reg = vm_regs[code[0]];
    lily_list_val *lv = vm_regs[code[1]]->value.list;
    const char *delim = "";
    if (argc == 2)
        delim = vm_regs[code[2]]->value.string->string;

    lily_msgbuf *vm_buffer = vm->vm_buffer;
    lily_msgbuf_flush(vm_buffer);

    if (lv->num_values) {
        int i, stop = lv->num_values - 1;
        lily_value **values = lv->elems;
        for (i = 0;i < stop;i++) {
            lily_vm_add_value_to_msgbuf(vm, vm_buffer, values[i]);
            lily_msgbuf_add(vm_buffer, delim);
        }
        if (stop != -1)
            lily_vm_add_value_to_msgbuf(vm, vm_buffer, values[i]);
    }

    lily_move_string(result_reg, lily_new_raw_string(vm_buffer->message));
}
Пример #2
0
/**
var httpmethod: String

This is the method that was used to make the request to the server.
Common values are "GET", and "POST".
*/
static lily_value *load_var_httpmethod(lily_options *options, uint16_t *unused)
{
    lily_value *v = lily_new_empty_value();
    request_rec *r = (request_rec *)options->data;

    lily_move_string(v, lily_new_raw_string(r->method));
    return v;
}