Ejemplo n.º 1
0
/* <array|dict|name|packedarray|string> length <int> */
static int
zlength(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    switch (r_type(op)) {
	case t_array:
	case t_string:
	case t_mixedarray:
	case t_shortarray:
	    check_read(*op);
	    make_int(op, r_size(op));
	    return 0;
	case t_dictionary:
	    check_dict_read(*op);
	    make_int(op, dict_length(op));
	    return 0;
	case t_name: {
	    ref str;

	    name_string_ref(imemory, op, &str);
	    make_int(op, r_size(&str));
	    return 0;
	}
	case t_astruct:
	    if (gs_object_type(imemory, op->value.pstruct) != &st_bytes)
		return_error(e_typecheck);
	    check_read(*op);
	    make_int(op, gs_object_size(imemory, op->value.pstruct));
	    return 0;
	default:
	    return_op_typecheck(op);
    }
}
Ejemplo n.º 2
0
int main(void) {
  ACData tk = make_token("barf");
  ACData n = make_int(3);
  ACData bs = give_binding(tk,n);
  ACData tk2 = make_token("frab");
  ACData n2 = make_int(-3);
  ACData bs2 = give_binding(tk2,n2);
  ACData bs3, bs4;
  ACData t,l;
  bs3 = give_overriding(bs,bs2);
  bs4 = give_disjoint_union(bs3,bs2);
  print_ac_data(bs3);
  t = make_tuple(tk,bs3);
  print_ac_data(t);
  printf("\n");
  l = make_list(tk,bs3);
  print_ac_data(l);
  printf("\n");
  l = lpush(l,l);
  print_ac_data(l);
  printf("\n");
  l = lpop(l);
  print_ac_data(l);
  printf("\n");
  return 0;
}
Ejemplo n.º 3
0
/* - .sizeimageparams <bits/sample> <multiproc> <ncolors> */
static int
zsizeimageparams(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    gx_device *dev = gs_currentdevice(igs);
    int ncomp = dev->color_info.num_components;
    int bps;

    push(3);
    if (device_is_true_color(dev))
        bps = dev->color_info.depth / ncomp;
    else {
        /*
         * Set bps to the smallest allowable number of bits that is
         * sufficient to represent the number of different colors.
         */
        gx_color_value max_value =
            (dev->color_info.num_components == 1 ?
             dev->color_info.max_gray :
             max(dev->color_info.max_gray, dev->color_info.max_color));
        static const gx_color_value sizes[] = {
            1, 2, 4, 8, 12, sizeof(gx_max_color_value) * 8
        };
        int i;

        for (i = 0;; ++i)
            if (max_value <= ((ulong) 1 << sizes[i]) - 1)
                break;
        bps = sizes[i];
    }
    make_int(op - 2, bps);
    make_false(op - 1);
    make_int(op, ncomp);
    return 0;
}
Ejemplo n.º 4
0
// Helper for converting String, Array, Bool, Null or Obj to Dbl|Int.
// Other types (i.e. Int and Double) must be handled outside of this.
TypedNum numericConvHelper(Cell cell) {
  assert(cellIsPlausible(cell));

  switch (cell.m_type) {
    case KindOfUninit:
    case KindOfNull:
      return make_int(0);

    case KindOfBoolean:
      return make_int(cell.m_data.num);

    case KindOfString:
    case KindOfStaticString:
      return stringToNumeric(cell.m_data.pstr);

    case KindOfArray:
      throw_bad_array_operand();

    case KindOfObject:
      return make_int(cell.m_data.pobj->o_toInt64());

    case KindOfResource:
      return make_int(cell.m_data.pres->o_toInt64());

    case KindOfInt64:
    case KindOfDouble:
    case KindOfRef:
    case KindOfClass:
      break;
  }
  not_reached();
}
Ejemplo n.º 5
0
/* Allocate, and prepare to load, the index or tint map. */
int
zcs_begin_map(i_ctx_t *i_ctx_p, gs_indexed_map ** pmap, const ref * pproc,
	      int num_entries,  const gs_color_space * base_space,
	      op_proc_t map1)
{
    gs_memory_t *mem = gs_state_memory(igs);
    int space = imemory_space((gs_ref_memory_t *)mem);
    int num_components = cs_num_components(base_space);
    int num_values = num_entries * num_components;
    gs_indexed_map *map;
    int code = alloc_indexed_map(&map, num_values, mem,
				 "setcolorspace(mapped)");
    es_ptr ep;

    if (code < 0)
	return code;
    *pmap = map;
    /* Map the entire set of color indices.  Since the */
    /* o-stack may not be able to hold N*4096 values, we have */
    /* to load them into the cache as they are generated. */
    check_estack(num_csme + 1);	/* 1 extra for map1 proc */
    ep = esp += num_csme;
    make_int(ep + csme_num_components, num_components);
    make_struct(ep + csme_map, space, map);
    ep[csme_proc] = *pproc;
    make_int(ep + csme_hival, num_entries - 1);
    make_int(ep + csme_index, -1);
    push_op_estack(map1);
    return o_push_estack;
}
Ejemplo n.º 6
0
static Obj *read_expr(void *root) {
    for (;;) {
        int c = getchar();
        if (c == ' ' || c == '\n' || c == '\r' || c == '\t')
            continue;
        if (c == EOF)
            return NULL;
        if (c == ';') {
            skip_line();
            continue;
        }
        if (c == '(')
            return read_list(root);
        if (c == ')')
            return Cparen;
        if (c == '.')
            return Dot;
        if (c == '\'')
            return read_quote(root);
        if (isdigit(c))
            return make_int(root, read_number(c - '0'));
        if (c == '-' && isdigit(peek()))
            return make_int(root, -read_number(0));
        if (isalpha(c) || strchr(symbol_chars, c))
            return read_symbol(root, c);
        error("Don't know how to handle %c", c);
    }
}
Ejemplo n.º 7
0
static Lisp_Object
gtk_color_instance_rgb_components (struct Lisp_Color_Instance *c)
{
  GdkColor *color = COLOR_INSTANCE_GTK_COLOR (c);
  return (list3 (make_int (color->red),
		 make_int (color->green),
		 make_int (color->blue)));
}
Ejemplo n.º 8
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main()
{
  auto f5 = std::bind([](std::unique_ptr<int> & a, std::unique_ptr<int> & b) {
    return add(std::move(a), std::move(b));
  }, make_int(1), make_int(2));

  std::cout << *f5() << std::endl;
  std::cout << *f5() << std::endl;
}
Ejemplo n.º 9
0
/*
 * Return value is Qt if we have dispatched the command,
 * or Qnil if id has not been mapped to a callback.
 * Window procedure may try other targets to route the
 * command if we return nil
 */
Lisp_Object
mswindows_handle_gui_wm_command (struct frame* f, HWND ctrl, LPARAM id)
{
  /* Try to map the command id through the proper hash table */
  Lisp_Object callback, callback_ex, image_instance, frame, event;

  XSETFRAME (frame, f);

  /* #### make_int should assert that --kkm */
  assert (XINT (make_int (id)) == id);

  image_instance = Fgethash (make_int (id), 
			     FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f), Qnil);
  /* It is possible for a widget action to cause it to get out of sync
     with its instantiator. Thus it is necessary to signal this
     possibility. */
  if (IMAGE_INSTANCEP (image_instance))
    XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (image_instance) = 1;
  callback = Fgethash (make_int (id), 
		       FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), Qnil);
  callback_ex = Fgethash (make_int (id), 
			  FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f), Qnil);

  if (!NILP (callback_ex) && !UNBOUNDP (callback_ex))
    {
      event = Fmake_event (Qnil, Qnil);

      XEVENT (event)->event_type = misc_user_event;
      XEVENT (event)->channel = frame;
      XEVENT (event)->timestamp = GetTickCount ();
      XEVENT (event)->event.eval.function = Qeval;
      XEVENT (event)->event.eval.object =
	list4 (Qfuncall, callback_ex, image_instance, event);
    }
  else if (NILP (callback) || UNBOUNDP (callback))
    return Qnil;
  else
    {
      Lisp_Object fn, arg;

      event = Fmake_event (Qnil, Qnil);

      get_gui_callback (callback, &fn, &arg);
      XEVENT (event)->event_type = misc_user_event;
      XEVENT (event)->channel = frame;
      XEVENT (event)->timestamp = GetTickCount ();
      XEVENT (event)->event.eval.function = fn;
      XEVENT (event)->event.eval.object = arg;
    }

  mswindows_enqueue_dispatch_event (event);
  /* The result of this evaluation could cause other instances to change so 
     enqueue an update callback to check this. */
  enqueue_magic_eval_event (update_widget_instances, frame);
  return Qt;
}
void WGraphicsPolygonItem::mouseMoveEvent(WGraphicsSceneMouseEvent* event)
{
	WWorldPointF pos = event->scenePos();
	
	if (isSelected())
	{
		if (event->buttons() & Ws::LeftButton) //drag move
		{
			_dragging = true;

			WWorldPolygonF polygonFrom = draggedPolygon(data()->polygon, scene()->dragStartPos(), event->lastScenePos(), _select_flag);
			WWorldPolygonF polygonTo = draggedPolygon(data()->polygon, scene()->dragStartPos(), event->scenePos(), _select_flag);
			scene()->update(expanded(polygonFrom.boundingRect() | polygonTo.boundingRect() | data()->polygon.boundingRect()));
		}
		else //update select flag (status transfer) 
		{
			int old_flag = _select_flag;
			if (!contains(pos)) //other status ---> none selected
			{
				_select_flag = SF_NONE;
			}
			else
			{
				unsigned i = 0;
				unsigned size = _cp.size();
				for (; i<size; ++i)
				{
					//detect wheter control point is selected
					if (distance(pos, data()->polygon[i]) < CP_RADIUS)
					{
						_select_flag = make_int(i, SF_VERTEX);
						break;
					}
					else if (distance(pos, _cp[i]) < CP_RADIUS) 
					{
						_select_flag = make_int(i, SF_MID);
						break;
					}
				}

				if (i == size) //no control point is selected, that is, content is selected
				{
					_select_flag = SF_CONTENT;
				}
			}

			if (_select_flag != old_flag) //select status changed
			{
				scene()->update(boundingRect());
				event->widget()->setCursor(WCursor(getCursorShape(_select_flag)));
			}
		}
	}
}
Ejemplo n.º 11
0
/* - .currenthalftone <red_freq> ... <gray_proc> 2 */
static int
zcurrenthalftone(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    gs_halftone ht;

    gs_currenthalftone(igs, &ht);
    switch (ht.type) {
        case ht_type_screen:
            push(4);
            make_real(op - 3, ht.params.screen.frequency);
            make_real(op - 2, ht.params.screen.angle);
            op[-1] = istate->screen_procs.gray;
            make_int(op, 1);
            break;
        case ht_type_colorscreen:
            push(13);
            {
                os_ptr opc = op - 12;
                gs_screen_halftone *pht =
                    &ht.params.colorscreen.screens.colored.red;

                make_real(opc, pht->frequency);
                make_real(opc + 1, pht->angle);
                opc[2] = istate->screen_procs.red;

                opc = op - 9;
                pht = &ht.params.colorscreen.screens.colored.green;
                make_real(opc, pht->frequency);
                make_real(opc + 1, pht->angle);
                opc[2] = istate->screen_procs.green;

                opc = op - 6;
                pht = &ht.params.colorscreen.screens.colored.blue;
                make_real(opc, pht->frequency);
                make_real(opc + 1, pht->angle);
                opc[2] = istate->screen_procs.blue;

                opc = op - 3;
                pht = &ht.params.colorscreen.screens.colored.gray;
                make_real(opc, pht->frequency);
                make_real(opc + 1, pht->angle);
                opc[2] = istate->screen_procs.gray;
            }
            make_int(op, 2);
            break;
        default:		/* Screen was set by sethalftone. */
            push(2);
            op[-1] = istate->halftone;
            make_int(op, 0);
            break;
    }
    return 0;
}
Ejemplo n.º 12
0
int
zfor(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    register es_ptr ep;
    int code;
    float params[3];

        /* Mostly undocumented, and somewhat bizarre Adobe behavior discovered	*/
        /* with the CET (28-05) and FTS (124-01) is that the proc is not run	*/
        /* if BOTH the initial value and increment are zero.			*/
    if ((code = float_params(op - 1, 3, params)) < 0)
        return code;
    if ( params[0] == 0.0 && params[1] == 0.0 ) {
        pop(4);		/* don't run the proc */
        return 0;
    }
    check_estack(7);
    ep = esp + 6;
    check_proc(*op);
    /* Push a mark, the control variable set to the initial value, */
    /* the increment, the limit, and the procedure, */
    /* and invoke the continuation operator. */
    if (r_has_type(op - 3, t_integer) &&
        r_has_type(op - 2, t_integer)
        ) {
        make_int(ep - 4, op[-3].value.intval);
        make_int(ep - 3, op[-2].value.intval);
        switch (r_type(op - 1)) {
            case t_integer:
                make_int(ep - 2, op[-1].value.intval);
                break;
            case t_real:
                make_int(ep - 2, (long)op[-1].value.realval);
                break;
            default:
                return_op_typecheck(op - 1);
        }
        if (ep[-3].value.intval >= 0)
            make_op_estack(ep, for_pos_int_continue);
        else
            make_op_estack(ep, for_neg_int_continue);
    } else {
        make_real(ep - 4, params[0]);
        make_real(ep - 3, params[1]);
        make_real(ep - 2, params[2]);
        make_op_estack(ep, for_real_continue);
    }
    make_mark_estack(ep - 5, es_for, no_cleanup);
    ref_assign(ep - 1, op);
    esp = ep;
    pop(4);
    return o_push_estack;
}
Ejemplo n.º 13
0
// (- <integer> ...)
static Obj *prim_minus(void *root, Obj **env, Obj **list) {
    Obj *args = eval_list(root, env, list);
    for (Obj *p = args; p != Nil; p = p->cdr)
        if (p->car->type != TINT)
            error("- takes only numbers");
    if (args->cdr == Nil)
        return make_int(root, -args->car->value);
    int r = args->car->value;
    for (Obj *p = args->cdr; p != Nil; p = p->cdr)
        r -= p->car->value;
    return make_int(root, r);
}
Ejemplo n.º 14
0
static int
zsizeimagebox(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    const gx_device *dev = gs_currentdevice(igs);
    gs_rect srect, drect;
    gs_matrix mat;
    gs_int_rect rect;
    int w, h;
    int code;

    check_type(op[-4], t_integer);
    check_type(op[-3], t_integer);
    check_type(op[-2], t_integer);
    check_type(op[-1], t_integer);
    srect.p.x = op[-4].value.intval;
    srect.p.y = op[-3].value.intval;
    srect.q.x = srect.p.x + op[-2].value.intval;
    srect.q.y = srect.p.y + op[-1].value.intval;
    gs_currentmatrix(igs, &mat);
    gs_bbox_transform(&srect, &mat, &drect);
    /*
     * We want the dimensions of the image as a source, not a
     * destination, so we need to expand it rather than pixround.
     */
    rect.p.x = (int)floor(drect.p.x);
    rect.p.y = (int)floor(drect.p.y);
    rect.q.x = (int)ceil(drect.q.x);
    rect.q.y = (int)ceil(drect.q.y);
    /*
     * Clip the rectangle to the device boundaries, since that's what
     * the NeXT implementation does.
     */
    box_confine(&rect.p.x, &rect.q.x, dev->width);
    box_confine(&rect.p.y, &rect.q.y, dev->height);
    w = rect.q.x - rect.p.x;
    h = rect.q.y - rect.p.y;
    /*
     * The NeXT documentation doesn't specify very clearly what is
     * supposed to be in the matrix: the following produces results
     * that match testing on an actual NeXT system.
     */
    mat.tx -= rect.p.x;
    mat.ty -= rect.p.y;
    code = write_matrix(op, &mat);
    if (code < 0)
        return code;
    make_int(op - 4, rect.p.x);
    make_int(op - 3, rect.p.y);
    make_int(op - 2, w);
    make_int(op - 1, h);
    return 0;
}
Ejemplo n.º 15
0
/* Parse and evaluate match (regex) expressions */
struct val *
eval5(void)
{
	regex_t		rp;
	regmatch_t	rm[2];
	char		errbuf[256];
	int		eval;
	struct val     *l, *r;
	struct val     *v;

	l = eval6();
	while (token == MATCH) {
		nexttoken(1);
		r = eval6();

		/* coerce to both arguments to strings */
		to_string(l);
		to_string(r);

		/* compile regular expression */
		if ((eval = regcomp(&rp, r->u.s, 0)) != 0) {
			regerror(eval, &rp, errbuf, sizeof(errbuf));
			errx(2, "%s", errbuf);
		}

		/* compare string against pattern --  remember that patterns
		   are anchored to the beginning of the line */
		if (regexec(&rp, l->u.s, 2, rm, 0) == 0 && rm[0].rm_so == 0) {
			if (rm[1].rm_so >= 0) {
				*(l->u.s + rm[1].rm_eo) = '\0';
				v = make_str(l->u.s + rm[1].rm_so);

			} else {
				v = make_int((int)(rm[0].rm_eo - rm[0].rm_so));
			}
		} else {
			if (rp.re_nsub == 0) {
				v = make_int(0);
			} else {
				v = make_str("");
			}
		}

		/* free arguments and pattern buffer */
		free_value(l);
		free_value(r);
		regfree(&rp);

		l = v;
	}

	return l;
}
Ejemplo n.º 16
0
int main(void) 
{
	int a[N];
	make_int(a,100);
	int b[N];
	make_int(b,10);
	int c[N];
	int k=2;
	subtraction(a,b,c);
	int i=0;
	for(i=0;i<5;i++)
	printf("%d",c[i]);
	return 0;
}
Ejemplo n.º 17
0
parse_result parse_int_dec(char const * str) {
	if (!str)
		return make_parse_result(NULL, str);
	{
		substring pos=take_if_string(is_digit, fullstr(str));
		substring neg;
		if (0<pos.size)
			return make_parse_result(make_int(atoi(str)), pos.str+pos.size);
		neg=take_if_string(is_digit, fullstr(str+1));
		if (str[1]=='-' && 0<neg.size)
			return make_parse_result(make_int(atoi(str)), neg.str+neg.size+1);
	}
	return make_parse_result(NULL, str);
}
Ejemplo n.º 18
0
/* <string|int> .checkpassword <0|1|2> */
static int
zcheckpassword(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    ref params[2];
    array_param_list list;
    gs_param_list *const plist = (gs_param_list *)&list;
    int result = 0;
    int code = name_ref(imemory, (const byte *)"Password", 8, &params[0], 0);
    password pass;

    if (code < 0)
        return code;
    params[1] = *op;
    array_param_list_read(&list, params, 2, NULL, false, iimemory);
    if (dict_read_password(&pass, systemdict, "StartJobPassword") >= 0 &&
        param_check_password(plist, &pass) == 0
        )
        result = 1;
    if (dict_read_password(&pass, systemdict, "SystemParamsPassword") >= 0 &&
        param_check_password(plist, &pass) == 0
        )
        result = 2;
    iparam_list_release(&list);
    make_int(op, result);
    return 0;
}
Ejemplo n.º 19
0
Obj *prim_negate(Env *env, Obj *root, Obj **list) {
    VAR(args);
    *args = eval_list(env, root, list);
    if ((*args)->car->type != TINT || (*args)->cdr != Nil)
        error("negate takes only one number");
    return make_int(env, root, -(*args)->car->value);
}
Ejemplo n.º 20
0
 Expr* operator()(Array_type const* t)
 {
   double p = t->size();
   double w = 8;
   double b = std::ceil(p / w);
   return make_int(b);
 }
Ejemplo n.º 21
0
 Expr* operator()(Integer_type const* t)
 {
   double p = t->precision();
   double w = 8;
   double b = std::ceil(p / w);
   return make_int(b);
 }
Ejemplo n.º 22
0
CELL func_char_to_integer(CELL frame)
{
	if (!CHARP(FV0)) {
		return make_exception("expects a <character> argument");
	}
	return make_int((unsigned char)GET_CHAR(FV0));
}
Ejemplo n.º 23
0
/* Convert a CID into TT char code or to TT glyph index. */
static bool
TT_char_code_from_CID_no_subst(const gs_memory_t *mem,
                               const ref *Decoding, const ref *TT_cmap, uint nCID, uint *c)
{   ref *DecodingArray, char_code, char_code1, ih, *glyph_index;
    bool found = false;
    int i = nCID % 256, n;

    make_int(&ih, nCID / 256);
    if (dict_find(Decoding, &ih, &DecodingArray) <= 0 ||
            !r_has_type(DecodingArray, t_array) ||
            array_get(mem, DecodingArray, i, &char_code) < 0)
        return false;
    if (r_has_type(&char_code, t_integer))
        n = 1;
    else if (r_has_type(&char_code, t_array)) {
        DecodingArray = &char_code;
        i = 0;
        n = r_size(DecodingArray);
    } else
        return false; /* Must not happen. */
    for (;n--; i++) {
        if (array_get(mem, DecodingArray, i, &char_code1) < 0 ||
            !r_has_type(&char_code1, t_integer))
            return false; /* Must not happen. */
        if (dict_find(TT_cmap, &char_code1, &glyph_index) >= 0 &&
                r_has_type(glyph_index, t_integer)) {
            *c = glyph_index->value.intval;
            found = true;
            if (*c != 0)
                return true;
        }
    }
    return found;
}
Ejemplo n.º 24
0
/*
 * Execute a quit in the case of an exit or stop with no appropriate
 * enclosing control scope (loop or stopped).  The caller has already
 * ensured two free slots on the top of the o-stack.
 */
static int
unmatched_exit(os_ptr op, op_proc_t opproc)
{
    make_oper(op - 1, 0, opproc);
    make_int(op, e_invalidexit);
    return_error(e_Quit);
}
Ejemplo n.º 25
0
void ungcpro_popup_callbacks(LWLIB_ID id)
{
	Lisp_Object lid = make_int(id);
	Lisp_Object this = assq_no_quit(lid, Vpopup_callbacks);
	assert(!NILP(this));
	Vpopup_callbacks = delq_no_quit(this, Vpopup_callbacks);
}
Ejemplo n.º 26
0
/* <file> read -false- */
static int
zread(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    stream *s;
    int ch;

    check_read_file(s, op);
    /* We 'push' first in case of ostack block overflow and the */
    /* usual case is we will need to push anyway. If we get EOF */
    /* we will need to 'pop' and decrement the 'op' pointer.    */
    /* This is required since the 'push' macro might return with*/
    /* stackoverflow which will result in another stack block   */
    /* added on, then the operator being retried. We can't read */
    /* (sgetc) prior to having a place on the ostack to return  */
    /* the character.						*/
    push(1);
    ch = sgetc(s);
    if (ch >= 0) {
	make_int(op - 1, ch);
	make_bool(op, 1);
    } else {
	pop(1);		/* Adjust ostack back from preparatory 'pop' */
	op--;
	if (ch == EOFC) 
	make_bool(op, 0);
    else
	return handle_read_status(i_ctx_p, ch, op, NULL, zread);
    }
    return 0;
}
Ejemplo n.º 27
0
Cell* op_floor::eval_op(Cell* operand) const
{
  Cell* operand_ptr;

  no_of_operands(operand,1,1,true,true);

  operand_ptr = car(operand);

  if (listp(operand_ptr))
  {
    operand_ptr = eval(operand_ptr);
  }
  else if (symbolp(operand_ptr))
  {
    operand_ptr = search_symbol(get_symbol(operand_ptr),true);
  }

  if (doublep(operand_ptr))
  {
    return make_int( int(floor(get_double(operand_ptr))) );
  }
  else
  {
    if (operand_ptr != NULL)
       delete operand_ptr;
    throw runtime_error("'floor' only operates with double.");
  }
}
Ejemplo n.º 28
0
cell read_string(char** s) {
    char c = *(*s)++;
    if (c == '\\') {
        c = *(*s)++;
        switch (c) {
        case 'n':
            c = '\n';
            break;
        case 't':
            c = '\t';
            break;
        case '"':
            c = '"';
            break;
        case '\\':
            c = '\\';
            break;
        case '0':
            c = '\0';
            break;
        }
    } else if (c == '"') {
        (*s)++;
        return NIL;
    }

    cell rest = read_string(s);
    return cons(make_int(c), rest);
}
Ejemplo n.º 29
0
/* or if they are identical. */
void
packed_get(const gs_memory_t *mem, const ref_packed * packed, ref * pref)
{
    const ref_packed elt = *packed;
    uint value = elt & packed_value_mask;

    switch (elt >> r_packed_type_shift) {
	default:		/* (shouldn't happen) */
	    make_null(pref);
	    break;
	case pt_executable_operator:
	    op_index_ref(value, pref);
	    break;
	case pt_integer:
	    make_int(pref, (int)value + packed_min_intval);
	    break;
	case pt_literal_name:
	    name_index_ref(mem, value, pref);
	    break;
	case pt_executable_name:
	    name_index_ref(mem, value, pref);
	    r_set_attrs(pref, a_executable);
	    break;
	case pt_full_ref:
	case pt_full_ref + 1:
	    ref_assign(pref, (const ref *)packed);
    }
}
Ejemplo n.º 30
0
static int
zrunandhide(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    es_ptr ep;

    check_op(2);
    if (!r_is_array(op - 1))
        return_op_typecheck(op);
    if (!r_has_attr(op, a_executable))
        return 0;		/* literal object just gets pushed back */
    check_estack(5);
    ep = esp += 5;
    make_mark_estack(ep - 4, es_other, err_end_runandhide); /* error case */
    make_op_estack(ep - 1,  end_runandhide); /* normal case */
    ref_assign(ep, op);
    /* Store the object we are hiding  and it's current tas.type_attrs */
    /* on the exec stack then change to 'noaccess' */
    make_int(ep - 3, (int)op[-1].tas.type_attrs);
    ref_assign(ep - 2, op - 1);
    r_clear_attrs(ep - 2, a_all);
    /* replace the array with a special kind of mark that has a_read access */
    esfile_check_cache();
    pop(2);
    return o_push_estack;
}