From ec719da2c52f1a2f724be7f914b8e197af0b6035 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Sat, 7 Apr 2018 11:05:26 -0500 Subject: [PATCH] Remove unused vm_reflect files --- include/vm_reflect.h | 72 -------------------------------------------- src/vm_reflect.c | 64 --------------------------------------- 2 files changed, 136 deletions(-) delete mode 100644 include/vm_reflect.h delete mode 100644 src/vm_reflect.c diff --git a/include/vm_reflect.h b/include/vm_reflect.h deleted file mode 100644 index eeecde2..0000000 --- a/include/vm_reflect.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef _VM_REFLECT_H_ -#define _VM_REFLECT_H_ - -#include - -/* - * Some forward decls for vm_reflect - */ -struct vm_reflect; -typedef struct vm_reflect vm_reflect; - -/* - * A reflect function, mostly helpful in the struct definition itself as - * well as a function decls and defns. A reflect function would accept a - * reflect object and use that to figure out what it's talking about. - */ -typedef void (*vm_reflect_fn)(vm_reflect *); - -struct vm_reflect { - /* - * These are the machine and CPU objects that the reflect system - * would want to work with. - */ - void *machine; - void *cpu; - - /* - * Where information that we print will go to. - */ - FILE *stream; - - /* - * Print out information about the machine and CPU, respectively. - */ - vm_reflect_fn cpu_info; - vm_reflect_fn machine_info; - - /* - * This function will pause or resume operation of the virtual machine. - */ - vm_reflect_fn pause; - - /* - * Turn on, or off, disassembly of the instructions being executed. - */ - vm_reflect_fn disasm; - - /* - * Eventually we will have the ability to load and save state to a - * file mechanism (probably not the one defined as `stream` above). - */ -#if 0 - vm_reflect_fn save_state; - vm_reflect_fn load_state; -#endif -}; - -/* - * Allow us to either declare or define a new reflect function that can - * be hooked into a reflect struct - */ -#define REFLECT(x) \ - void x(vm_reflect *ref) - -extern int vm_reflect_cpu_info(vm_reflect *); -extern int vm_reflect_disasm(vm_reflect *); -extern int vm_reflect_machine_info(vm_reflect *); -extern int vm_reflect_pause(vm_reflect *); -extern vm_reflect *vm_reflect_create(); -extern void vm_reflect_free(vm_reflect *); - -#endif diff --git a/src/vm_reflect.c b/src/vm_reflect.c deleted file mode 100644 index f7bce27..0000000 --- a/src/vm_reflect.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * vm_reflect.c - * - * Here we have support for reflection, or perhaps meta-manipulation, of - * the virtual machine. You can create hooks to stop the machine, or - * disassemble opcodes from it, or handle state. - */ - -#include - -#include "log.h" -#include "vm_di.h" -#include "vm_reflect.h" - -/* - * Create a new vm_reflect struct with the given machine, cpu and - * stream. - */ -vm_reflect * -vm_reflect_create() -{ - vm_reflect *ref; - - ref = malloc(sizeof(vm_reflect)); - if (ref == NULL) { - log_crit("Could not allocate memory for vm_reflect"); - return NULL; - } - - ref->machine = vm_di_get(VM_MACHINE); - ref->cpu = vm_di_get(VM_CPU); - ref->stream = vm_di_get(VM_OUTPUT); - - ref->cpu_info = NULL; - ref->machine_info = NULL; - ref->pause = NULL; - ref->disasm = NULL; - - return ref; -} - -/* - * Free a vm_reflect struct that we created earlier - */ -void -vm_reflect_free(vm_reflect *ref) -{ - // Not much to this--just going to free the main memory chunk - free(ref); -} - -/* - * All of the reflect functions do essentially the same thing--at least, - * right now they do. - */ -#define REFLECT_HANDLER(x) \ - int vm_reflect_##x(vm_reflect *ref) { \ - if (ref == NULL) ref = (vm_reflect *)vm_di_get(VM_REFLECT); \ - if (ref->x == NULL) return ERR_INVALID; ref->x(ref); return OK; } - -REFLECT_HANDLER(cpu_info); // ignore docblock -REFLECT_HANDLER(machine_info); // ignore docblock -REFLECT_HANDLER(pause); // ignore docblock -REFLECT_HANDLER(disasm); // ignore docblock