Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
MethodInvocationExpression.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 
6 namespace SiliconStudio.Shaders.Ast
7 {
8  /// <summary>
9  /// A method invocation.
10  /// </summary>
12  {
13  /// <summary>
14  /// Initializes a new instance of the <see cref="MethodInvocationExpression"/> class.
15  /// </summary>
17  {
18  Initialize(null);
19  }
20 
21  /// <summary>
22  /// Initializes a new instance of the <see cref="MethodInvocationExpression"/> class.
23  /// </summary>
24  /// <param name="name">The name.</param>
25  /// <param name="arguments">The arguments.</param>
26  public MethodInvocationExpression(string name, params Expression[] arguments)
27  {
28  Initialize(new VariableReferenceExpression(name), arguments);
29  }
30 
31  /// <summary>
32  /// Initializes a new instance of the <see cref="MethodInvocationExpression"/> class.
33  /// </summary>
34  /// <param name="target">The target.</param>
35  /// <param name="arguments">The arguments.</param>
36  public MethodInvocationExpression(Expression target, params Expression[] arguments)
37  {
38  Initialize(target, arguments);
39  }
40 
41  private void Initialize(Expression target, params Expression[] arguments)
42  {
43  Target = target;
44  Arguments = new List<Expression>();
45  if (arguments != null)
46  Arguments.AddRange(arguments);
47  }
48 
49  /// <summary>
50  /// Gets or sets the target.
51  /// </summary>
52  /// <value>
53  /// The target.
54  /// </value>
55  public Expression Target { get; set; }
56 
57  /// <summary>
58  /// Gets or sets the arguments.
59  /// </summary>
60  /// <value>
61  /// The arguments.
62  /// </value>
63  public List<Expression> Arguments { get; set; }
64 
65  /// <inheritdoc/>
66  public override IEnumerable<Node> Childrens()
67  {
68  ChildrenList.Clear();
69  ChildrenList.AddRange(Arguments);
70  ChildrenList.Add(Target);
71  return ChildrenList;
72  }
73 
74  /// <inheritdoc/>
75  public override string ToString()
76  {
77  return string.Format("{0}({1})", Target, string.Join(",", Arguments));
78  }
79  }
80 }
MethodInvocationExpression(Expression target, params Expression[] arguments)
Initializes a new instance of the MethodInvocationExpression class.
override IEnumerable< Node > Childrens()
Gets the child nodes. An enumeration of child nodes
MethodInvocationExpression()
Initializes a new instance of the MethodInvocationExpression class.
MethodInvocationExpression(string name, params Expression[] arguments)
Initializes a new instance of the MethodInvocationExpression class.