The StaDyn Programming Language
Source code documentation of StaDyn, a hybrid static and dynamic typing language.
MethodDefinition.cs
Go to the documentation of this file.
1 // -------------------------------------------------------------------------- //
3 // Project rROTOR //
4 // -------------------------------------------------------------------------- //
5 // File: MethodDefinition.cs //
6 // Author: Cristina Gonzalez Muņoz - cristi.gm@gmail.com //
7 // Description: //
8 // Encapsulates a definition of a concrete method. //
9 // Inheritance: MethodDeclaration. //
10 // Implements Composite pattern [Composite]. //
11 // Implements Visitor pattern [Concrete Element]. //
12 // -------------------------------------------------------------------------- //
13 // Create date: 07-12-2006 //
14 // Modification date: 31-05-2007 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Text;
20 using Inference.Core;
21 using Tools;
22 using TypeSystem;
23 using ErrorManagement;
24 
25 namespace AST {
35  #region Fields
36 
40  private Block body;
41 
45  private bool isEntryPoint;
46 
47  #endregion
48 
49  #region Properties
50 
54  public Block Body {
55  get { return this.body; }
56  }
57 
61  public bool IsEntryPoint {
62  get { return this.isEntryPoint; }
63  }
64 
65  #endregion
66 
67  #region Constructor
68 
80  public MethodDefinition(SingleIdentifierExpression id, Block stats, string returnType, List<Parameter> parameters, List<Modifier> modifiers, Location location)
81  : base(id, returnType, parameters, modifiers, location) {
82 
83  this.body = stats;
84  if (modifiers.Contains(Modifier.Static) && id.Identifier.Equals("Main")) {
85  Program.SetEntryPointFound(this.Location);
86  this.isEntryPoint = true;
87  }
88  }
89 
90  #endregion
91 
92  #region Accept()
93 
100  public override Object Accept(Visitor v, Object o) {
101  return v.Visit(this, o);
102  }
103 
104  #endregion
105  }
106 }
Encapsulates a definition of a concrete method.
Encapsulates a block of statements.
Definition: Block.cs:34
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
override Object Accept(Visitor v, Object o)
Accept method of a concrete visitor.
Encapsulates a identifier expression of our programming language.
Encapsulates a declaration of a concrete method.
MethodDefinition(SingleIdentifierExpression id, Block stats, string returnType, List< Parameter > parameters, List< Modifier > modifiers, Location location)
Constructor of MethodDefinition.
Location location
Location: Encapsulates in one object the line, column and filename
Definition: AstNode.cs:39
Modifier
Indicates differents modifiers to use in class (only public, internal or static), fields or methods...
bool IsEntryPoint
True if the method definition is a entry point. Otherwise, false.
Block Body
Gets the body of the method