Ejemplo n.º 1
0
  public final void appendCode(XmcWriter w) throws XmException {
    Iterator<XcIdent> ite = iterator();

    w.spc().add('{').lf();

    for (; ite.hasNext(); ) {
      XcIdent ident = ite.next();
      String symbol = ident.getSymbol();
      XcType type = ident.getType();

      ident.appendGccExtension(w);

      type.appendDeclCode(w, symbol, true, false);

      if (ident.getIsBitField()) {
        w.add(":");
        if (ident.getIsBitFieldExpr()) {
          w.add(ident.getBitFieldExpr());
        } else {
          w.add(ident.getBitField());
        }
      }

      w.add(ident.getGccAttribute());

      w.add(';').lf();
    }

    w.add('}');
  }
Ejemplo n.º 2
0
  /**
   * Appends contents of compound statement with XmWriter.
   *
   * @param w a writer appends the code.
   * @param insideCompExpr true if is the object is the term of the compound expression.
   * @throws XmException thrown if a writer failed to append the content.
   */
  public final void appendContent(XmcWriter w, boolean insideCompExpr) throws XmException {
    if (_identTable == null) {
      w.add(_decls);
    } else {
      _identTable.appendCode(w, _decls);
    }

    Iterator<XcStAndDeclObj> iter = _stmtAndDeclList.iterator();

    XcStAndDeclObj stmtAndDecl = null;

    while (iter.hasNext() == true) {
      stmtAndDecl = iter.next();
      w.add(stmtAndDecl);

      if (insideCompExpr == false) w.noLfOrLf();
    }

    if (stmtAndDecl != null
        && ((stmtAndDecl instanceof XcControlStmtObj.CaseLabel)
            || (stmtAndDecl instanceof XcControlStmtObj.GccRangedCaseLabel)
            || (stmtAndDecl instanceof XcControlStmtObj.Label)
            || (stmtAndDecl instanceof XcControlStmtObj.DefaultLabel))) w.eos();
  }
Ejemplo n.º 3
0
  @Override
  public void appendCode(XmcWriter w) throws XmException {
    if (XmOption.isSuppressLineDirective()) return;

    if (_lineNum <= 0 || _filePath == null) return;

    w.noLfOrLf().add("# ").add(_lineNum);

    if (_filePath != null) {
      w.add(" \"").add(_filePath);

      if (w.getIsDebugMode() && _rawLineNum > 0)
        w.addSpc("(raw line = ").addSpc(_rawLineNum).add(")");

      w.add("\"");
    }

    w.lf();
  }
Ejemplo n.º 4
0
 @Override
 public final void appendCode(XmcWriter w) throws XmException {
   w.add("{").lf();
   appendContent(w, false);
   w.add("}").lf();
 }