Exemplo n.º 1
0
/**
 * Interpret a tree. Will deal with initialiazation etc
 */
int interpreter(t_ast_element *p) {
    int ret = 0;

    si_init();

    t_object *obj = interpreter_leaf(p);

    if (OBJECT_IS_NUMERICAL(obj)) {
        ret = ((t_numerical_object *)(obj))->value;
    }

    // @TODO: What should we do with the output of this node? Somehow, return it to the caller or somethign?

#ifdef __DEBUG
    t_hash_iter iter;
    ht_iter_rewind(&iter, object_hash);
    while (ht_iter_valid(&iter)) {
        t_object *obj = ht_iter_value(&iter);
        if (obj->type != objectTypeCode && obj->type != objectTypeMethod) {
            DEBUG_PRINT("Object: %20s (%08X) Refcount: %d : %s \n", obj->name, (unsigned int)obj, obj->ref_count, object_debug(obj));
        }
        ht_iter_next(&iter);
    }
#endif

    si_fini();

    return ret;
}
Exemplo n.º 2
0
/* Initialise the workspace; returns nonzero for success, zero otherwise */
unsigned wsinit() {
	_gws.m = malloc(sizeof(*(_gws.m))*meanings);
	_gws.s = malloc(sizeof(*(_gws.s))*signals);
	_gws.mi = mi_init();
	_gws.si = si_init();
	return (_gws.m && _gws.s && _gws.mi && _gws.si);
}
Exemplo n.º 3
0
// Creates and initializes a device.
struct cen64_device *device_create(struct cen64_device *device,
  const struct rom_file *ddipl, const struct rom_file *ddrom,
  const struct rom_file *pifrom, const struct rom_file *cart,
  const struct save_file *eeprom, const struct save_file *sram,
  const struct save_file *flashram, const struct controller *controller,
  bool no_audio, bool no_video) {

  // Initialize the bus.
  device->bus.ai = &device->ai;
  device->bus.dd = &device->dd;
  device->bus.pi = &device->pi;
  device->bus.ri = &device->ri;
  device->bus.si = &device->si;
  device->bus.vi = &device->vi;

  device->bus.rdp = &device->rdp;
  device->bus.rsp = &device->rsp;
  device->bus.vr4300 = &device->vr4300;

  // Initialize the bus.
  if (bus_init(&device->bus)) {
    debug("create_device: Failed to initialize the bus.\n");
    return NULL;
  }

  // Initialize the AI.
  if (ai_init(&device->ai, &device->bus, no_audio)) {
    debug("create_device: Failed to initialize the AI.\n");
    return NULL;
  }

  // Initialize the DD.
  if (dd_init(&device->dd, &device->bus,
    ddipl->ptr, ddrom->ptr, ddrom->size)) {
    debug("create_device: Failed to initialize the DD.\n");
    return NULL;
  }

  // Initialize the PI.
  if (pi_init(&device->pi, &device->bus, cart->ptr, cart->size, sram, flashram)) {
    debug("create_device: Failed to initialize the PI.\n");
    return NULL;
  }

  // Initialize the RI.
  if (ri_init(&device->ri, &device->bus)) {
    debug("create_device: Failed to initialize the RI.\n");
    return NULL;
  }

  // Initialize the SI.
  if (si_init(&device->si, &device->bus, pifrom->ptr,
    cart->ptr, ddipl->ptr != NULL, eeprom->ptr, eeprom->size,
    controller)) {
    debug("create_device: Failed to initialize the SI.\n");
    return NULL;
  }

  // Initialize the VI.
  if (vi_init(&device->vi, &device->bus, no_video)) {
    debug("create_device: Failed to initialize the VI.\n");
    return NULL;
  }

  // Initialize the RDP.
  if (rdp_init(&device->rdp, &device->bus)) {
    debug("create_device: Failed to initialize the RDP.\n");
    return NULL;
  }

  // Initialize the RSP.
  if (rsp_init(&device->rsp, &device->bus)) {
    debug("create_device: Failed to initialize the RSP.\n");
    return NULL;
  }

  // Initialize the VR4300.
  if (vr4300_init(&device->vr4300, &device->bus)) {
    debug("create_device: Failed to initialize the VR4300.\n");
    return NULL;
  }

  return device;
}