static void _character_dump(FILE* fff)
{
    fprintf(fff, "\n\n==================================== Magic ====================================\n");
    _dump(fff, TV_STAFF, "Staves");
    _dump(fff, TV_WAND, "Wands");
    _dump(fff, TV_ROD, "Rods");
}
Beispiel #2
0
API void dump_pair(pair_t pair) {
  unsee();
  print(CPAREN"(");
  _dump(pair.left);
  print(CSEP" . ");
  _dump(pair.right);
  print(CPAREN")"COFF"\n");
}
Beispiel #3
0
void _dump(be_node *node, ssize_t indent)
{
	if (node == NULL)
	{
		printf("Nothing to dump, node==null\n");
		return;
	}
	dump_indent(indent);
	indent = abs(indent);

	switch (node->type) {
		case BE_STR:
		{
			uint64_t l = node->val.s.len;
			char * str = new char[l + 1];
			memset(str, 0, l + 1);
			memcpy(str, node->val.s.ptr ,l);
			printf("str = %s (len = %lli)\n", str, l);
			delete[] str;
			break;
		}

		case BE_INT:
			printf("int = %lli\n", node->val.i);
			break;

		case BE_LIST:
			puts("list [");

			for (int i = 0; i < node->val.l.count; i++)
				_dump(&node->val.l.elements[i], indent + 1);

			dump_indent(indent);
			puts("]");
			break;

		case BE_DICT:
			puts("dict {");

			for (int i = 0; i < node->val.d.count; i++)
			{
				dump_indent(indent + 1);
				uint64_t l = node->val.d.keys[i].len;
				char * str = new char[l + 1];
				memset(str, 0, l + 1);
				memcpy(str, node->val.d.keys[i].ptr ,l);
				printf("%s => ", str);
				delete[] str;
				_dump(&node->val.d.vals[i], -(indent + 1));
			}

			dump_indent(indent);
			puts("}");
			break;
	}
}
Beispiel #4
0
		inline void __dumpVariable(Variable* variable)
		{
			switch (variable->type->value)
			{
			case Type::INT8:		stream->write((int)*variable->value<char>());				break;
			case Type::UINT8:		stream->write(*variable->value<unsigned char>());			break;
			case Type::INT16:		stream->write(*variable->value<short>());					break;
			case Type::UINT16:		stream->write(*variable->value<unsigned short>());			break;
			case Type::INT32:		stream->write(*variable->value<int>());						break;
			case Type::UINT32:		stream->write(*variable->value<unsigned int>());			break;
			case Type::INT64:		stream->write(*variable->value<int64_t>());					break;
			case Type::UINT64:		stream->write(*variable->value<uint64_t>());				break;
			case Type::FLOAT:		stream->write(hsprintf("%g", *variable->value<float>()));	break;
			case Type::DOUBLE:		stream->write(hsprintf("%g", *variable->value<double>()));	break;
			case Type::BOOL:		stream->write(*variable->value<bool>());					break;
			case Type::HSTR:		_dump(variable->value<hstr>());								break;
			case Type::HVERSION:	_dump(variable->value<hversion>());							break;
			case Type::HENUM:		_dump(variable->value<henum>());							break;
			case Type::GRECT:		_dump(variable->value<grect>());							break;
			case Type::GVEC2:		_dump(variable->value<gvec2>());							break;
			case Type::GVEC3:		_dump(variable->value<gvec3>());							break;
			case Type::OBJECT:		_dump(variable->value<Serializable>());						break;
			case Type::OBJPTR:		_dump(variable->value<Serializable*>());					break;
			case Type::HARRAY:		__dumpContainer(variable);									break;
			case Type::HMAP:		__dumpContainer(variable);									break;
			default:																			break;
			}
		}
Beispiel #5
0
API void dump_line(value_t val) {
  if (val.type == PairType) {
    pair_t pair = get_pair(val);
    unsee();
    _dump(pair.left);
    val = pair.right;
    while (val.type == PairType) {
      print_char(' ');
      pair_t pair = get_pair(val);
      unsee();
      _dump(pair.left);
      val = pair.right;
    }
  }
  print(COFF"\n");
}
Beispiel #6
0
int main() {
  int i;
  int j;
  for (i=0; i<10; i+=1) {
    j = i * 2;
    _print(j);
    _dump();
  }
}
bool PyDumpVisitor::VisitBuffer( const PyBuffer* rep )
{
    _print( "%sBuffer of length %lu:", _pfx(), rep->content().size() );

    _pfxExtend( "  " );
    _dump( _pfx(), &rep->content()[ 0 ], rep->content().size() );
    _pfxWithdraw();

    return true;
}
Beispiel #8
0
void pcp_dumpkeysig(pcp_keysig_t *s) {
  int i;

  printf("Dumping pcp_sigkey_t raw values:\n");

  printf("     type: 0x%02X\n", s->type);
  printf("     size: %ld\n", (long int)s->size);

  printf(" checksum: ");
  for ( i = 0;i < LSHA;++i) printf("%02x",(unsigned int) s->checksum[i]);
  printf("\n");

  _dump("     blob:", s->blob, s->size);
}
Beispiel #9
0
static void
_dump(struct buddy * self, int index , int level) {
	switch (self->tree[index]) {
	case NODE_UNUSED:
		printf("(%d:%d)", _index_offset(index, level, self->level) , 1 << (self->level - level));
		break;
	case NODE_USED:
		printf("[%d:%d]", _index_offset(index, level, self->level) , 1 << (self->level - level));
		break;
	case NODE_FULL:
		printf("{");
		_dump(self, index * 2 + 1 , level+1);
		_dump(self, index * 2 + 2 , level+1);
		printf("}");
		break;
	default:
		printf("(");
		_dump(self, index * 2 + 1 , level+1);
		_dump(self, index * 2 + 2 , level+1);
		printf(")");
		break;
	}
}
Beispiel #10
0
static void *_eventloop(void *arg)
{
    (void)arg;
    msg_t msg, reply;
    msg_t msg_queue[NG_PKTDUMP_MSG_QUEUE_SIZE];

    /* setup the message queue */
    msg_init_queue(msg_queue, NG_PKTDUMP_MSG_QUEUE_SIZE);

    reply.content.value = (uint32_t)(-ENOTSUP);
    reply.type = NG_NETAPI_MSG_TYPE_ACK;

    while (1) {
        msg_receive(&msg);

        switch (msg.type) {
            case NG_NETAPI_MSG_TYPE_RCV:
                puts("PKTDUMP: data received:");
                _dump((ng_pktsnip_t *)msg.content.ptr);
                break;
            case NG_NETAPI_MSG_TYPE_SND:
                puts("PKTDUMP: data to send:");
                _dump((ng_pktsnip_t *)msg.content.ptr);
                break;
            case NG_NETAPI_MSG_TYPE_GET:
            case NG_NETAPI_MSG_TYPE_SET:
                msg_reply(&msg, &reply);
                break;
            default:
                puts("PKTDUMP: received something unexpected");
                break;
        }
    }

    /* never reached */
    return NULL;
}
Beispiel #11
0
void _choose(int start, int* pickedOut, int length, int index, int maxcount)
{   
	if(index==maxcount){
            _dump (pickedOut, start, maxcount);

		return;
      }
      if(!length)
		return; NULL;
      pickedOut[index] = store[start];
      pickedOut[index+1] = start+1;
      
	_choose(start+1, pickedOut, length-1, index+2, maxcount);
      _choose(start+1, pickedOut, length-1, index, maxcount);


}
Beispiel #12
0
/*-------------------------------------------------------------*/
void AzDvect::dump(const AzOut &out, const char *header, 
                   const AzStrArray *sp_row, 
                   int cut_num) const
{
  if (out.isNull()) return; 

  AzPrint o(out); 
  const char *my_header = ""; 
  if (header != NULL) my_header = header; 

  o.writeln(my_header); 

  int nz_num = nonZeroRowNum(); 
  int indent = 3; 
  o.printBegin(my_header, ",", "=", indent); 
  o.print("#row", num); 
  o.print("#non-zero", nz_num); 
  o.printEnd();

  if (cut_num > 0) {
    _dump(out, sp_row, cut_num); 
    return; 
  }

  int ex; 
  for (ex = 0; ex < num; ++ex) {
    if (elm[ex] == 0) {
      continue;  
    }

    /* [row] val (header) */
    o.printBegin("", " ", "=", indent); 
    o.inBrackets(ex, 4); 
    
//    o.print(elm[ex], 5, true); 
    o.print(elm[ex], 20, true); 
    
    if (sp_row != NULL) {
      const char *row_header = sp_row->c_str(ex); 
      o.inParen(row_header); 
    }
    o.printEnd(); 
  }
  o.flush();  
}
Beispiel #13
0
int _can_handler(int argc, char **argv)
{
    if (argc < 2) {
        _can_usage();
        return 1;
    }
    else if (strncmp(argv[1], "list", 5) == 0) {
        return _list(argc - 1, argv + 1);
    }
    else if (strncmp(argv[1], "send", 5) == 0) {
        return _send(argc - 1, argv + 1);
    }
    else if (strncmp(argv[1], "dump", 5) == 0) {
        return _dump(argc - 1, argv + 1);
    }
    else {
        printf("unknown command: %s\n", argv[1]);
        return 1;
    }
    return 0;
}
Beispiel #14
0
int main(int argv, const char **argc)
{
    const char *fname = argc[1];
    struct stat sbuf;
    int fd = open(fname, O_RDONLY);
    struct vparse_state parser;
    char *data;
    int r;

    memset(&parser, 0, sizeof(struct vparse_state));

    fstat(fd, &sbuf);
    data = malloc(sbuf.st_size+1);

    read(fd, data, sbuf.st_size);
    data[sbuf.st_size] = '\0';

    parser.base = data;
    r = vparse_parse(&parser);
    if (r) {
        struct vparse_errorpos pos;
        vparse_fillpos(&parser, &pos);
        printf("error %s at line %d char %d: %.*s ... %.*s <--- (started at line %d char %d)\n",
              vparse_errstr(r), pos.errorline, pos.errorchar,
              20, parser.base + pos.startpos,
              20, parser.base + pos.errorpos - 20,
              pos.startline, pos.startchar);
        return 1;
    }

    _dump(parser.card);

    vparse_free(&parser);

    return 0;
}
Beispiel #15
0
API void dump(value_t val) {
  unsee();
  _dump(val);
  print(COFF"\n");
}
Beispiel #16
0
void
dumpEvent(XKeyEvent * xke)
{
	printf("\n--------------------------------------------\n");
	_dump(type);
	_dump(serial);
	_dump(send_event);
	_dump(display);
	_dump(window);
	_dump(root);
	_dump(subwindow);
	_dump(time);
	_dump(x);
	_dump(y);
	_dump(x_root);
	_dump(y_root);
	_dump(state);
	_dump(keycode);
	_dump(same_screen);
}
Beispiel #17
0
 void AEnvironment::dump()
 {
     _dump();
 }
Beispiel #18
0
static void _dump(VALUE v, int level) {
	char **symbols;
	void *symbols_buffer[1];
	VALUE *ptr;
	size_t i;
	HASH_OBJECT_ENTRY *e;
	HASH_OBJECT_ENTRY **buckets;

	if(IS_NULL(v))  { printf("%*s* null\n",    level << 1, ""); goto exit; }
	if(IS_TRUE(v))  { printf("%*s* true\n",    level << 1, ""); goto exit; }
	if(IS_FALSE(v)) { printf("%*s* false\n",   level << 1, ""); goto exit; }
	if(IS_UNDEF(v)) { printf("%*s* undef\n",   level << 1, ""); goto exit; }
	if(IS_KWARGS_MARKER(v)){ printf("%*s* kwargs marker\n",   level << 1, ""); goto exit; }

	if(IS_INT(v))   { printf("%*s* int %" VALUE_NUM_FMT "\n", level << 1, "", GET_INT(v)); goto exit; }
	if(IS_REAL(v))  { printf("%*s* real %g\n", level << 1, "", REAL_OBJECT_VAL(v)); goto exit; }

	if(IS_STRING(v)) {
		// TODO: properly handle
		//       1. non-printable characters
		//       2. zero character
		printf("%*s* string(len=%zu) %.*s\n", level << 1, "", OBJ_LEN(v), (int) OBJ_LEN(v), (char *)OBJ_DATA_PTR(v));
		goto exit;
	}

	if(IS_NATIVE_METHOD(v)) {
		symbols_buffer[0] = OBJ_DATA_PTR(v);
		symbols = backtrace_symbols(symbols_buffer, 1);
		printf("%*s* native method %s at %p req_params=%d\n", level << 1, "", symbols[0], OBJ_DATA_PTR(v), NATIVE_METHOD_OBJ_N_REQ_PAR(v));
		for(i=0; i<NATIVE_METHOD_OBJ_N_REQ_PAR(v); i++) {
			printf("%*s* required parameter %zu\n", (level+1) << 1, "", i+1);
			_dump(NATIVE_METHOD_OBJ_PARAMS(v)[i*2+0], level+2);
			_dump(NATIVE_METHOD_OBJ_PARAMS(v)[i*2+1], level+2);
		}
		goto exit;
	}

	if(IS_CLOSURE(v)) {
		printf("%*s* closure name=%s ip=%zu locals_including_params=%d req_params=%d opt_params=%d n_uplevels=%d params_flags=%d\n", level << 1, "",
			IS_NULL(CLOSURE_OBJ_NAME(v)) ? "(none)" : obj_to_cstring(CLOSURE_OBJ_NAME(v)),
			CLOSURE_OBJ_IP(v),
			CLOSURE_OBJ_N_LOCALS(v),
			CLOSURE_OBJ_N_REQ_PAR(v),
			CLOSURE_OBJ_N_OPT_PAR(v),
			CLOSURE_OBJ_N_UPLEVELS(v),
			CLOSURE_OBJ_PARAMS_FLAGS(v)
		);
		for(i=0; i<CLOSURE_OBJ_N_REQ_PAR(v); i++) {
			printf("%*s* required parameter %zu (name and type follow)\n", (level+1) << 1, "", i+1);
			_dump(CLOSURE_OBJ_PARAMS(v)[i*2+0], level+2);
			_dump(CLOSURE_OBJ_PARAMS(v)[i*2+1], level+2);
		}
		for(i=0; i<CLOSURE_OBJ_N_OPT_PAR(v); i++) {
			printf("%*s* optional parameter %zu (name, type and default value follow)\n", (level+1) << 1, "", i+1);
			_dump(CLOSURE_OBJ_PARAMS(v)[CLOSURE_OBJ_N_REQ_PAR(v)*2 + i*3 + 0], level+2);
			_dump(CLOSURE_OBJ_PARAMS(v)[CLOSURE_OBJ_N_REQ_PAR(v)*2 + i*3 + 1], level+2);
			_dump(CLOSURE_OBJ_PARAMS(v)[CLOSURE_OBJ_N_REQ_PAR(v)*2 + i*3 + 2], level+2);
		}
		i = CLOSURE_OBJ_N_REQ_PAR(v)*2 + CLOSURE_OBJ_N_OPT_PAR(v)*3;
		if(CLOSURE_OBJ_PARAMS_FLAGS(v) & PARAMS_FLAG_ARR_SPLAT) {
			printf("%*s* array splat parameter\n", (level+1) << 1, "");
			_dump(CLOSURE_OBJ_PARAMS(v)[i+0], level+2);
			_dump(CLOSURE_OBJ_PARAMS(v)[i+1], level+2);
			i+=3;
		}
		if(CLOSURE_OBJ_PARAMS_FLAGS(v) & PARAMS_FLAG_HASH_SPLAT) {
			printf("%*s* hash splat parameter\n", (level+1) << 1, "");
			_dump(CLOSURE_OBJ_PARAMS(v)[i+0], level+2);
			_dump(CLOSURE_OBJ_PARAMS(v)[i+1], level+2);
			i+=3;
		}
		goto exit;
	}

	if(IS_ARRAY(v)) {
		printf("%*s* array of length %zu\n", level << 1, "", OBJ_LEN(v));
		for(i=0, ptr=(VALUE *)OBJ_DATA_PTR(v); i<OBJ_LEN(v); i++, ptr++) {
			_dump(*ptr, level+1);
		}
		goto exit;
	}

	if(IS_HASH(v)) {
		printf("%*s* hash with total of %zu items in %zu buckets at %p\n", level << 1, "", OBJ_LEN(v), HASH_BUCKETS_N(v), OBJ_DATA_PTR(v));
		buckets = OBJ_DATA_PTR(v);
		for(i=0; i<HASH_BUCKETS_N(v); i++) {
			if(!buckets[i]) { continue; }
			printf("%*s* bucket # %zu\n", (level+1) << 1, "", i);
			for(e=buckets[i]; e; e=e->bucket_next) {
				printf("%*s* item at %p with hash() of %u insertion_order_prev=%p insertion_order_next=%p \n", (level+2) << 1, "", (void *)e, e->hash, (void *)e->insertion_order_prev, (void *)e->insertion_order_next);
				printf("%*s* key\n", (level+3) << 1, "");
				_dump(e->key, level+4);
				printf("%*s* value\n", (level+3) << 1, "");
				_dump(e->val, level+4);
			}
		}
		goto exit;
	}

	if(IS_NGS_TYPE(v)) {
		printf("%*s* type (name and optionally constructors and parents follow) id=%" PRIdPTR " ptr=%p\n", level << 1, "", NGS_TYPE_ID(v), IS_NORMAL_TYPE(v) ? v.ptr : 0);
		_dump(NGS_TYPE_NAME(v), level + 1);
		if(level < 3) {
			_dump(NGS_TYPE_FIELDS(v), level + 1);
			_dump(NGS_TYPE_CONSTRUCTORS(v), level + 1);
			_dump(NGS_TYPE_PARENTS(v), level + 1);
		}
		goto exit;
	}

	if(IS_CLIB(v)) {
		printf("%*s* C library (name follows) ptr=%p\n", level << 1, "", OBJ_DATA_PTR(v));
		_dump(CLIB_OBJECT_NAME(v), level + 1);
		goto exit;
	}

	if(IS_CSYM(v)) {
		printf("%*s* C symbol (name and libraray follow) ptr=%p\n", level << 1, "", OBJ_DATA_PTR(v));
		_dump(CSYM_OBJECT_NAME(v), level + 1);
		_dump(CSYM_OBJECT_LIB(v), level + 1);
		goto exit;
	}

	if(IS_NORMAL_TYPE_CONSTRUCTOR(v)) {
		printf("%*s* user type constructor (type optionally follows)\n", level << 1, "");
		if(level < 3) {
			_dump(OBJ_DATA(v), level + 1);
		}
		goto exit;
	}

	if(IS_NORMAL_TYPE_INSTANCE(v)) {
		printf("%*s* user type instance (type and fields optionally follow)\n", level << 1, "");
		// level < 4 so that uncaught exception ImplNotFound could display the type of the arguments
		if(level < 4) {
			_dump(NORMAL_TYPE_INSTANCE_TYPE(v), level + 1);
			_dump(NORMAL_TYPE_INSTANCE_FIELDS(v), level + 1);
		}
		goto exit;
	}

	printf("%*s* (dump not implemented for the object at %p)\n", level << 1, "", OBJ_DATA_PTR(v));

exit:
	return;
}
Beispiel #19
0
// show the screen
bool Display::show ()
{
	if (_quit)
	{
		if (_died)
			_dump();
		return false;
	}

	if (!_window)
		return true;

	// poll events
	SDL_Event e;
	while (SDL_PollEvent(&e))
		switch (e.type)
		{
		case SDL_QUIT:
			quit();
			return false;

		case SDL_KEYDOWN:
			_pressed(e.key.keysym.sym);
			break;

		case SDL_KEYUP:
			_released(e.key.keysym.sym);
			break;
		
		default:
			break;
		}

	// get delta time
	tick_t now = _now();
	tick_t diff = now - _time;
	_time = now;

	// eliminate unusual framerate errors (dragging, etc)
	if (diff > (tick_s / MinFPS))
		diff = tick_s / MinFPS;
	else if (diff == 0)
		diff = tick_s / MaxFPS;

	if (_view != nullptr)
	{
		auto dt = diff / double(tick_s);
		_view->update(this, dt);
		_view->draw(this);
	}
	else
		color(.5f, .8f, 1.f).glApplyClear();

	SDL_GL_SwapWindow(_window);

	
	/* const double sleep_s = 1.0 / 100.0;
	const time_t sleep_t = time_t(tick_s * sleep_s);
	auto n = _now();
	while ((_now() - n) < sleep_t)
		; */

	SDL_Delay(3);

	return true;
}
Beispiel #20
0
void dump(be_node *node)
{
	_dump(node, 0);
}
Beispiel #21
0
 const char* dump() const {
     return _dump().c_str();
 }
Beispiel #22
0
void
buddy_dump(struct buddy * self) {
	_dump(self, 0 , 0);
	printf("\n");
}
Beispiel #23
0
//-----------------------------------------------------------------------------
//
// 命令コマンドを解釈してバイナリに変換
//
//-----------------------------------------------------------------------------
bool encode(char* instName, char* buffer, map<uint32_t, string>& labelNames, uint32_t currentLine, uint32_t& code, bool& useLabel)
{
	uint32_t rs = 0;
	uint32_t rt = 0;
	uint32_t rd = 0;
	uint32_t imm = 0;
	double d = 0;
	char label[MAX_LINE_SIZE];
	char dummy[MAX_LINE_SIZE];

	if (eq(instName, "add"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _add(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "sub"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _sub(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "mul"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _mul(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "and"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _and(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "or"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _or(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "nor"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _nor(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "xor"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _xor(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "addi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _addi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "subi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _subi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "muli"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _muli(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "slli"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _slli(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "srai"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _srai(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "andi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _andi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _ori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "nori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _nori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "xori"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _xori(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fadd"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fadd(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fsub"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fsub(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmul"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fmul(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmuln"))
	{
		int n = sscanf(buffer, formFFF, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fmuln(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "finv"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _finv(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fsqrt"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fsqrt(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmov"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fmov(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fneg"))
	{
		int n = sscanf(buffer, formFF, dummy, &rd, &rs);
		if (n == 3)
		{
			code = _fneg(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "imovf"))
	{
		int n = sscanf(buffer, formFR, dummy, &rt, &rs);
		if (n == 3)
		{
			code = _imovf(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fmovi"))
	{
		int n = sscanf(buffer, formRF, dummy, &rt, &rs);
		if (n == 3)
		{
			code = _fmovi(rs, rt, rd);
			return true;
		}
	}
	// to use ALU
	if (eq(instName, "mvlo"))
	{
		int n = sscanf(buffer, formRI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _mvlo(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "mvhi"))
	{
		int n = sscanf(buffer, formRI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _mvhi(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fmvlo"))
	{
		int n = sscanf(buffer, formFI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _fmvlo(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fmvhi"))
	{
		int n = sscanf(buffer, formFI, dummy, &rt, &imm);
		if (n == 3)
		{
			code = _fmvhi(rt, rt, imm);
			return true;
		}
	}
	if (eq(instName, "j"))
	{
		int n = sscanf(buffer, formL, dummy, label);
		if (n == 2)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _j(0);
			return true;
		}
	}
	if (eq(instName, "beq"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _beq(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "blt"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _blt(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ble"))
	{
		int n = sscanf(buffer, formRRL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _ble(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fbeq"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fbeq(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fblt"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fblt(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fble"))
	{
		int n = sscanf(buffer, formFFL, dummy, &rs, &rt, label);
		if (n == 4)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _fble(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "jr"))
	{
		int n = sscanf(buffer, formR, dummy, &rs);
		if (n == 2)
		{
			code = _jr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "call"))
	{
		int n = sscanf(buffer, formL, dummy, label);
		if (n == 2)
		{
			labelNames[currentLine] = string(label);
//			cerr << "assigned (" << currentLine << ", " << string(label) << ") in labelNames" << endl;
			useLabel = true;
			code = _call(0);
			return true;
		}
	}
	if (eq(instName, "callr"))
	{
		int n = sscanf(buffer, formR, dummy, &rs);
		if (n == 2)
		{
			code = _callr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "return"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _return(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "ldr"))
	{
		int n = sscanf(buffer, formRRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _ldr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "fldr"))
	{
		int n = sscanf(buffer, formFRR, dummy, &rd, &rs, &rt);
		if (n == 4)
		{
			code = _fldr(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "sti"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _sti(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "ldi"))
	{
		int n = sscanf(buffer, formRRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _ldi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fsti"))
	{
		int n = sscanf(buffer, formFRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _fsti(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "fldi"))
	{
		int n = sscanf(buffer, formFRI, dummy, &rt, &rs, &imm);
		if (n == 4)
		{
			code = _fldi(rs, rt, imm);
			return true;
		}
	}
	if (eq(instName, "inputb"))
	{
		int n = sscanf(buffer, formR, dummy, &rt);
		if (n == 2)
		{
			code = _inputb(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "outputb"))
	{
		int n = sscanf(buffer, formR, dummy, &rt);
		if (n == 2)
		{
			code = _outputb(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "halt"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _halt(rs, rt, rd);
			return true;
		}
	}
	if (eq(instName, "dump"))
	{
		int n = sscanf(buffer, form, dummy);
		if (n == 1)
		{
			code = _dump(rs, rt, rd);
			return true;
		}
	}
	
	return false;
}
Beispiel #24
0
// Differs from _bpdl because no named-sections and assumes all symbols
// pre-exist in symbol-table
//
mword *inline_bpdl(bvm_cache *this_bvm, mword *sexpr){ // inline_bpdl#

#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_trace;
#endif

    if(is_nil(sexpr)){
        return nil;
    }

    mword bpdl_list_type = get_bpdl_list_type(sexpr);

    switch(bpdl_list_type){

        case BPDL_LIST_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_LIST_LIST");
#endif
            return inline_bpdl_list_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_CODE_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_CODE_LIST");
#endif
            return inline_bpdl_code_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_SHORT_VAL_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_SHORT_VAL_LIST");
#endif
            return inline_bpdl_val_list(this_bvm, sexpr);


        case BPDL_VAL_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_VAL_LIST");
#endif
            return inline_bpdl_val_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_SHORT_PTR_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_SHORT_PTR_LIST");
#endif
            return inline_bpdl_ptr_list(this_bvm, sexpr);


        case BPDL_PTR_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_PTR_LIST");
#endif
            return inline_bpdl_ptr_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_TAG_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_TAG_LIST");
#endif
            return inline_bpdl_tag_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_HASH_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_HASH_LIST");
#endif
            return inline_bpdl_hash_list(this_bvm, (mword*)icdr(sexpr));


        case BPDL_SYM_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_SYM_LIST");
#endif
            //inline_bpdl_sym_list(this_bvm, (mword*)icdr(sexpr));
            return nil;


        case BPDL_BS_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_BS_LIST");
#endif
            return nil; // XXX UNIMPLEMENTED

        case BPDL_QW_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_QW_LIST");
#endif
            return nil; // XXX UNIMPLEMENTED

        case BPDL_SEXPR_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_SEXPR_LIST");
#endif
            return (mword*)icar((mword*)icdr(sexpr));

        case BPDL_LABEL_LIST:
#if(defined BPDL_TRACE || defined INLINE_BPDL_TRACE)
_msg("BPDL_LABEL_LIST");
#endif
// XXX macros go here ... XXX

//            return bpdl_lookup_label(this_bvm, (mword*)icar(sexpr));
            return inline_bpdl_label_list(this_bvm, sexpr);

        default: // BPDL_UNKNOWN_LIST
            _msg("Unrecognized list type");
            _dump(sexpr);
            _die;

    }

    return nil;

}
Beispiel #25
0
void FileLog::onPrint(ELogLevel level, time_t t, const char *time, const char *msg)
{
    EState s = State_Start;
    UtilDay d(t);

    for (;;)
    {
        switch (s)
        {
        case State_Start:
            {
                if (!mLogFile)
                {
                    s = State_PreOpenCurFile;
                    break;
                }

                if (mCurDay != d)
                {
                    s = State_Dump;
                    break;
                }

                s = State_Ready;
            }
            break;
        case State_PreOpenCurFile:
            {
                assert(!mLogFile && "State_PreOpenCurFile:mLogFile < 0");

                const char *pathname = _getTodayFilePath(d);
                mCurDay = d;
                mLogFile = fopen(pathname, "at+");

                if (!mLogFile)
                {
                    s = State_Error;
                    break;
                }

                s = State_Ready;
            }
            break;
        case State_Dump:
            {
                assert(mLogFile && "State_Dump:mLogFile >= 0");

                // 如果磁盘空间不足则删除最早的日志文件
                while (checkDiskStatus() == DiskStatus_Full)
                {
                    if (_deleteEarliestFile() != ErrCode_Success) // 删除失败就不用继续了
                        break;
                }

                // 日志文件转储
                (void)_dump(mCurDay);

                // 不管转储成不成功,都需要保证当前的日志可以写入
                s = State_PreOpenCurFile;

                // 删除当前文件
                fclose(mLogFile);
                mLogFile = NULL;
                unlink(_getTodayFilePath(mCurDay));
                mCurDay.set((time_t)0);
            }
            break;
        case State_Ready:
            {
                assert(mLogFile && "State_Ready:mLogFile >= 0");

                int rv = _writeLog(level, t, time, msg);
                if (ErrCode_CurFileFull == rv)
                {
                    s = State_Dump;
                    break;
                }

                if (rv != ErrCode_Success)
                {
                    s = State_Error;
                    break;
                }

                s = State_Done;
            }
            break;
        default:
            break;
        }

        if (State_Error == s ||
            State_Done == s)
        {
            break;
        }
    }
}
Beispiel #26
0
API void _dump(value_t val) {
  switch (val.type) {
    case AtomType:
      switch (val.data) {
        case -4: print(CERROR"type-error"); return;
        case -1: print(CNIL"nil"); return;
        case 1: print(CBOOL"true"); return;
        case 0: print(CBOOL"false"); return;

        default: print(CUNDEF"undefined"); return;
      }
    case IntegerType:
      print(CINT);
      print_int(val.data);
      return;
    case SymbolType:
      if (val.data < 0) print(CSYM);
      else print(CBUILTIN);
      print(symbols_get_name(val.data));
      return;
    case PairType: {
      value_t node = seen;
      while (node.type == PairType) {
        pair_t pair = get_pair(node);
        if (eq(pair.left, val)) {
          print(CPAREN"("CSEP"..."CPAREN")");
          return;
        }
        node = pair.right;
      }
      seen = cons(val, seen);
      pair_t pair = get_pair(val);
      const char *opener, *closer;
      if (eq(pair.left, quoteSym)) {
        if (pair.right.type != PairType) {
          if (pair.right.type == SymbolType && pair.right.data < 0) {
            const char* data = symbols_get_name(pair.right.data);
            const char* p = data;
            bool whole = true;
            while (whole && *p) whole = *p++ != ' ';
            if (!whole) {
              print(CSTRING"\"");
              print(data);
              print("\"");
              return;
            }
          }
          print(CPAREN"'");
          _dump(pair.right);
          return;
        }
        opener = "'(";
        closer = ")";
        val = pair.right;
        pair = get_pair(val);
      }
      else if (eq(pair.left, listSym) && pair.right.type == PairType) {
        opener = "[";
        closer = "]";
        val = pair.right;
        pair = get_pair(val);
      }
      else {
        opener = "(";
        closer = ")";
      }
      print(CPAREN);
      print(opener);
      if (isNil(pair.right)) {
        _dump(pair.left);
      }
      else if (pair.right.type == PairType) {
        _dump(pair.left);
        while (pair.right.type == PairType) {
          print_char(' ');
          pair = get_pair(pair.right);
          _dump(pair.left);
        }
        if (!isNil(pair.right)) {
          print(CSEP" . ");
          _dump(pair.right);
        }
      } else {
        _dump(pair.left);
        print(CSEP" . ");
        _dump(pair.right);
      }
      print(CPAREN);
      print(closer);
      return;
    }
  }
}
Beispiel #27
0
 void dump(storage_t* ary) {
   Time start;
   _dump(ary);
   Time end;
   writing_time_ += end - start;
 }