private void WriteFunction(Programmer.Function function) { d_writer.WriteLine("Cdn.Networks.{0}.prototype.{1} = function ({2}) {{", CPrefix, function.Name, GenerateArgsList(function)); d_writer.WriteLine("\treturn {0};", FunctionToJS(function)); d_writer.WriteLine("}"); d_writer.WriteLine(); }
private string FunctionToJS(Programmer.Function function) { CLike.Context context = new Context(d_program, d_options, function.Expression, GenerateMapping("x{0}", function.Arguments)); return(InstructionTranslator.QuickTranslate(context)); }
private string GenerateArgsList(Programmer.Function function) { List <string> ret = new List <string>(function.NumArguments + 2); if (function.IsCustom) { int i = 0; foreach (var arg in function.CustomArguments) { ret.Add(String.Format("x{0}", i)); ++i; } } else { for (int i = 0; i < function.OrderedArguments.Count; ++i) { ret.Add(String.Format("x{0}", i)); } } return(String.Join(", ", ret.ToArray())); }
public override string FunctionCallName(Programmer.Function function) { return(ThisCall(function.Name)); }
public virtual string FunctionCallName(Programmer.Function function) { return(ThisCall(function.Name)); }
public Function(Programmer.Function function) { d_function = function; }