Math2mat

/home/ythoma/docs/math2mat/svn/wp1/framework/m2mGUI/src/m2m/backend/structure/Assignment.java

Go to the documentation of this file.
00001 /******************************************************************************
00002  *                                                                                      Assignment
00003  ******************************************************************************
00004  * Auteur               : Trolliet Gregory
00005  * Date                 : 4 mars 2009
00006  * Description : Assignment
00007  ******************************************************************************/
00008 package m2m.backend.structure;
00009 
00017 public class Assignment extends Operation {
00018 
00019         final static String OPNAME="ass";
00020         //final static String OPNAME="aff";
00021         
00022         public Assignment() {
00023                 super(OPNAME);
00024                 this.setName(OPNAME);
00025         }
00026 
00027         @Override
00028         public void copyTo(Element e,Function newFunc) {
00029                 Assignment newElement=(Assignment)e;
00030                 super.copyTo(newElement,newFunc);
00031         }
00032         
00033         @Override
00034         public Element copy(Function newFunc) {
00035                 Assignment newElement=new Assignment();
00036                 this.copyTo(newElement,newFunc);
00037                 return newElement;
00038         }
00039         
00040         @Override
00041         public String getOpSymbol() {
00042                 return "=";
00043         }
00044 
00045         @Override
00046         public String toOctave(int level) {
00047                 String sOctave = new String();
00048                 Element out = this.output.firstElement();
00049                 sOctave += tab(level) + out.getName() + "\t= ";
00050                 if (this.input.firstElement() instanceof SimpleVariable) {
00051                         SimpleVariable var = (SimpleVariable)this.input.firstElement();
00052                         if (var.getName().isEmpty()) {
00053                                 sOctave += var.getVal();
00054                         } else if (var.getType().equals("const")) {
00055                                 sOctave += var.getVal();
00056                         } else {
00057                                 sOctave += this.input.firstElement().getName();
00058                         }
00059                 }
00060                 if (!monitor) {
00061                         sOctave += ";";
00062                 }
00063                 if (out instanceof SimpleVariable & out.monitor) 
00064                 {
00065                         sOctave += "\n" + tab(level) + "for j_m2m_regen=1:length(interns)";
00066                         sOctave += "\n" + tab(level+1) + "if(length(interns(j_m2m_regen).sname) == length(\"" + out.getName() +"\") && interns(j_m2m_regen).sname == \"" + out.getName() + "\")";
00067                         sOctave += "\n" + tab(level+2) + "interns(j_m2m_regen).values(i_m2m_regen,:) = " + out.getName() + ";";
00068                         sOctave += "\n" + tab(level+1) + "endif";
00069                     sOctave += "\n" + tab(level) + "endfor"; 
00070                 }
00071                 return sOctave;
00072         }
00073 }
 All Classes Namespaces Files Functions Variables Enumerations