private static IExpression GetMember(RuntimeData runtime, IExpression parent, Member searchToken) { // まずは変数を検索する if (parent == null) { if (runtime.ContainsKey(searchToken.Text)) { return(runtime.GetData(searchToken.Token)); } } // 親メンバーから検索 if (parent != null) { throw new NotImplementedException(); } // フィールドメンバーから検索 if (parent == null) { if (runtime.ContainsFunc(searchToken.Text)) { return(runtime.GetFunc(searchToken, false)); } } // 不明なものはとりあえず変数と見立てる if (parent == null) { return(new Variable(searchToken.Token)); } throw new SyntaxException(string.Format("'{0}'は見つかりませんでした", searchToken.Text), searchToken.Token, new KeyNotFoundException()); }
public override INumber Execute(RuntimeData runtime, params INumber[] parameters) { var param = parameters[0]; if (param is Variable || param is Member) { string name = ""; if (param is Variable) { name = (param as Variable).Name; } if (param is Member) { name = (param as Member).Text; } if (runtime.ContainsFunc(name)) { var func = runtime.GetFunc(param, false); if (func is UserDefineFunction) { return((func as UserDefineFunction).Formula as INumber); } } } return(parameters[0].Eval(runtime)); }