/* tripl/arch/interp/interp.c * * This file is part of tripl. * * tripl is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * tripl is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with tripl. If not, see */ #include #include #include #include #include #include #include #include #include #include #include int interp_init(void); __arch int interp_new_var(char *name, long value, int attr); __arch int interp_stack_dump(void); struct klist_node stack; struct arch interp_arch_fn = { .arch_init = interp_init, .arch_new_var = interp_new_var, .arch_stack_dump = interp_stack_dump, .arch_import_shared = NULL, .arch_funcall = NULL, .arch_set_var = NULL }; __arch int interp_init(void) { klist_init(&stack); return 0; } __arch int interp_new_var(char *name, long value, int attr) { push_nr(value, name, attr); return 0; } __arch int interp_stack_dump(void) { struct klist_node *n; int i; ansi_csi_st(stdout, MODE_HIGHLIGHT, FG_LIGHTBLUE, BG_BLACK); printf("stack dump: \n"); ansi_csi_ed(stdout); for (i = 0, n = stack.next; n != &stack; n = n->next, i++) printf("\t%3d: %s \t%ld @ %08x\n", i, (char *) n->payload, n->value, n->xmask); return 0; }