Ejemplo n.º 1
0
void DotBuilder::doOperator(ASTOperator* element)
{
  uint operatorType = element->getOperatorType();

  ASTElement* left  = element->getLeft();
  ASTElement* right = element->getRight();

  const char* opString = NULL;

  switch (operatorType)
  {
    case MOPERATOR_ASSIGN: opString = "="; break;
    case MOPERATOR_PLUS  : opString = "+"; break;
    case MOPERATOR_MINUS : opString = "-"; break;
    case MOPERATOR_MUL   : opString = "*"; break;
    case MOPERATOR_DIV   : opString = "/"; break;
    case MOPERATOR_MOD   : opString = "%"; break;
	case MOPERATOR_POW   : opString = "^"; break;
    default:
      MP_ASSERT_NOT_REACHED();
  }

  _sb.appendFormat("  N_%u [label=\"<L>|<F0>%s|<R>\"];\n", element->getElementId(), opString);
  _sb.appendFormat("  N_%u:L -> N_%u:F0;\n", element->getElementId(), left->getElementId());
  _sb.appendFormat("  N_%u:R -> N_%u:F0;\n", element->getElementId(), right->getElementId());

  doElement(left);
  doElement(right);
}
Ejemplo n.º 2
0
void DotBuilder::doTree(ASTElement* tree)
{
  _sb.appendString("digraph G {\n");
  _sb.appendString("  node [shape=record];\n");
  doElement(tree);
  _sb.appendString("}\n");
}
Ejemplo n.º 3
0
void DotBuilder::doCall(ASTCall* element)
{
  const Vector<ASTElement*>& arguments = element->getArguments();
  size_t i, len = arguments.getLength();
  size_t celter = len / 2;

  _sb.appendFormat("  N_%u [label=\"", element->getElementId());
  _sb.appendFormat("<F0>%s", Hash<Function>::dataToKey(element->getFunction()));
  for (i = 0; i < len; i++)
  {
    _sb.appendFormat("<A%u>", (unsigned int)i);
  }
  _sb.appendString("\"];\n");

  for (i = 0; i < len; i++)
  {
    _sb.appendFormat("  N_%u:A%u -> N_%u:F0;\n",
      element->getElementId(),
      (unsigned int)i,
      arguments[i]->getElementId());
  }

  for (i = 0; i < len; i++)
  {
    doElement(arguments[i]);
  }
}
Ejemplo n.º 4
0
//[cf]
//[of]:doChapter
void DocbookToHTML::doChapter(AXElement* chapter)
{
  AXElement* title = ax_getElement(chapter, 0);
  append("<h1>");
  appendAttribute(ax_getAttribute(title, 0));
  append("</h1>\n");

  doElement(chapter);

}
Ejemplo n.º 5
0
void DotBuilder::doTransform(ASTTransform* element)
{
  uint transformType = element->getTransformType();
  ASTElement* child = element->getChild();

  const char* opString = NULL;

  switch (transformType)
  {
    case MTRANSFORM_NONE  : opString = ""; break;
    case MTRANSFORM_NEGATE: opString = "-"; break;
    default:
      MP_ASSERT_NOT_REACHED();
  }

  _sb.appendFormat("  N_%u [label=\"<F0>%s\"];\n", element->getElementId(), opString);
  _sb.appendFormat("  N_%u -> N_%u:F0;\n", element->getElementId(), child->getElementId());
  doElement(child);
}
Ejemplo n.º 6
0
void DotBuilder::doBlock(ASTBlock* element)
{
  Vector<ASTElement*>& children = element->_elements;
  size_t i, len = children.getLength();

  _sb.appendFormat("  N_%u [label=\"", element->getElementId());
  for (i = 0; i < len; i++) _sb.appendFormat("<F%u> |", (uint)i);
  _sb.appendFormat(" \"];\n", element->getElementId());

  for (i = 0; i < len; i++)
  {
    _sb.appendFormat("  N_%u:F%u -> N_%u:F0\n",
      element->getElementId(), (uint)i, children[i]->getElementId());
  }

  for (i = 0; i < len; i++)
  {
    doElement(children[i]);
  }
}
Ejemplo n.º 7
0
//[cf]
//[of]:doElement
void DocbookToHTML::doElement(AXElement* e)
{
  int  level = 2;
  bool start = true;

  e = e->firstChild;
  while( e )
  {
    switch( e->id )
    {
      case id_pcdata:
        appendAttribute(ax_getAttribute(e, 0));
        break;

      case id_article:
        doElement(e);
        break;

      case id_chapter:
      case id_preface:
      case id_section:
      case id_simplesect:
      {
        char buf[1];
        buf[0] = '0'+level;
        AXElement* title = ax_getElement(e, 0);
        append("\n\n<h");
        append(buf, 1);
        append(">");
        appendAttribute(ax_getAttribute(title, 0));
        append("</h");
        append(buf, 1);
        append(">\n\n");
        doElement(e);
        break;
      }
      
      case id_programlisting:
        append("<pre>");
        appendAttribute(ax_getAttribute(e, 0));
        append("</pre>");
        break;

      case id_itemizedlist:
        append("<ul>");
        doElement(e);
        append("</ul>");
        break;

      case id_listitem:
        append("<li>");
        doElement(e);
        append("</li>");
        break;

      case id_para:
      case id_note:
        if( !start ) append("\n\n<p>");
        doElement(e);
        if( !start ) append("</p>\n");
        start = false;
        break;

      case id_emphasis:
        append("<b>");
        doElement(e);
        append("</b>");
        break;

      case id_varname:
      case id_guimenuitem:
      case id_guimenu:
      case id_filename:
      case id_code:
        append("<tt>");
        doElement(e);
        append("</tt>");
        break;

    }
    e = e->nextSibling;
  }
}