Example #1
0
        public dynamic Visit(OperStm stm)
        {
            var node = new TreeNode(stm.Operation)
            {
                Tag = stm.Node
            };

            if (stm.Arguments != null)
            {
                node.Nodes.Add(Visit(stm.Arguments));
            }
            return(node);
        }
        public dynamic Visit(OperStm stm)
        {
            var args = stm.Arguments?.Values.Select(x => Visit((dynamic)x)).Cast <Operand>().ToArray() ?? new Operand[0];

            if (stm.Operation == "write")
            {
                _codeGen.WriteLine(args);
            }
            else if (stm.Operation == "call")
            {
                try
                {
                    var typeName   = (stm.Arguments.Values[0] as LiteralExpr).StrValue;
                    var type       = Type.GetType(typeName);
                    var methodName = (stm.Arguments.Values[1] as LiteralExpr).StrValue;
                    _codeGen.Invoke(type, methodName, args.Skip(2).ToArray());
                }
                catch (Exception)
                {
                    throw new InvalidOperationException("Правильное использвание функции call : call(TypeName, MethodName, optional args)");
                }
            }
            return(null);
        }
 public dynamic Visit(OperStm stm)
 {
     stm.OrderNumber = _count;
     VisitNext(stm);
     return(null);
 }
 public dynamic Visit(OperStm stm)
 {
     return(stm);
 }