Пример #1
0
        internal IDisposable RegisterFunction(LexerNode lexer, FunctionDeclarationNode node)
        {
            if (!CanRegisterGlobalFunction())
            {
                throw new SemanticException($"Unavailable function declaration '{lexer.Value}' inside another function '{currentRegistration.Name}'");
            }
            var f = new FuncGloalObject {
                Name = lexer, Node = node
            };

            global.Add(lexer.Value, f);
            scopes.Add(lexer.Value, f);

            currentRegistration = new ScopeRegistration(lexer.Value, f);
            return(currentRegistration);
        }
Пример #2
0
        internal FuncGloalObject GetScope(TextRange range)
        {
            FuncGloalObject currentScope = null;

            try {
                foreach (var scope in scopes)
                {
                    var box               = scope.Value.Node.Boundary;
                    var start             = scope.Value.Node.VarDeclaration.DeclarationName.NameLex.StartPointer;
                    var fromStartToCurent = start.GetOffsetToPosition(range.Start);
                    var fromCurrenToEnd   = range.Start.GetOffsetToPosition(box.EndPointer.StartPointer);
                    if (fromStartToCurent > 0 && fromCurrenToEnd > 0)
                    {
                        currentScope = scope.Value;
                        break;
                    }
                }
            }catch (Exception ex) {
                Console.WriteLine(ex);
            }
            return(currentScope);
        }
Пример #3
0
        internal IEnumerable <string> GetVariableOfScopeByWorlds(string worlds, FuncGloalObject currentScope)
        {
            var valiables = currentScope.VariableTypesMapper.Keys.Where(x => x.StartsWith(worlds));

            return(valiables);
        }
Пример #4
0
        internal IEnumerable <string> GetProperiesOfTypeByVariableName(string variableName, FuncGloalObject currentScope)
        {
            if (!currentScope.VariableTypesMapper.ContainsKey(variableName))
            {
                return(new string[0]);
            }

            var type = currentScope.VariableTypesMapper[variableName];

            if (global.TryGetValue(type, out var obj))
            {
                //obj.Analyze();
                return(obj.Properties.Keys.Union(obj.Methods));
            }

            return(new string[0]);
        }