Ejemplo n.º 1
0
void dumpChar( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    printf("char: ");
    int intval = (int)(phdr->hdr >> __CHAR_VAL_SHFT__);

    switch(intval) {
    case __CH_newline__:
        printf("newline");
        break;

    case __CH_space__:
        printf("space");
        break;

    default:
        putchar(intval);
        break;
    }

    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);
}
Ejemplo n.º 2
0
void dumpStr( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    /* __WORD__ slen = (__WORD__)(phdr->hdr >> __STR_LEN_SHFT__); */
    __WORD__ slen = __unboxint(_A1_, __stringLength(_A1_, __boxptd(_A1_, addr)));
    printf("string length: ");
    dumpIntWord(f, slen);
    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);

    /* String content */
    __WORD__ wholelines = ((slen + 1) / __WORDSIZE__);
    __WORD__ tailline = ((slen + 1) % __WORDSIZE__);
    if (tailline != 0)
        tailline = 1;
    for (__WORD__ i = 0; i < (wholelines + tailline); ++i) {
        dumpStrLine(f, phdr, i);
    }
}
 virtual StringResultBase* Prettify(const ParseResultBase* parseResult) const {
     const GasonParseResult* pr = static_cast<const GasonParseResult*>(parseResult);
     std::ostringstream os;
     dumpValue(os, pr->value, 4, "\n");
     GasonStringResult* result = new GasonStringResult;
     result->s = os.str();
     return result;
 }
Ejemplo n.º 4
0
    void Options::dumpOptions()
    {
        for (VariablesMap::const_iterator iter = m_variablesMap.begin(); iter != m_variablesMap.end(); ++iter) {
            std::string name = (*iter).first;
            const std::type_info &type = iter->second.value().type();

            dumpValue(type, name, std::cerr);
        }
    }
Ejemplo n.º 5
0
Archivo: runtime.c Proyecto: m4dc4p/mil
int main() {
    int* result;
    printf("Starting:\n");
    result = TOP();
    dumpValue(result);
    printf("Done: %d words allocated.\n",freeHeap);
    printf("Result Address = %08x\n", result);
    return 0;
}
Ejemplo n.º 6
0
void dumpPairState( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;

    dumpAddr(f, addr);
    dumpValue(f, *(__WORD__*)addr);
    printf("state: 0x");
    dumpWord(f, *(__WORD__*)addr);
    printf("\n");
}
Ejemplo n.º 7
0
void
QmcMetric::dumpSampledMetric(QTextStream &stream, bool srcFlag, uint instance) const
{
    Q_ASSERT(!event());

    stream << name();

    if (srcFlag == true)
	dumpSource(stream);

    if (my.status < 0)
	stream << ": " << pmErrStr(my.status) << endl;
    else if (hasInstances()) {
	if (instance == UINT_MAX) {
	    if (numInst() == 1)
		stream << ": 1 instance";
	    else
		stream << ": " << numInst() << " instances";
	    if (indom()->changed())
		stream << " (indom has changed)";
	    stream << endl;

	    for (int i = 0; i < numInst(); i++) {
		stream << "  [" << instID(i) << " or \"" << instName(i)
		       << "\" (" << my.values[i].instance() << ")] = ";
		dumpValue(stream, i);
		stream << endl;
	    }
	}
	else {
	    stream << '[' << instID(instance) << " or \"" << instName(instance) 
		   << "\" (" << my.values[instance].instance() << ")] = ";
	    dumpValue(stream, instance);
	    stream << endl;
	}
    }
    else {
	stream << " = ";
	dumpValue(stream, 0);
	stream << endl;
    }
}
Ejemplo n.º 8
0
std::ostream& PVUnionArray::dumpValue(std::ostream& o) const
{
    o << format::indent() << getUnionArray()->getID() << ' ' << getFieldName() << std::endl;
    size_t length = getLength();
    if (length > 0)
    {
    	format::indent_scope s(o);

        for (size_t i = 0; i < length; i++)
        	dumpValue(o, i);
    }

    return o;
}
Ejemplo n.º 9
0
void dumpInt( __bytefield__ *f, __WORD__ pos ) {
    /* Address */
    __WORD__ addr = ( __WORD__)f->field + pos;
    __BWORD__ val = *(__BWORD__*)addr;
    dumpAddr(f, addr);

    /* Hex value */
    dumpValue(f, val);

    /* Desc */
    printf("Boxed integer: ");
    dumpIntWord(f, __unboxint(_A1_, val));
    printf("\n");
}
Ejemplo n.º 10
0
void dumpStrLine( __bytefield__ *f, __ptd_hdr__ *phdr, __WORD__ i) {
    __WORD__ lineAddr = (__WORD__)((__WORD__*)((__WORD__)phdr + sizeof(__ptd_hdr__)) + i);

    /* Address */
    dumpAddr(f, lineAddr);

    /* Hex value */
    dumpValue(f, *(__WORD__*)lineAddr);

    /* Desc */
    for (__WORD__ k = 0; k < __WORDSIZE__; ++k)
        putchar((int)*((char*)lineAddr + k));
    printf("\n");
}
Ejemplo n.º 11
0
void dumpBoxed( __bytefield__ *f, __WORD__ pos ) {
    /* Address */
    __WORD__ addr = ( __WORD__)f->field + pos;
    __BWORD__ bval = *(__BWORD__*)addr;
    __WORD__ t = __boxtype(_A1_, bval);
    __WORD__ saddr = 0;
    __WORD__ subt;

    if (t == __INT_TYPE__)
        dumpInt(f, pos);
    else {
        dumpAddr(f, addr);

        /* Hex value */
        dumpValue(f, bval);

        /* Desc */
        printf ("Boxed ");
        switch (t) {
        case __PTD_TYPE__:
            saddr = __unboxptd(_A1_, bval);
            subt = __boxsubtype(_A1_, saddr);
            if (subt == __VEC_TYPE__)
                printf("vector at ");
            else if (subt == __STR_TYPE__)
                printf("string at ");
            else if (subt == __CHAR_TYPE__)
                printf("char at ");
            break;

        case __PAIR_TYPE__:
            saddr = __unboxpair(_A1_, bval);
            printf("pair at ");
            break;

        case __LAMBDA_TYPE__:
            saddr = __unboxlambda(_A1_, bval);
            printf("lambda at ");
            break;

        default:
            printf("unknown type");
            break;
        }

        dumpWord(f, saddr);
        printf("\n");
    }
}
Ejemplo n.º 12
0
void dumpVecIndex( __bytefield__ *f, __ptd_hdr__ *phdr, __WORD__ i ) {
    __WORD__ cellAddr = (__WORD__)((__WORD__*)((__WORD__)phdr + sizeof(__ptd_hdr__)) + i);

    /* Address */
    dumpAddr(f, cellAddr);

    /* Hex value */
    dumpValue(f, *(__WORD__*)cellAddr);

    /* Desc */
    printf("v[");
    dumpIntWord(f, i);
    printf("]: ");
    dumpWord(f, *(__WORD__*)cellAddr);
    printf("\n");
}
Ejemplo n.º 13
0
int
main(int argc, const char ** argv) {

    xmlrpc_env env;
    const char * methodName;
    xmlrpc_value * paramArrayP;
    xmlrpc_mem_block * callXmlP;

    if (argc-1 > 0) {
        fprintf(stderr, "No arguments.  Input is from Standard Input\n");
        if (argv){}  /* defeat compiler warning */
        exit(99);
    }

    xmlrpc_env_init(&env);

    fprintf(stderr, "Reading call data from Standard Input...\n");

    readFile(&env, stdin, &callXmlP);
    die_if_fault_occurred(&env);

    xmlrpc_parse_call(&env,
                      XMLRPC_MEMBLOCK_CONTENTS(char, callXmlP),
                      XMLRPC_MEMBLOCK_SIZE(char, callXmlP),
                      &methodName,
                      &paramArrayP);

    if (env.fault_occurred)
        printf("Invalid call.  %s\n", env.fault_string);
    else {
        printf("Parsed successfully as XML-RPC call.\n");

        printf("Method name: '%s'\n", methodName);

        printf("Parameter array:\n");

        dumpValue("  ", paramArrayP);

        strfree(methodName);
        xmlrpc_DECREF(paramArrayP);
    }
    XMLRPC_MEMBLOCK_FREE(char, callXmlP);

    xmlrpc_env_clean(&env);

    return 0;
}
Ejemplo n.º 14
0
Archivo: runtime.c Proyecto: m4dc4p/mil
/***
 * Prints heap objects for the value given. Tags are recognized and
 * their names are printed. All pointers in the object are followed
 * until a tag is found.
 **/
void dumpValue(int * start) {
  
  int* tag   = (int*)(*start);
  int  size  = *(tag - 1);
  int  isData = *(tag - 2);
  int* name  = (int *) *(tag - 3);

  int * k = start;
  int j = size;
  while(j>0) {
    k++;
    if(inHeap(k))
      dumpValue((int *)*k);
    j--;
  }

  if(isData)
    printf("%08x: [(%s)", start, name);
  else
    printf("%08x: [%08x ", start, *tag);
  
  while (size>0) {
    start++;
    if(inHeap(start))
      printf(" %08x", *start);
    else {
      // start - address of heap object
      // *start - heap object
      // **start - address stored at head of heap object
      // *** - info table about object
      tag = ((int *)*((int *) *start));
      name = (int *) *(tag - 3);
      printf(" %s", name);
    }
    size--;
  }
  printf("]\n");
}
Ejemplo n.º 15
0
void dumpVec( __bytefield__ *f, __WORD__ pos ) {
    __WORD__ addr = (__WORD__)f->field + pos;
    __ptd_hdr__ *phdr = (__ptd_hdr__*)addr;

    /* Address */
    dumpAddr(f, (__WORD__)phdr);

    /* Hex value */
    dumpValue(f, phdr->hdr);

    /* Desc */
    __WORD__ vlen = (__WORD__)(phdr->hdr >> __VEC_LEN_SHFT__);
    printf("vector size: ");
    dumpIntWord(f, vlen);
    printf("\n");

    /* State */
    dumpPtdState(f, pos + __WORDSIZE__);

    /* Vector content */
    for (__WORD__ i = 0; i < vlen; ++i) {
        dumpVecIndex(f, phdr, i);
    }
}
static void dumpValue(std::ostringstream& os, const JsonValue& o, int shiftWidth, const std::string& linefeed = "", int indent = 0) {
    switch (o.getTag()) {
    case JSON_NUMBER:
        char buffer[32];
        sprintf(buffer, "%f", o.toNumber());
        os << buffer;
        break;
    case JSON_TRUE:
        os << "true";
        break;        
    case JSON_FALSE:
        os << "false";
        break;
    case JSON_STRING:
        dumpString(os, o.toString());
        break;
    case JSON_ARRAY:
        // It is not necessary to use o.toNode() to check if an array or object
        // is empty before iterating over its members, we do it here to allow
        // nicer pretty printing.
        if (!o.toNode()) {
            os << "[]";
            break;
        }
        os << "[" << linefeed;
        for (auto i : o) {
            if (shiftWidth > 0)
                os << std::setw(indent + shiftWidth) << " " << std::setw(0);
            dumpValue(os, i->value, shiftWidth, linefeed, indent + shiftWidth);
            if (i->next)
                os << ",";
            os << linefeed;
        }
        if (indent > 0)
            os << std::setw(indent) << " " << std::setw(0);
        os.put(']');
        break;
    case JSON_OBJECT:
        if (!o.toNode()) {
            os << "{}";
            break;
        }
        os << "{" << linefeed;
        for (auto i : o) {
            if (shiftWidth > 0)
                os << std::setw(indent + shiftWidth) << " " << std::setw(0);
            dumpString(os, i->key);
            os << ":";
            dumpValue(os, i->value, shiftWidth, linefeed, indent + shiftWidth);
            if (i->next)
                os << ",";
            os << linefeed;
        }
        if (indent > 0)
            os << std::setw(indent) << " " << std::setw(0);
        os.put('}');
        break;
    case JSON_NULL:
        os << "null";
        break;
    }
}