/* <mask> .instopped <result> true */ static int zinstopped(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint count; check_type(*op, t_integer); count = count_to_stopped(i_ctx_p, op->value.intval); if (count) { push(1); op[-1] = *ref_stack_index(&e_stack, count - 2); /* default result */ make_true(op); } else make_false(op); return 0; }
/* <bool> <proc> if - */ int zif(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_proc(*op); check_type(op[-1], t_boolean); if (op[-1].value.boolval) { check_estack(1); ++esp; ref_assign(esp, op); esfile_check_cache(); } pop(2); return o_push_estack; }
/* <dict> <key> undef - */ static int zundef(i_ctx_t *i_ctx_p) { os_ptr op = osp; os_ptr op1 = op - 1; int code; check_type(*op1, t_dictionary); if (i_ctx_p->in_superexec == 0) check_dict_write(*op1); code = idict_undef(op1, op); if (code < 0 && code != gs_error_undefined) /* ignore undefined error */ return code; pop(2); return 0; }
/* <int> .setlanguagelevel - */ static int zsetlanguagelevel(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code = 0; check_type(*op, t_integer); if (op->value.intval != LANGUAGE_LEVEL) { code = set_language_level(i_ctx_p, (int)op->value.intval); if (code < 0) return code; } LANGUAGE_LEVEL = op->value.intval; pop(1); return code; }
BOOL Bytes_length(MVALUE** stack_ptr, MVALUE* lvar, sVMInfo* info, CLObject vm_type, sCLClass* klass) { CLObject self; self = lvar->mObjectValue.mValue; if(!check_type(self, gBytesTypeObject, info)) { vm_mutex_unlock(); return FALSE; } (*stack_ptr)->mObjectValue.mValue = create_int_object(CLBYTES(self)->mLen); (*stack_ptr)++; return TRUE; }
static bool dynamic_value_object(compile_t* c, LLVMValueRef object, LLVMValueRef desc, ast_t* pattern, LLVMBasicBlockRef next_block) { // Get the type of the right-hand side of the pattern's eq() function. ast_t* param_type = eq_param_type(pattern); // Build a base pointer that skips the object header. LLVMValueRef ptr = gendesc_ptr_to_fields(c, object, desc); // Check the runtime type. We pass a pointer to the fields because we may // still need to match a tuple type inside a type expression. if(!check_type(c, ptr, desc, param_type, next_block)) return false; return check_value(c, pattern, param_type, object, next_block); }
static bool check_isect(compile_t* c, LLVMValueRef ptr, LLVMValueRef desc, ast_t* pattern_type, LLVMBasicBlockRef next_block) { // We have to match all component types. ast_t* child = ast_child(pattern_type); while(child != NULL) { if(!check_type(c, ptr, desc, child, next_block)) return false; child = ast_sibling(child); } return true; }
/* <string> <bool> .setdebug - */ static int zsetdebug(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_read_type(op[-1], t_string); check_type(*op, t_boolean); { int i; for (i = 0; i < r_size(op - 1); i++) gs_debug[op[-1].value.bytes[i] & 127] = op->value.boolval; } pop(2); return 0; }
/* <file> <int> .unread - */ static int zunread(i_ctx_t *i_ctx_p) { os_ptr op = osp; stream *s; ulong ch; check_read_file(s, op - 1); check_type(*op, t_integer); ch = op->value.intval; if (ch > 0xff) return_error(e_rangecheck); if (sungetc(s, (byte) ch) < 0) return_error(e_ioerror); pop(2); return 0; }
/* <obj> <result> <mask> .stopped <result> */ static int zzstopped(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_type(*op, t_integer); check_op(3); /* Mark the execution stack, and push the default result */ /* in case control returns normally. */ check_estack(5); push_mark_estack(es_stopped, no_cleanup); *++esp = op[-1]; /* save the result */ *++esp = *op; /* save the signal mask */ push_op_estack(stopped_push); push_op_estack(zexec); /* execute the operand */ pop(2); return o_push_estack; }
BOOL Range_tail(MVALUE** stack_ptr, MVALUE* lvar, sVMInfo* info, CLObject vm_type) { CLObject self; CLObject new_obj; int tail_value; self = lvar->mObjectValue.mValue; // self if(!check_type(self, gRangeTypeObject, info)) { return FALSE; } (*stack_ptr)->mObjectValue.mValue = CLRANGE(self)->mTail; // push result (*stack_ptr)++; return TRUE; }
/* * <int> .repeatform - */ static int zrepeatform(i_ctx_t *i_ctx_p) { os_ptr op = osp; gx_device *cdev = gs_currentdevice_inline(igs); int code; gs_form_template_t tmplate; float BBox[4], Matrix[6]; check_type(*op, t_integer); code = read_matrix(imemory, op - 2, &tmplate.CTM); if (code < 0) return code; code = dict_floats_param(imemory, op - 1, "BBox", 4, BBox, NULL); if (code < 0) return code; if (code == 0) return_error(gs_error_undefined); tmplate.BBox.p.x = BBox[0]; tmplate.BBox.p.y = BBox[1]; code = dict_floats_param(imemory, op - 1, "Matrix", 6, Matrix, NULL); if (code < 0) return code; if (code == 0) return_error(gs_error_undefined); tmplate.form_matrix.xx = Matrix[0]; tmplate.form_matrix.xy = Matrix[1]; tmplate.form_matrix.yx = Matrix[2]; tmplate.form_matrix.yy = Matrix[3]; tmplate.form_matrix.tx = Matrix[4]; tmplate.form_matrix.ty = Matrix[5]; tmplate.pcpath = igs->clip_path; tmplate.FormID = op->value.intval; code = dev_proc(cdev, dev_spec_op)(cdev, gxdso_repeat_form, &tmplate, sizeof(gs_form_template_t)); pop(3); return code; }
int zrepeat(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_proc(*op); check_type(op[-1], t_integer); if (op[-1].value.intval < 0) return_error(e_rangecheck); check_estack(5); /* Push a mark, the count, and the procedure, and invoke */ /* the continuation operator. */ push_mark_estack(es_for, no_cleanup); *++esp = op[-1]; *++esp = *op; make_op_estack(esp + 1, repeat_continue); pop(2); return repeat_continue(i_ctx_p); }
/* *op is the index within the string, or 0 for an interrupt after a CR. */ static int zreadline_continue(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint size = r_size(op - 1); uint start; int code; check_type(*op, t_integer); if (op->value.intval < 0 || op->value.intval > size) return_error(e_rangecheck); start = (uint) op->value.intval; code = (start == 0 ? zreadline_at(i_ctx_p, op - 1, size, true) : zreadline_at(i_ctx_p, op - 1, start, false)); if (code >= 0) pop(1); return code; }
/* *op contains the index within the string and the odd flag. */ static int zreadhexstring_continue(i_ctx_t *i_ctx_p) { os_ptr op = osp; int code, length, odd; check_type(*op, t_integer); length = op->value.intval & 0xFFFFFF; odd = op->value.intval >> 24; if (length > r_size(op - 1) || odd < -1 || odd > 0xF) return_error(e_rangecheck); check_write_type(op[-1], t_string); code = zreadhexstring_at(i_ctx_p, op - 1, (uint)length, odd); if (code >= 0) pop(1); return code; }
/* <bool> .pathbbox <llx> <lly> <urx> <ury> */ static int z1pathbbox(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_rect box; int code; check_type(*op, t_boolean); code = gs_upathbbox(igs, &box, op->value.boolval); if (code < 0) return code; push(3); make_real(op - 3, box.p.x); make_real(op - 2, box.p.y); make_real(op - 1, box.q.x); make_real(op, box.q.y); return 0; }
/* <device> <keep_open> .copydevice2 <newdevice> */ static int zcopydevice2(i_ctx_t *i_ctx_p) { os_ptr op = osp; gx_device *new_dev; int code; check_read_type(op[-1], t_device); check_type(*op, t_boolean); code = gs_copydevice2(&new_dev, op[-1].value.pdevice, op->value.boolval, imemory); if (code < 0) return code; new_dev->memory = imemory; make_tav(op - 1, t_device, icurrent_space | a_all, pdevice, new_dev); pop(1); return 0; }
/* <int> .getdevice <device> */ static int zgetdevice(i_ctx_t *i_ctx_p) { os_ptr op = osp; const gx_device *dev; check_type(*op, t_integer); if (op->value.intval != (int)(op->value.intval)) return_error(e_rangecheck); /* won't fit in an int */ dev = gs_getdevice((int)(op->value.intval)); if (dev == 0) /* index out of range */ return_error(e_rangecheck); /* Device prototypes are read-only; */ /* the cast is logically unnecessary. */ make_tav(op, t_device, avm_foreign | a_readonly, pdevice, (gx_device *) dev); return 0; }
/* <file> <int> write - */ int zwrite(i_ctx_t *i_ctx_p) { os_ptr op = osp; stream *s; byte ch; int status; check_write_file(s, op - 1); check_type(*op, t_integer); ch = (byte) op->value.intval; status = sputc(s, (byte) ch); if (status >= 0) { pop(2); return 0; } return handle_write_status(i_ctx_p, status, op - 1, NULL, zwrite); }
/* <dict> <key> .knownget false */ static int zknownget(i_ctx_t *i_ctx_p) { os_ptr op = osp; register os_ptr op1 = op - 1; ref *pvalue; check_type(*op1, t_dictionary); check_dict_read(*op1); if (dict_find(op1, op, &pvalue) <= 0) { make_false(op1); pop(1); } else { ref_assign(op1, pvalue); make_true(op); } return 0; }
/* <dict> .settrapparams - */ static int zsettrapparams(i_ctx_t *i_ctx_p) { os_ptr op = osp; dict_param_list list; int code; check_type(*op, t_dictionary); code = dict_param_list_read(&list, op, NULL, false, iimemory); if (code < 0) return code; code = gs_settrapparams(&i_trap_params, (gs_param_list *) & list); iparam_list_release(&list); if (code < 0) return code; pop(1); return 0; }
void upkg::get_types(void) { int i, j; char readbuf[UPKG_MAX_ORDERS * 4]; for (i = 0; i < hdr->export_count; i++) { if ((j = get_types_isgood(i)) != -1) { reader->seek(exports[i].serial_offset); reader->read(readbuf, 4 * UPKG_MAX_ORDERS); get_type(readbuf, i, j); check_type(i, j); } else { exports[i].type_name = -1; } } }
static bool dynamic_capture_object(compile_t* c, LLVMValueRef object, LLVMValueRef desc, ast_t* pattern, LLVMBasicBlockRef next_block) { ast_t* pattern_type = ast_type(pattern); // Build a base pointer that skips the object header. LLVMValueRef ptr = gendesc_ptr_to_fields(c, object, desc); // Check the runtime type. We pass a pointer to the fields because we may // still need to match a tuple type inside a type expression. if(!check_type(c, ptr, desc, pattern_type, next_block)) return false; // As long as the type is correct, we can assign it, with gen_assign_value() // handling boxing and unboxing. We pass the type of the pattern as the type // of the object. return gen_assign_value(c, pattern, object, pattern_type) != NULL; }
static scp_result resolve_string(sc_memory_context *context, const sc_char *operator_name, const sc_char *parameter_name, scp_operand *param, char **str) { sc_stream *stream; sc_uint32 length = 0, read_length = 0; sc_char *data; if (SCP_ASSIGN == param->param_type) { return print_parameter_error(operator_name, parameter_name, "must have FIXED modifier"); } if (SC_FALSE == sc_memory_is_element(context, param->addr)) { return print_parameter_error(operator_name, parameter_name, "has not value"); } if (SCP_RESULT_FALSE == check_type(context, param->addr, scp_type_link)) { return print_parameter_error(operator_name, parameter_name, "must have link type"); } if (SCP_RESULT_FALSE == check_string_type(context, param->addr)) { return print_parameter_error(operator_name, parameter_name, "must have string format"); } if (SC_RESULT_OK != sc_memory_get_link_content(context, param->addr, &stream)) { return print_parameter_error(operator_name, parameter_name, "content reading error"); } sc_stream_get_length(stream, &length); // extra byte needed for string terminator, which is neither counted nor read from an sc_stream data = calloc(length + 1, sizeof(sc_char)); sc_stream_read_data(stream, data, length, &read_length); sc_stream_free(stream); size_t str_length = strlen(data) + 1; *str = calloc(str_length, sizeof(sc_char)); memcpy(*str, data, str_length); free(data); return SCP_RESULT_TRUE; }
static int test_rename_dir(void) { int err = 0; int res; start_test("rename dir"); res = create_dir(testdir, testdir_files); if (res == -1) return -1; rmdir(testdir2); res = rename(testdir, testdir2); if (res == -1) { PERROR("rename"); cleanup_dir(testdir, testdir_files, 1); return -1; } res = check_nonexist(testdir); if (res == -1) { cleanup_dir(testdir, testdir_files, 1); return -1; } res = check_type(testdir2, S_IFDIR); if (res == -1) { cleanup_dir(testdir2, testdir_files, 1); return -1; } err += check_mode(testdir2, 0755); err += check_dir_contents(testdir2, testdir_files); err += cleanup_dir(testdir2, testdir_files, 0); res = rmdir(testdir2); if (res == -1) { PERROR("rmdir"); return -1; } res = check_nonexist(testdir2); if (res == -1) return -1; if (err) return -1; success(); return 0; }
scp_result check_node_parameter_1(sc_memory_context *context, const sc_char *operator_name, scp_operand *param1) { if (SCP_ASSIGN == param1->param_type) { param1->addr = sc_memory_node_new(context, scp_type_node); } else { if (SC_FALSE == sc_memory_is_element(context, param1->addr)) { return print_error(operator_name, "Parameter 1 has not value"); } if (check_type(context, param1->addr, scp_type_node) == SCP_RESULT_FALSE) { return print_error(operator_name, "Parameter 1 isn't node"); } } return SCP_RESULT_TRUE; }
static inline int read_type_and_machine(struct elf_file *file) { struct ehdr *ehdr = &file->ehdr; int retval = 0; retval = read_be_half_words(file->stream, &ehdr->e_type, 2); if (retval != 0) { error(0, 0, "couldn't read type and machine."); return retval; } retval = check_type(ehdr); if (retval != 0) return retval; retval = check_machine(ehdr); if (retval != 0) return retval; return 0; }
/* Check the operand of a restore. */ static int restore_check_operand(os_ptr op, alloc_save_t ** pasave, gs_dual_memory_t *idmem) { vm_save_t *vmsave; ulong sid; alloc_save_t *asave; check_type(*op, t_save); vmsave = r_ptr(op, vm_save_t); if (vmsave == 0) /* invalidated save */ return_error(e_invalidrestore); sid = op->value.saveid; asave = alloc_find_save(idmem, sid); if (asave == 0) return_error(e_invalidrestore); *pasave = asave; return 0; }
/* <bool> <proc_true> <proc_false> ifelse - */ int zifelse(i_ctx_t *i_ctx_p) { os_ptr op = osp; check_proc(*op); check_proc(op[-1]); check_type(op[-2], t_boolean); check_estack(1); ++esp; if (op[-2].value.boolval) { ref_assign(esp, op - 1); } else { ref_assign(esp, op); } esfile_check_cache(); pop(3); return o_push_estack; }
/* <int> array <array> */ int zarray(i_ctx_t *i_ctx_p) { os_ptr op = osp; uint size; int code; check_type(*op, t_integer); if (op->value.intval < 0) return_error(gs_error_rangecheck); if (op->value.intval > max_array_size) return_error(gs_error_limitcheck); size = op->value.intval; code = ialloc_ref_array((ref *)op, a_all, size, "array"); if (code < 0) return code; refset_null(op->value.refs, size); return 0; }