/// <summary>Pushes a new set of variables, to start a scope.</summary> public void PushVarSet() { LVarIDs.Push(CLVariables.Count); CLVariables.Add(new List <SingleCILVariable>()); }
/// <summary> /// Returns the object referenced by the name. /// </summary> /// <param name="vars">A <c>CLLocalStore</c> that stores local /// variables.</param> /// <param name="context">The object representing the context in which /// the expression is being evaluated.</param> public CalcObject GetObject(CLLocalStore vars = null, CLContextProvider context = null) { vars ??= new CLLocalStore(); context ??= new CLContextProvider(); if (Name.StartsWith("!")) { if (CLCodeFunction.Exists(Name.Substring(1))) { return(new CalcCodeFunction(Name.Substring(1), Params)); } } if (Name.StartsWith("_") || Name.StartsWith("^")) { if (!(vars.ContainsVar(Name))) { throw new CLException("No variable named " + Name + " exists."); } else { return(vars[Name]); } } int count = 0; if (Int32.TryParse(Name, out count)) { if (count == 0) { return(new CalcString(Name)); } if (vars.ParamCount >= count) { return(vars[count - 1]); } else if (Params.Length > 0) { return(Params[0]); } else { throw new CLException("No parameter #" + count + " exists."); } } if (Name == "...") { return(new CalcListExpression(vars.CopyParams())); } CalcObject ret = CLVariables.Load(Name, context); if (ret != null) { return(ret); } throw new CLException("No variable named " + Name + " exists."); }