Esempio n. 1
0
        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="caller">调用上下文</param>
        /// <param name="args">实际参数</param>
        /// <returns></returns>
        public VarData Run(VarData caller, VarData[] args)
        {
            // 将调用上下文(CallContext.VarTable)和实参保存在函数上下文(VarTable)中
            // 还有父类上下文(BaseContext.VarTable)和外层上下文(OutContext.VarTable)
            // 局部上下文(LocalContext.VarTable)

            return(null);
        }
Esempio n. 2
0
 /// <summary>
 /// 获取其值
 /// </summary>
 /// <param name="data">数据</param>
 /// <returns></returns>
 public static object GetData(VarData data)
 {
     if (data.IsUnit)
     {
         return(data.Data);
     }
     else
     {
         return(GetData(data.Get()));
     }
 }
Esempio n. 3
0
        public static ValueUnit New(VarData value)
        {
            //Run

            ValueUnit unit = new ValueUnit
            {
                IsInit = false,
                IsRan  = false,
                Scope  = Unit.New(null)
            };

            return(unit);
        }
Esempio n. 4
0
        public static WNumber New(double d)
        {
            Unit context = Unit.New(null);

            context.VarMap.Set("argument", VarData.New(d));
            context.VarMap.Set("returnvalue", VarData.New(d));
            return(new WNumber
            {
                IsInit = true,
                IsRan = true,
                Scope = context
            });
        }
Esempio n. 5
0
        /// <summary>
        /// 创建此类实例
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static WString New(string value)
        {
            Unit context = Unit.New(null);

            context.VarMap.Set("argument", VarData.New(value));
            context.VarMap.Set("returnvalue", VarData.New(value));
            return(new WString
            {
                IsInit = true,
                IsRan = true,
                Scope = context
            });
        }
Esempio n. 6
0
 /// <summary>
 /// 设置当前Unit值的参数,这里将不会立即执行
 /// 将会忽略Unit的Name属性
 /// </summary>
 /// <param name="args"></param>
 public virtual void Set(params Unit[] args)
 {
     // 如果传入的是字符串
     if (args != null && args.Length >= 1 && args[0].GetValue().Data is string)
     {
         var code = args[0].GetValue().Data as string;
         VarMap.Set("source", VarData.New(code));  // source 用来保存源代码以及所在的位置,这里暂时只保存源代码
         IsInit = true;
     }
     else
     {
         throw new NotImplementedException("Set 函数没有实现");
     }
 }
Esempio n. 7
0
 public override Unit Run(params Unit[] args)
 {
     // 参数解析
     VarData[] values = new VarData[args.Length];
     for (int i = 0; i < values.Length; i++)
     {
         values[i] = args[i].GetValue();
     }
     // 缓存参数
     VarMap.Set("arguments", new VarData
     {
         //Type = values.GetType(),
         Kind = "Array[Unit]",
         Data = values
     });
     // 函数执行
     return(base.Run(args));
 }
Esempio n. 8
0
 public static VarData Apply(VarData caller, VarData[] agrs)
 {
     return(null);
 }