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
9
* You must not remove this notice from this software.
10
* **********************************************************************************/
14
using System.Collections.Generic;
17
using Irony.Scripting.Runtime;
19
namespace Irony.Scripting.Ast {
20
public class AssigmentNode : AstNode {
21
public VarRefNode Identifier;
22
public AstNode Expression;
24
public AssigmentNode(NodeArgs args) : this(args, args.ChildNodes[0], args.ChildNodes[2]) { }
26
public AssigmentNode(NodeArgs args, AstNode lvalue, AstNode expression) : base(args) {
28
var Identifier = lvalue as VarRefNode;
29
if (Identifier == null) {
30
args.Context.ReportError(lvalue.Location, "Expected identifier.");
33
Identifier.Flags |= AstNodeFlags.AllocateSlot | AstNodeFlags.NotRValue;
34
Identifier.Access = AccessType.Write;
35
AddChild("Name", Identifier);
36
Expression = expression;
37
AddChild("Expr", Expression);
40
protected override void DoEvaluate(EvaluationContext context) {
41
Expression.Evaluate(context);
42
Identifier.Evaluate(context); //writes the value into the slot