Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ParamListNode.cs
Go to the documentation of this file.
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.Interpreter;
18 using Irony.Parsing;
19 
20 namespace Irony.Interpreter.Ast {
21 
22  public class ParamListNode : AstNode {
23 
24  public override void Init(ParsingContext context, ParseTreeNode treeNode) {
25  base.Init(context, treeNode);
26  foreach (var child in treeNode.ChildNodes) {
27  AddChild("parameter", child);
28  }
29  AsString = "Param list";
30  }
31 
32  public override void EvaluateNode(EvaluationContext context, AstMode mode) {
33  var argsObj = context.Data.Pop();
34  var args = argsObj as ValuesList;
35  if (args == null)
36  context.ThrowError(Resources.ErrArgListNotFound, argsObj);
37  if (args.Count != ChildNodes.Count)
38  context.ThrowError(Resources.ErrWrongArgCount, ChildNodes.Count, args.Count);
39 
40  for(int i = 0; i < ChildNodes.Count; i++) {
41  context.Data.Push(args[i]);
42  ChildNodes[i].Evaluate(context, AstMode.Write);
43  }
44  }//method
45 
46  }//class
47 
48 }//namespace
static string ErrArgListNotFound
Looks up a localized string similar to Argument list not found in the stack. Expected: ValueList...
override void Init(ParsingContext context, ParseTreeNode treeNode)
static string ErrWrongArgCount
Looks up a localized string similar to Invalid number of arguments. Expected {0}, found {1}...
override void EvaluateNode(EvaluationContext context, AstMode mode)