/* * Copyright © 2011, Petro Protsyk, Denys Vuika * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; namespace Scripting.SSharp.Runtime { /// /// Base interface for Script Context obect. /// ScriptContext object stores run-time information during script's execution /// This information containts: /// Scopes - which stores variables, types and functions /// Execution Flow Flags - break, return, continue /// /// ScriptContext objects also evaluates operators /// public interface IScriptContext : IDisposable { #region Scopes /// /// Create scope /// IScriptScope CreateScope(); /// /// Add given scope to hierarchy /// /// new scope IScriptScope CreateScope(IScriptScope scope); /// /// Removes local scope /// void RemoveLocalScope(); /// /// Current scope /// IScriptScope Scope { get; } /// /// Returns item from scope hierarchy /// /// name /// /// value object GetItem(string id, bool throwException); /// /// Sets item to scope hierarchy /// /// name /// value void SetItem(string id, object value); /// /// Create reference to an exising variable in scope hierarchy /// /// /// IValueReference Ref(string id); /// /// Occurs before referencing process, giving ability to cancel it and return custom result /// event EventHandler Referencing; /// /// Occurs when referencing successful just before returning value /// event EventHandler Referenced; /// /// Finds function definition /// /// name /// function object IInvokable GetFunctionDefinition(string name); #endregion #region Break-Continue-Return void SetReturn(bool val); void SetBreak(bool val); void SetContinue(bool val); bool IsReturn(); bool IsBreak(); bool IsContinue(); /// /// Reset all flags that control execution. Called on each context /// before and after script execution /// void ResetControlFlags(); #endregion #region Common /// /// Result of script execution /// object Result { get; set; } Script Owner { get; } #endregion } }