Exemplo n.º 1
0
 protected override void WriteBlockContents(Writer writer)
 {
     if (Variables.Count > 0)
     {
         writer.Write("var ");
         bool first = true;
         foreach (string variableName in Variables.Keys)
         {
             if (first)
             {
                 first = false;
             }
             else
             {
                 writer.Write(", ");
             }
             writer.Write(variableName);
             Variable v = Variables[variableName];
             if (v.InitialValue != null)
             {
                 writer.Write(" = ");
                 v.InitialValue.WriteTo(writer);
             }
         }
         writer.Write(";");
         if (this.Count > 0)
         {
             writer.WriteLineThenIndent();
         }
     }
     base.WriteBlockContents(writer);
 }
Exemplo n.º 2
0
 public override void WriteTo(Writer writer)
 {
     writer.Write(Name);
 }
Exemplo n.º 3
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("new util.StructDefinition(");
     InitialValues.WriteTo(writer);
     writer.Write(")");
 }
Exemplo n.º 4
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("<<<" + SPAGSFunction.Name + ">>>");
 }
Exemplo n.º 5
0
 public override void WriteTo(Writer writer)
 {
     int start = 0;
     foreach (Match match in Regex.Matches(funcExpr.Pattern, @"\{(\d+)(\:([^\}]+))?\}"))
     {
         writer.Write(funcExpr.Pattern.Substring(start, match.Index - start));
         start = match.Index + match.Length;
         int num = int.Parse(match.Groups[1].Value);
         if (num > parameters.Count)
         {
             throw new Exception("Not enough parameters to " + funcExpr.SPAGSFunction.Name + " (got " + parameters.Count + ")");
         }
         Expression newExpr = parameters[num];
         PossibleValueTypes castTypes;
         if (match.Groups[3].Success)
         {
             castTypes = (PossibleValueTypes)Enum.Parse(typeof(PossibleValueTypes), match.Groups[3].Value);
         }
         else
         {
             castTypes = funcExpr.convert.GetValueTypes(funcExpr.SPAGSFunction.Signature.Parameters[num].Type);
         }
         newExpr = newExpr.Cast(castTypes);
         newExpr.WriteTo(writer);
     }
     writer.Write(funcExpr.Pattern.Substring(start));
 }
Exemplo n.º 6
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("util.imul(");
     Left.WriteTo(writer);
     writer.Write(", ");
     Right.WriteTo(writer);
     writer.Write(")");
 }
Exemplo n.º 7
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("util.fillArray(");
     Value.WriteTo(writer);
     writer.Write(", ");
     Length.WriteTo(writer);
     writer.Write(")");
 }
Exemplo n.º 8
0
 public override void WriteTo(Writer writer)
 {
     for (int i = 0; i < Assignments.Count; i++)
     {
         if (i > 0)
         {
             writer.Write(";");
             writer.WriteLineThenIndent();
         }
         Assignments[i].WriteTo(writer);
     }
 }
Exemplo n.º 9
0
 public override void WriteTo(Writer writer)
 {
     WriteBlockContents(writer);
     writer.WriteLineThenIndent();
 }
Exemplo n.º 10
0
 public override void WriteTo(Writer writer)
 {
     Expression.WriteTo(writer);
 }
Exemplo n.º 11
0
 public override void WriteTo(Writer writer)
 {
     Block.WriteTo(writer);
 }
Exemplo n.º 12
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("while (");
     WhileThisIsTrue.WriteTo(writer);
     writer.Write(") ");
     KeepDoingThis.WriteTo(writer);
 }
Exemplo n.º 13
0
 public abstract void WriteTo(Writer writer);
Exemplo n.º 14
0
 public override void WriteTo(Writer writer)
 {
     if (Value == null)
     {
         writer.Write("return");
     }
     else
     {
         writer.Write("return ");
         Value.WriteTo(writer);
     }
 }
Exemplo n.º 15
0
 public ScopeContext(Writer writer, ScopedBlock block)
 {
     this.writer = writer;
     Block = block;
     writer.scopeStack.Push(this);
 }
Exemplo n.º 16
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("new util.StringBuffer()");
 }
Exemplo n.º 17
0
 internal IndentationBlock(Writer writer)
 {
     this.writer = writer;
     writer.indent++;
 }
Exemplo n.º 18
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("if (");
     Condition.WriteTo(writer);
     writer.Write(") ");
     ThenDoThis.WriteTo(writer);
     if (ElseDoThis.Count != 0)
     {
         writer.WriteLineThenIndent();
         writer.Write("else ");
         if (ElseDoThis.Count == 1 && ElseDoThis[0] is If)
         {
             ElseDoThis[0].WriteTo(writer);
         }
         else
         {
             ElseDoThis.WriteTo(writer);
         }
     }
 }