1f2d37758SMatthew Dillon /* 2*a977bf87SJoris Giovannangeli * $OpenBSD: stack.c,v 1.11 2009/10/27 23:59:37 deraadt Exp $ 3f2d37758SMatthew Dillon * $DragonFly: src/usr.bin/dc/extern.h,v 1.1 2004/09/20 04:20:39 dillon Exp $ 4f2d37758SMatthew Dillon */ 5f2d37758SMatthew Dillon 6f2d37758SMatthew Dillon /* 7f2d37758SMatthew Dillon * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> 8f2d37758SMatthew Dillon * 9f2d37758SMatthew Dillon * Permission to use, copy, modify, and distribute this software for any 10f2d37758SMatthew Dillon * purpose with or without fee is hereby granted, provided that the above 11f2d37758SMatthew Dillon * copyright notice and this permission notice appear in all copies. 12f2d37758SMatthew Dillon * 13f2d37758SMatthew Dillon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14f2d37758SMatthew Dillon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15f2d37758SMatthew Dillon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16f2d37758SMatthew Dillon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17f2d37758SMatthew Dillon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18f2d37758SMatthew Dillon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19f2d37758SMatthew Dillon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20f2d37758SMatthew Dillon */ 21f2d37758SMatthew Dillon 22f2d37758SMatthew Dillon #include <stdbool.h> 23f2d37758SMatthew Dillon #include "bcode.h" 24f2d37758SMatthew Dillon 25f2d37758SMatthew Dillon 26f2d37758SMatthew Dillon /* inout.c */ 27f2d37758SMatthew Dillon void src_setstream(struct source *, FILE *); 28f2d37758SMatthew Dillon void src_setstring(struct source *, char *); 29f2d37758SMatthew Dillon struct number *readnumber(struct source *, u_int); 30f2d37758SMatthew Dillon void printnumber(FILE *, const struct number *, u_int); 31f2d37758SMatthew Dillon char *read_string(struct source *); 32f2d37758SMatthew Dillon void print_value(FILE *, const struct value *, const char *, u_int); 33f2d37758SMatthew Dillon void print_ascii(FILE *, const struct number *); 34f2d37758SMatthew Dillon 35f2d37758SMatthew Dillon /* mem.c */ 36f2d37758SMatthew Dillon struct number *new_number(void); 37f2d37758SMatthew Dillon void free_number(struct number *); 38f2d37758SMatthew Dillon struct number *dup_number(const struct number *); 39f2d37758SMatthew Dillon void *bmalloc(size_t); 40f2d37758SMatthew Dillon void *brealloc(void *, size_t); 41f2d37758SMatthew Dillon char *bstrdup(const char *p); 42f2d37758SMatthew Dillon void bn_check(int); 43f2d37758SMatthew Dillon void bn_checkp(const void *); 44f2d37758SMatthew Dillon 45f2d37758SMatthew Dillon /* stack.c */ 46f2d37758SMatthew Dillon void stack_init(struct stack *); 47f2d37758SMatthew Dillon void stack_free_value(struct value *); 48f2d37758SMatthew Dillon struct value *stack_dup_value(const struct value *, struct value *); 49f2d37758SMatthew Dillon void stack_swap(struct stack *); 50*a977bf87SJoris Giovannangeli size_t stack_size(const struct stack *); 51f2d37758SMatthew Dillon void stack_dup(struct stack *); 52f2d37758SMatthew Dillon void stack_pushnumber(struct stack *, struct number *); 53f2d37758SMatthew Dillon void stack_pushstring(struct stack *stack, char *); 54f2d37758SMatthew Dillon void stack_push(struct stack *, struct value *); 55f2d37758SMatthew Dillon void stack_set_tos(struct stack *, struct value *); 56f2d37758SMatthew Dillon struct value *stack_tos(const struct stack *); 57f2d37758SMatthew Dillon struct value *stack_pop(struct stack *); 58f2d37758SMatthew Dillon struct number *stack_popnumber(struct stack *); 59f2d37758SMatthew Dillon char * stack_popstring(struct stack *); 60f2d37758SMatthew Dillon void stack_clear(struct stack *); 61f2d37758SMatthew Dillon void stack_print(FILE *, const struct stack *, const char *, 62f2d37758SMatthew Dillon u_int base); 63f2d37758SMatthew Dillon void frame_assign(struct stack *, size_t, const struct value *); 64f2d37758SMatthew Dillon struct value * frame_retrieve(const struct stack *, size_t); 65f2d37758SMatthew Dillon /* void frame_free(struct stack *); */ 66