Пример #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);
 }
Пример #2
0
 public override void WriteTo(Writer writer)
 {
     writer.Write(Name);
 }
Пример #3
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("new util.StructDefinition(");
     InitialValues.WriteTo(writer);
     writer.Write(")");
 }
Пример #4
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("<<<" + SPAGSFunction.Name + ">>>");
 }
Пример #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));
 }
Пример #6
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("util.imul(");
     Left.WriteTo(writer);
     writer.Write(", ");
     Right.WriteTo(writer);
     writer.Write(")");
 }
Пример #7
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("util.fillArray(");
     Value.WriteTo(writer);
     writer.Write(", ");
     Length.WriteTo(writer);
     writer.Write(")");
 }
Пример #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);
     }
 }
Пример #9
0
 public override void WriteTo(Writer writer)
 {
     WriteBlockContents(writer);
     writer.WriteLineThenIndent();
 }
Пример #10
0
 public override void WriteTo(Writer writer)
 {
     Expression.WriteTo(writer);
 }
Пример #11
0
 public override void WriteTo(Writer writer)
 {
     Block.WriteTo(writer);
 }
Пример #12
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("while (");
     WhileThisIsTrue.WriteTo(writer);
     writer.Write(") ");
     KeepDoingThis.WriteTo(writer);
 }
Пример #13
0
 public abstract void WriteTo(Writer writer);
Пример #14
0
 public override void WriteTo(Writer writer)
 {
     if (Value == null)
     {
         writer.Write("return");
     }
     else
     {
         writer.Write("return ");
         Value.WriteTo(writer);
     }
 }
Пример #15
0
 public ScopeContext(Writer writer, ScopedBlock block)
 {
     this.writer = writer;
     Block = block;
     writer.scopeStack.Push(this);
 }
Пример #16
0
 public override void WriteTo(Writer writer)
 {
     writer.Write("new util.StringBuffer()");
 }
Пример #17
0
 internal IndentationBlock(Writer writer)
 {
     this.writer = writer;
     writer.indent++;
 }
Пример #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);
         }
     }
 }