/// <summary> /// Close all opened scopes /// </summary> public void CloseScope() { _symbolsCache.Clear(); RefResContext.CloseScopes(); this.ReportNormal("Close All Scopes"); }
/// <summary> /// Initialize this interpreter by: /// 1- Set the root AST of this interpreter to the given symbol's AST /// 2- Create a temp command block for this interpreter inside the given symbol /// 3- Initialize the scope information by setting the main scope to the command block with no /// opened scopes /// 4- Initialize the internal expression evaluator to dynamic evaluation mode on the command block /// </summary> /// <param name="symbolName">The name of a frame or a namespace, no other symbols are allowed</param> public void Reset(string symbolName) { if (RefResContext.MainScope == null) { RefResContext.SetMainScope(Root.AssociatedAst.RootScope); } var symbol = Symbol(symbolName); Reset(symbol); }
/// <summary> /// Adds the child scope of the given frame to the opened scopes /// </summary> /// <param name="symbol"></param> public void OpenScope(AstFrame symbol) { if (symbol.IsNullOrInvalid()) { this.ReportNormal("Open Scope", ProgressEventArgsResult.Failure); return; } RefResContext.OpenScope(symbol); this.ReportNormal("Open Scope", symbol.AccessName, ProgressEventArgsResult.Success); }
/// <summary> /// Close the child scope of the given frame /// </summary> /// <param name="symbol"></param> public void CloseScope(AstFrame symbol) { if (symbol.IsNullOrInvalid()) { this.ReportNormal("Close Scope", ProgressEventArgsResult.Failure); return; } _symbolsCache.Clear(); RefResContext.CloseScope(symbol); this.ReportNormal("Close Scope", symbol.AccessName, ProgressEventArgsResult.Success); }
/// <summary> /// The main Reset method called by all others. The given symbol must be a frame or a namespace /// </summary> /// <param name="symbol"></param> public void Reset(AstSymbol symbol) { if (symbol.IsNullOrInvalid() || (symbol.IsValidFrame == false && symbol.IsValidNamespace == false)) { this.ReportNormal("Reset Interpreter", ProgressEventArgsResult.Failure); return; } Output.Clear(); Root = symbol.Root; _mainCommandBlock = CommandBlock.Create(symbol.AssociatedSymbol as SymbolWithScope); RefResContext.Clear(_mainCommandBlock); _expressionEvaluator = GMacExpressionEvaluator.CreateForDynamicEvaluation(_mainCommandBlock); _symbolsCache.Clear(); this.ReportNormal("Reset Interpreter", symbol.AccessName, ProgressEventArgsResult.Success); }