/// <summary> /// Searches the scope hierarchy for the given id, /// should return NoVariable if it is not found /// </summary> /// <param name="id"></param> /// <returns></returns> protected virtual object GetVariableInternal(string id, bool searchHierarchy) { if (vars.ContainsKey(id)) { return(vars[id]); } if (!searchHierarchy) { return(RuntimeHost.NoVariable); } IScriptScope scope = Parent; while (scope != null) { if (scope.HasVariable(id)) { return(scope.GetItem(id, true)); } scope = scope.Parent; } return(RuntimeHost.NoVariable); }
/// <summary> /// Searches the scope hierarchy for the given id, /// should return NoVariable if it is not found /// </summary> /// <param name="id"></param> /// <param name="searchHierarchy"></param> /// <returns></returns> protected virtual object GetVariableInternal(string id, bool searchHierarchy) { IValueReference result; if (_vars.TryGetValue(id, out result)) { return(result.Value); } if (!searchHierarchy) { return(RuntimeHost.NoVariable); } IScriptScope scope = Parent; while (scope != null) { if (scope.HasVariable(id)) { return(scope.GetItem(id, true)); } scope = scope.Parent; } return(RuntimeHost.NoVariable); }
private object GetIndentifierValue(IScriptContext context, string identifier) { //object result = context.GetItem(identifier, false); //if (result != RuntimeHost.NoVariable) return result; if (IsGlobal) { _variable = null; IScriptScope scope = context.Scope.Parent; while (scope != null) { if (scope.HasVariable(identifier)) { return(scope.GetItem(identifier, true)); } scope = scope.Parent; } } else { if (_variable != null && _variable.Value != null) { return(_variable.Value); } object result; _variable = CreateRef(identifier, context, true, out result); if (result != RuntimeHost.NoVariable) { return(result); } } return(RuntimeHost.HasType(identifier) ? (object)RuntimeHost.GetType(identifier) : NamespaceResolver.Get(identifier)); }