Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnonymousFunction"/> class.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 /// <param name="statements">The statements.</param>
 public AnonymousFunction(ParameterList parameters, StatementList statements)
 {
     this.Parameters = parameters;
     this.Statements = statements;
     this.Type = new ClassType("Func",
                     new GenericTypeArgumentList(
                         parameters.Parameters.ForEach(x => new GenericTypeArgument(x.Type.Name, x.Type.GenericTypeArguments, x.Type.ReturnType))
                                              .ToList(x => (IGenericTypeArgument)x)
                     ),
                     statements.FirstOrDefault(x => (x as ReturnStatement) != null)
                               .Chain(x => (x as ReturnStatement).Expression.Type,
                                         parameters.FirstOrDefault().Chain(y => y.Type,
                                                         new ClassType("dynamic", new GenericTypeArgumentList(), null)))
                 );
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Program"/> class.
 /// </summary>
 /// <param name="statements">The statements.</param>
 public Program(StatementList statements)
 {
     this.Statements = statements;
 }