コード例 #1
0
ファイル: node-print.c プロジェクト: argasek/morphine
void JsonPrint(JsonNodeT *node, int indent) {
  int i;

  switch (node->type) {
    case JSON_NULL:
      printf("null");
      break;
    case JSON_BOOLEAN:
      printf(node->u.boolean ? "true" : "false");
      break;
    case JSON_INTEGER:
      printf("%ld", node->u.integer);
      break;
    case JSON_REAL:
      printf("%f", node->u.real);
      break;
    case JSON_STRING:
      printf("\"%s\"", node->u.string);
      break;
    case JSON_ARRAY:
      putchar('[');
      if (node->u.array.num)
        putchar('\n');
      for (i = 0; i < node->u.array.num; i++) {
        JsonPrint(node->u.array.item[i], indent + 2);
        if (i < node->u.array.num - 1)
          puts(",");
        else
          putchar('\n');
      }
      if (node->u.array.num)
        PrintSpaces(indent);
      putchar(']');
      break;
    case JSON_OBJECT:
      PrintSpaces(indent);
      putchar('{');
      if (node->u.object.num)
        putchar('\n');
      for (i = 0; i < node->u.object.num; i++) {
        PrintSpaces(indent + 1);
        printf("%s : ", node->u.object.item[i].key);
        JsonPrint(node->u.object.item[i].value, indent + 2);
        if (i < node->u.object.num - 1)
          puts(",");
        else
          putchar('\n');
      }
      if (node->u.object.num)
        PrintSpaces(indent);
      putchar('}');
      break;
  }
}
コード例 #2
0
void TreeNode::PrintTree(ostream &out, int spaces, int siblingNum) const {
	// print Children
	for (int i=0; i<MAXCHILDREN; ++i)
		if (this->child[i] != NULL) {
			PrintSpaces(out, spaces);
			out << "Child: " << i << '\n';		
			this->child[i]->PrintTree(out, spaces+4, 0); // reset sibling number in child calls
		}
	// print Siblings
	if (this->sibling != NULL) {
		PrintSpaces(out, spaces);
		out << "Sibling: " << ++siblingNum << '\n';
		this->sibling->PrintTree(out, spaces, siblingNum);
	}
}
コード例 #3
0
void ExpressionNode::PrintTree(ostream &out, int spaces, int siblingNum) const {
	PrintSpaces(out, spaces);

	switch (subKind) {
		case OpK:
			out << "Op: " << op << " [line: " << lineNumber << "]\n";
			break;
		case AssignK:
			out << "Assign" << " [line: " << lineNumber << "]\n";
			break;
		case ConstK:
			if (type == TreeNode::Bool)
				out << "Const: " << boolalpha << (bool)val << noboolalpha << " [line: " << lineNumber << "]\n";
			else
				out << "Const: " << val << " [line: " << lineNumber << "]\n";
			break;
		case IdK:
			out << "Id: " << name << " [line: " << lineNumber << "]\n";
			break;
		case CallK:
			out << "Call: " << name << " [line: " << lineNumber << "]\n";
			break;
	}    
	TreeNode::PrintTree(out, spaces, siblingNum);
}
コード例 #4
0
ファイル: unifylods.cpp プロジェクト: Bubbasacs/FinalProj
static void SpewBoneInfo( int globalBoneID, int depth )
{
	s_bonetable_t *pBone = &g_bonetable[globalBoneID];
	if( g_bPrintBones )
	{
		PrintSpaces( depth * 2 );
		printf( "%d \"%s\" ", depth, pBone->name );
	}
	int i;
	for( i = 0; i < 8; i++ )
	{
		if( pBone->flags & ( BONE_USED_BY_VERTEX_LOD0 << i ) )
		{
			if( g_bPrintBones )
			{
				printf( "lod%d ", i );
			}
			g_NumBonesInLOD[i]++;
		}
	}
	if( g_bPrintBones )
	{
		printf( "\n" );	
	}
	
	int j;
	for( j = 0; j < g_numbones; j++ )
	{
		s_bonetable_t *pBone = &g_bonetable[j];
		if( pBone->parent == globalBoneID )
		{
			SpewBoneInfo( j, depth + 1 );
		}
	}
}
コード例 #5
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void SymVar::PrintVerbose(ostream& o, int offset) const
{
    PrintSpaces(o, offset) << token.GetName() << ": ";
    if (type->GetClassName() & SYM_TYPE_ALIAS)
        type->Print(o, offset + 1);
    else
        type->PrintVerbose(o, offset + 1);
    o << "\n";
}
コード例 #6
0
ファイル: TestUConv.cpp プロジェクト: Andrel322/gecko-dev
nsresult nsTestUConv::DisplayDetectors()
{
  const char * trace = "DisplayDetectors";
  mLog.AddTrace(trace);
  nsresult res = NS_OK;

  nsCOMPtr<nsICharsetConverterManager> ccMan = 
           do_GetService(kCharsetConverterManagerCID, &res);
  if (NS_FAILED(res)) {
    mLog.PrintError("NS_WITH_SERVICE", res);
    return res;
  }

  // charset detectors
  nsCOMPtr<nsIUTF8StringEnumerator> detectors;

  res = ccMan->GetCharsetDetectorList(getter_AddRefs(detectors));
  if (NS_FAILED(res)) {
    mLog.PrintError("GetCharsetDetectorList()", res);
    return res;
  }

  printf("***** Character Set Detectors *****\n");

  bool hasMore;
  detectors->HasMore(&hasMore);
  while (hasMore) {
    nsAutoCString detectorName;
    res = detectors->GetNext(detectorName);
    if (NS_FAILED(res)) {
      mLog.PrintError("GetNext()", res);
      return res;
    }

    printf("%s", detectorName.get());
    PrintSpaces(36 - detectorName.Length()); // align to hard coded column number

    nsAutoString title;
    res = ccMan->GetCharsetTitle(detectorName.get(), title);
    if (NS_FAILED(res)) title.SetLength(0);
    printf("\"%s\"\n", NS_LossyConvertUTF16toASCII(title).get());

    detectors->HasMore(&hasMore);
  }
  
  mLog.DelTrace(trace);
  return NS_OK;
}
コード例 #7
0
void StatementNode::PrintTree(ostream &out, int spaces, int siblingNum) const {
	PrintSpaces(out, spaces);
    
	switch (subKind) {
		case IfK:
			out << "If" << " [line: " << lineNumber << "]\n";
			break;
		case CompK:
			out << "Compound" << " [line: " << lineNumber << "]\n";
			break;
		case WhileK:
			out << "While" << " [line: " << lineNumber << "]\n";
			break;
		case ReturnK:
			out << "Return" << " [line: " << lineNumber << "]\n";
			break;
	}
	TreeNode::PrintTree(out, spaces, siblingNum);
}
コード例 #8
0
void PrintBoneGraphRecursive( studiohdr_t *phdr, int boneIndex, int level )
{
	int j;
	PrintSpaces( level );
	printf( "%d \"%s\" ", boneIndex, phdr->pBone( boneIndex )->pszName() );
	int i;
	for( i = 0; i < 8; i++ )
	{
		if( phdr->pBone( boneIndex )->flags & ( BONE_USED_BY_VERTEX_LOD0 << i ) )
		{
			printf( "lod%d ", i );
			g_NumBonesInLOD[i]++;
		}
	}
	printf( "\n" );
	for( j = 0; j < phdr->numbones; j++ )
	{
		mstudiobone_t *pBone = phdr->pBone( j );
		if( pBone->parent == boneIndex )
		{
			PrintBoneGraphRecursive( phdr, j, level+1 );
		}
	}
}
コード例 #9
0
void DeclarationNode::PrintTree(ostream &out, int spaces, int siblingNum) const {
	PrintSpaces(out, spaces);
    PrintNode(out, this);		
	TreeNode::PrintTree(out, spaces, siblingNum);
}
コード例 #10
0
ファイル: TestUConv.cpp プロジェクト: rn10950/RetroZilla
nsresult nsTestUConv::DisplayCharsets()
{
  char * trace = "DisplayCharsets";
  mLog.AddTrace(trace);
  nsresult res = NS_OK;

  nsCOMPtr<nsICharsetConverterManager> ccMan = 
           do_GetService(kCharsetConverterManagerCID, &res);
  if (NS_FAILED(res)) {
    mLog.PrintError("NS_WITH_SERVICE", res);
    return res;
  }

  nsCOMPtr<nsIUTF8StringEnumerator> decoders;
  nsCOMPtr<nsIUTF8StringEnumerator> encoders;

  res = ccMan->GetDecoderList(getter_AddRefs(decoders));
  if (NS_FAILED(res)) {
    mLog.PrintError("GetDecoderList()", res);
    return res;
  }

  res = ccMan->GetEncoderList(getter_AddRefs(encoders));
  if (NS_FAILED(res)) {
    mLog.PrintError("GetEncoderList()", res);
    return res;
  }


  printf("***** Character Sets *****\n");

  PRUint32 encCount = 0, decCount = 0;
  PRUint32 basicEncCount = 0, basicDecCount = 0;

  nsCStringArray allCharsets;
  
  nsCAutoString charset;
  PRBool hasMore;
  encoders->HasMore(&hasMore);
  while (hasMore) {
    res = encoders->GetNext(charset);
    if (NS_SUCCEEDED(res))
      allCharsets.AppendCString(charset);

    encoders->HasMore(&hasMore);
  }

  nsAutoString prop, str;
  PRUint32 count = allCharsets.Count();
  for (PRUint32 i = 0; i < count; i++) {

    const nsCString* charset = allCharsets[i];
    printf("%s", charset->get());
    PrintSpaces(24 - charset->Length());  // align to hard coded column number


    nsCOMPtr<nsIUnicodeDecoder> dec = NULL;
    res = ccMan->GetUnicodeDecoder(charset->get(), getter_AddRefs(dec));
    if (NS_FAILED(res)) printf (" "); 
    else {
      printf("D");
      decCount++;
    }
#ifdef NS_DEBUG
    // show the "basic" decoder classes
    if (dec) {
      nsCOMPtr<nsIBasicDecoder> isBasic = do_QueryInterface(dec);
      if (isBasic) {
        basicDecCount++;
        printf("b");
      }
      else printf(" ");
    }
    else printf(" ");
#endif

    nsCOMPtr<nsIUnicodeEncoder> enc = NULL;
    res = ccMan->GetUnicodeEncoder(charset->get(), getter_AddRefs(enc));
    if (NS_FAILED(res)) printf (" "); 
    else {
      printf("E");
      encCount++;
    }

#ifdef NS_DEBUG
    if (enc) {
      nsCOMPtr<nsIBasicEncoder> isBasic = do_QueryInterface(enc);
      if (isBasic) {
        basicEncCount++;
        printf("b");
      }
      else printf(" ");
    }
    else printf(" ");
#endif
    
    printf(" ");

    prop.AssignLiteral(".notForBrowser");
    res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
    if ((dec != NULL) && (NS_FAILED(res))) printf ("B"); 
    else printf("X");

    prop.AssignLiteral(".notForComposer");
    res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
    if ((enc != NULL) && (NS_FAILED(res))) printf ("C"); 
    else printf("X");

    prop.AssignLiteral(".notForMailView");
    res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
    if ((dec != NULL) && (NS_FAILED(res))) printf ("V"); 
    else printf("X");

    prop.AssignLiteral(".notForMailEdit");
    res = ccMan->GetCharsetData(charset->get(), prop.get(), str);
    if ((enc != NULL) && (NS_FAILED(res))) printf ("E"); 
    else printf("X");

    printf("(%3d, %3d) ", encCount, decCount);
    res = ccMan->GetCharsetTitle(charset->get(), str);
    if (NS_FAILED(res)) str.SetLength(0);
    NS_LossyConvertUCS2toASCII buff2(str);
    printf(" \"%s\"\n", buff2.get());
  }

  printf("%u of %u decoders are basic (%d%%)\n",
         basicDecCount, decCount, (basicDecCount * 100) / decCount);

  printf("%u of %u encoders are basic (%d%%)\n",
         basicEncCount, encCount, (basicEncCount * 100) / encCount);
  mLog.DelTrace(trace);
  return NS_OK;
}
コード例 #11
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void SymVarConst::Print(ostream& o, int offset) const
{
    PrintSpaces(o, offset) << token.GetName() << " = " << value.GetName();
}
コード例 #12
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void SymTypeAlias::PrintVerbose(ostream& o, int offset) const
{
    PrintSpaces(o, offset) << token.GetName() << " = ";
    target->PrintVerbose(o, offset + 1);
    o << "\n";
}
コード例 #13
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void Symbol::Print(ostream& o, int offset) const
{
    PrintSpaces(o, offset) << token.GetName();
}
コード例 #14
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void SymTypeRecord::PrintVerbose(ostream& o, int offset) const
{
    o << "record\n";
    sym_table->Print(o, offset);
    PrintSpaces(o, offset - 1) << "end";
}
コード例 #15
0
ファイル: sym_table.cpp プロジェクト: bencz/Compiler-study
void SymVar::PrintAsNode(ostream& o, int offset) const
{
    PrintSpaces(o, offset) << token.GetName() << " [";
    type->Print(o, 0);
    o << "]\n";
}
コード例 #16
0
/**
 *	Prints spaces to align the cursor to the requested position
 *	
 *	@note The cursor move will not be performed if the request would move the cursor
 *	backwards.
 */
void IDebugLog::SeekCursor(int position)
{
	if(position > cursorPos)
		PrintSpaces(position - cursorPos);
}