~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/Reports/Irony/Scripting/AST/AssigmentNode.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.Scripting.Runtime;
 
18
 
 
19
namespace Irony.Scripting.Ast {
 
20
  public class AssigmentNode : AstNode {
 
21
    public VarRefNode Identifier;
 
22
    public AstNode Expression;
 
23
 
 
24
    public AssigmentNode(NodeArgs args)  : this(args, args.ChildNodes[0], args.ChildNodes[2]) {  }
 
25
 
 
26
    public AssigmentNode(NodeArgs args, AstNode lvalue, AstNode expression) : base(args) {
 
27
      ChildNodes.Clear();
 
28
      var Identifier = lvalue as VarRefNode;
 
29
      if (Identifier == null) {
 
30
        args.Context.ReportError(lvalue.Location, "Expected identifier.");
 
31
        return; 
 
32
      }
 
33
      Identifier.Flags |= AstNodeFlags.AllocateSlot | AstNodeFlags.NotRValue;
 
34
      Identifier.Access = AccessType.Write;
 
35
      AddChild("Name", Identifier);
 
36
      Expression = expression;
 
37
      AddChild("Expr", Expression);
 
38
    }
 
39
 
 
40
    protected override void DoEvaluate(EvaluationContext context) {
 
41
      Expression.Evaluate(context);
 
42
      Identifier.Evaluate(context); //writes the value into the slot
 
43
    }
 
44
 
 
45
  }
 
46
}