~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/Reports/Irony/Scripting/Runtime/Closure.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#region License
 
2
/* **********************************************************************************
 
3
 * Copyright (c) Roman Ivantsov
 
4
 * This source code is subject to terms and conditions of the MIT License
 
5
 * for Irony. A copy of the license can be found in the License.txt file
 
6
 * at the root of this distribution. 
 
7
 * By using this source code in any fashion, you are agreeing to be bound by the terms of the 
 
8
 * MIT License.
 
9
 * You must not remove this notice from this software.
 
10
 * **********************************************************************************/
 
11
#endregion
 
12
 
 
13
using System;
 
14
using System.Collections.Generic;
 
15
using System.Linq;
 
16
using System.Text;
 
17
using Irony.CompilerServices;
 
18
using Irony.Scripting.Ast;
 
19
 
 
20
namespace Irony.Scripting.Runtime {
 
21
 
 
22
  public class Closure {
 
23
    public string MethodName; //either BindingInfo.Name, or name of the variable storing lambda expression 
 
24
    public readonly Frame ParentFrame;
 
25
    public readonly AstNode Node;
 
26
    public readonly FunctionBindingInfo BindingInfo;
 
27
    public Closure(Frame parentFrame, AstNode node, FunctionBindingInfo bindingInfo) {
 
28
      MethodName = bindingInfo.Name;
 
29
      ParentFrame = parentFrame;
 
30
      Node = node; 
 
31
      BindingInfo = bindingInfo;
 
32
    }
 
33
    public void Evaluate(EvaluationContext context) {
 
34
      context.PushFrame(MethodName, Node, ParentFrame);
 
35
      try {
 
36
        BindingInfo.Evaluate(context);
 
37
      } finally {
 
38
        context.PopFrame();
 
39
      }//finally
 
40
    }//method
 
41
 
 
42
  }//class
 
43
 
 
44
 
 
45
 
 
46
}//namespace