Exemple #1
0
 private static void Emit(Function func)
 {
     Source += "public static " + MakeString(func.ReturnType) + " " + func.Name.Text + "(";
     EmitLocalParam(func);
     Source += ")\n{\n";
     EmitLocalVariable(func);
     EmitBody(func.GetSpecifiedChildren<Body>().First(), func);
     Source += "}\n";
 }
Exemple #2
0
 private static void EmitBody(Body body, Function func = null)
 {
     if (func == null)
         foreach (var st in body.Statements)
         {
             Emit(st);
         }
     else
         foreach (var st in body.Statements)
         {
             if (st is Assignment)
             {
                 var s = st as Assignment;
                 if (string.Join(".", s.Variable.Select(x => x.Text)) == func.Name.Text)
                 {
                     Source += "return ";
                     if (s.Invoke == null)
                         Source += MakeString(s.Expr) + ";\n";
                     else
                         EmitInvoke(s.Invoke);
                     break;
                 }
             }
             Emit(st);
         }
 }