The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
MethodDeclaration.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: MethodDeclaration.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a declaration of a concrete method. //
9 // Inheritance: IdDeclaration. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 14-01-2007 //
14 // Modification date: 22-05-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 
21 using Tools;
22 using TypeSystem;
23 using ErrorManagement;
24 
25 namespace AST {
35  #region Fields
36 
40  private List<Parameter> parametersInfo;
41 
45  private List<Modifier> modifiersInfo;
46 
50  private string returnTypeInfo;
51 
55  private bool isReturnDynamic;
56 
57  #endregion
58 
59  #region Properties
60 
64  public List<Modifier> ModifiersInfo {
65  get { return this.modifiersInfo; }
66  }
67 
71  public List<Parameter> ParametersInfo {
72  get { return this.parametersInfo; }
73  }
74 
78  public string ReturnTypeInfo {
79  get { return this.returnTypeInfo; }
80  protected set { this.returnTypeInfo = value; }
81  }
82 
86  public bool IsReturnDynamic {
87  get { return this.isReturnDynamic; }
88  set { this.isReturnDynamic = value; }
89  }
90 
91  #endregion
92 
93  #region Constructor
94 
104  public MethodDeclaration(SingleIdentifierExpression id, string returnType, List<Parameter> parameters, List<Modifier> modifiers, Location location)
105  : base(id, null, location) {
106  this.parametersInfo = parameters;
107  if (parameters == null)
108  this.parametersInfo = new List<Parameter>();
109  this.modifiersInfo = modifiers;
110  this.returnTypeInfo = returnType;
111  }
112 
113  #endregion
114 
115  #region SearchParam()
116 
122  public bool SearchParam(string param) {
123  for (int i = 0; i < this.parametersInfo.Count; i++) {
124  if (this.parametersInfo[i].Identifier.Equals(param))
125  return true;
126  }
127  return false;
128  }
129 
130  #endregion
131 
132  #region Accept()
133 
140  public override Object Accept(Visitor v, Object o) {
141  return v.Visit(this, o);
142  }
143 
144  #endregion
145  }
146 }
Abstract class to define different visits over the abstract syntax tree.
Definition: Visitor.cs:29
This class encapsulates a location in a specific file. Implements an Inmutable pattern. So it can be used in any context, that is his internal fields never change.
Definition: Location.cs:24
Encapsulates a identifier expression of our programming language.
Encapsulates a declaration of a concrete method.
List< Parameter > ParametersInfo
Gets the parameters information used to obtain its type
MethodDeclaration(SingleIdentifierExpression id, string returnType, List< Parameter > parameters, List< Modifier > modifiers, Location location)
Constructor of MethodDeclaration.
bool IsReturnDynamic
Gets or sets true if the return expression is a dynamic reference. Otherwise false.
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
string ReturnTypeInfo
Gets the information of the return type
Encapsulates a declaration.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
string Identifier
Gets the name associated to the declaration
bool SearchParam(string param)
Searches the specified param in the method parameter list.
List< Modifier > ModifiersInfo
Gets the modifiers information used to obtain its type