Changeset 2461
- Timestamp:
- Apr 1, 2011 8:47:37 PM (9 years ago)
- Location:
- trunk/Compiler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/ModelicaCompiler/src/jastadd/ModelicaCompiler.jrag
r2439 r2461 988 988 log.debug("Creating raw .mof file..."); 989 989 PrintStream out = new PrintStream(flatFile); 990 fc.prettyPrint (out, "");990 fc.prettyPrint_MC(out, ""); 991 991 out.close(); 992 992 log.debug("... raw .mof file created."); … … 1007 1007 log.debug("Creating transformed .mof file..."); 1008 1008 out = new PrintStream(new File(tempDir, icl.qualifiedName() + "_transformed.mof")); 1009 fc.prettyPrint (out, "");1009 fc.prettyPrint_MC(out, ""); 1010 1010 out.close(); 1011 1011 log.debug("... transformed .mof file created."); -
trunk/Compiler/ModelicaFrontEnd/src/jastadd/PrettyPrint.jrag
r2457 r2461 1607 1607 syn String Modification.toString() = prettyPrint(""); 1608 1608 } 1609 1610 aspect PrettyPrint_MC { 1611 1612 class MCPrettyPrinter extends Printer { 1613 1614 public MCPrettyPrinter() { 1615 super(" "); 1616 } 1617 1618 public void print(ASTNode node, PrintStream str, String indent) { 1619 node.prettyPrint(this, str, indent); 1620 } 1621 1622 } 1623 1624 static MCPrettyPrinter ASTNode.printer_MC = new MCPrettyPrinter(); 1625 1626 public String ASTNode.prettyPrint_MC(String indent) { 1627 ByteArrayOutputStream os = new ByteArrayOutputStream(); 1628 PrintStream str = new PrintStream(os); 1629 prettyPrint(str,indent); 1630 return os.toString(); 1631 } 1632 1633 public void List.prettyPrintFAttributeList_MC(PrintStream str, Printer p) { 1634 1635 boolean attrSet = false; 1636 boolean firstAttr = true; 1637 1638 for (int i=0;i<getNumChild();i++) { 1639 if (((FAttribute)getChild(i)).getAttributeSet() && !((FAttribute)getChild(i)).getName().name().equals("fixed")) { 1640 attrSet=true; 1641 break; 1642 } 1643 } 1644 1645 if (attrSet){ 1646 str.print("("); 1647 for (int i=0;i<getNumChild();i++) { 1648 1649 if (((FAttribute)getChild(i)).getAttributeSet() && !((FAttribute)getChild(i)).getName().name().equals("fixed")) { 1650 1651 if (!firstAttr) 1652 str.print(","); 1653 p.print(((FAttribute)getChild(i)),str,""); 1654 1655 firstAttr = false; 1656 } 1657 } 1658 str.print(")"); 1659 } 1660 } 1661 1662 public void FVariable.prettyPrint_MC(Printer p, PrintStream str, String indent) { 1663 str.print(indent); 1664 1665 str.print(getFTypePrefixVariability()); 1666 1667 if (hasFTypePrefixInputOutput()) { 1668 str.print(getFTypePrefixInputOutput()); 1669 str.print(" "); 1670 } 1671 1672 str.print(type().scalarType()); 1673 str.print(" "); 1674 str.print(nameUnderscore()); 1675 // p.print(getFQName(),str,""); 1676 1677 getFAttributeList().prettyPrintFAttributeList_MC(str,p); 1678 1679 if (hasBindingExp()) { 1680 str.print(" = "); 1681 FExp bindingExp = getBindingExp(); 1682 p.print(bindingExp,str,indent); 1683 } else if (hasParameterEquation()) { 1684 str.print(" = "); 1685 FExp bindingExp = ((FEquation)parameterEquation()).getRight(); 1686 p.print(bindingExp,str,indent); 1687 } 1688 1689 if (hasFStringComment()) { 1690 str.print(" \""); 1691 str.print(getFStringComment().getComment()); 1692 str.print("\""); 1693 } 1694 1695 if (isIndependentParameter() && hasBindingExp()) { 1696 str.print(" /* "); 1697 try { 1698 str.print(getBindingExp().ceval()); 1699 } catch (ConstantEvaluationException e){ 1700 str.print("evalutation error"); 1701 } 1702 str.print(" */"); 1703 } 1704 } 1705 1706 1707 public void FClass.prettyPrint_MC(Printer p, PrintStream str, String indent) { 1708 String nextInd = p.indent(indent); 1709 1710 p.print(getFFunctionDecls(), str, nextInd); 1711 p.print(getFRecordDecls(), str, nextInd); 1712 p.print(getFEnumDecls(), str, nextInd); 1713 1714 str.print(indent + "model " + nameUnderscore() + "\n"); 1715 for (FVariable fv : getFVariables()) { 1716 if (!fv.isDerivativeVariable() && !fv.isPreVariable()) { 1717 p.print(fv, str, nextInd); 1718 str.print(";\n"); 1719 } 1720 } 1721 1722 if (getNumFInitialEquation()>0) 1723 str.print(indent + "initial equation \n"); 1724 getFInitialEquations().prettyPrintWithFix(p, str, nextInd, "", ";\n"); 1725 1726 /* 1727 if (getNumFParameterEquation()>0) 1728 str.print(indent + "parameter equation\n"); 1729 getFParameterEquations().prettyPrintWithFix(p, str, nextInd, "", ";\n"); 1730 */ 1731 int block_index = 0; 1732 boolean wroteEquation = false; 1733 for (FEquationBlock b : getFEquationBlocks()) { 1734 for (FAbstractEquation e : b.getFAbstractEquations()) { 1735 if (e instanceof FAlgorithmBlock) { 1736 p.print(e, str, indent); 1737 wroteEquation = false; 1738 } else { 1739 if (!e.isIgnored()) { 1740 if (!wroteEquation) { 1741 str.print(indent); 1742 str.print("equation\n"); 1743 wroteEquation = true; 1744 } 1745 p.print(e, str, nextInd); 1746 str.print(";\n"); 1747 } 1748 } 1749 } 1750 block_index++; 1751 } 1752 1753 str.print(indent); 1754 str.print("end "); 1755 str.print(nameUnderscore()); 1756 str.print(";\n"); 1757 } 1758 1759 1760 public void ASTNode.prettyPrint_MC(PrintStream str, String indent) { 1761 prettyPrint_MC(printer_MC, str, indent); 1762 } 1763 1764 public void ASTNode.prettyPrint_MC(Printer p, PrintStream str, String indent) { 1765 prettyPrint(p, str, indent); 1766 } 1767 1768 public void FIdUseExp.prettyPrint_MC(Printer p, PrintStream str, String indent) { 1769 str.print(nameUnderscore()); 1770 } 1771 1772 public void FDerExp.prettyPrint_MC(Printer p, PrintStream str, String indent) { 1773 str.print("der("); 1774 str.print(getFIdUse().nameUnderscore()); 1775 str.print(")"); 1776 } 1777 1778 }
Note: See TracChangeset
for help on using the changeset viewer.