public GlobalScope AddOrGetRootScope(string name) { var existing = _globalScopes.FirstOrDefault(g => g.FileName == name); if (existing != null) { return(existing); } var newScope = new GlobalScope(_errorHandler, name); _globalScopes.Add(newScope); return(newScope); }
public GlobalScope CreateFunctionScope(GlobalScope scope) { var newScope = scope.DeriveFunctionScope(); return(newScope); }
public void Register(MethodPointer name, Method method, IRuntime runtime, string processingStackName, GlobalScope scope) { var methodName = $"{name.NameSpace}.{name.Name}"; if (!_procedures.ContainsKey(methodName)) { method.GlobalScopeName = processingStackName; method.RootScope = scope; _procedures.Add(methodName, method); } else { runtime.AddError(new LinkingError($"Failed to reregister method {methodName} (already declared)")); } }
/// <summary> /// Used to create derived scope (with access to all root variables) /// </summary> /// <param name="errorHandler"></param> /// <param name="rootScope"></param> protected GlobalScope(IErrorHandler errorHandler, GlobalScope rootScope) { _errorHandler = errorHandler; ScopesStack.Push(rootScope.GetBoottomScope()); }