Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public GlobalScope CreateFunctionScope(GlobalScope scope)
        {
            var newScope = scope.DeriveFunctionScope();

            return(newScope);
        }
Exemplo n.º 3
0
        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)"));
            }
        }
Exemplo n.º 4
0
 /// <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());
 }