public VMException(FunctionDefn defn, string filename, Statement st, Exception inner) : base("", inner) { this.defn = defn; this.st = st; this.filename = filename; }
private void GetFreeVars(VM vm, Statement st, Stack<string> boundVars, Scope result) { // InternalCount and store the names defined by this statement int nNewVars = 0; foreach (string name in st.GetDefinedNames()) { ++nNewVars; boundVars.Push(name); } // Iterate over all names used by expressions in the statement foreach (string name in st.GetUsedNames()) { // Is this not a boundVar, and not already marked as a free var if (!boundVars.Contains(name) && !result.HasName(name)) { // Throws an exception if the name is not found HeronValue v = vm.LookupName(name); result.Add(new VarDesc(name), v); } } // Recurse over all sub statements, getting the free vars foreach (Statement child in st.GetSubStatements()) GetFreeVars(vm, child, boundVars, result); // Pop all variables added by this variable for (int i = 0; i < nNewVars; ++i) boundVars.Pop(); }
/// <summary> /// Call this instead of "Stsatement.Eval()", this way you can set /// breakpoints etc. /// </summary> /// <param name="value"></param> /// <returns></returns> public void Eval(Statement statement) { CurrentStatement = statement; statement.Eval(this); }