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