示例#1
0
 public BoundProgram(ImmutableArray <VariableSymbol> globalVariables, FunctionSymbol?globalFunction, FunctionSymbol?mainFunction, ImmutableDictionary <FunctionSymbol, BoundBlockStatement> functions, AssemblyDefinition mainAssembly, ImmutableArray <AssemblyDefinition> referencAssemblies, ImmutableDictionary <TypeSymbol, TypeReference> resolvedTypes, DiagnosticReport diagnostics, bool isValid) : base(isValid)
 {
     GlobalVariables    = globalVariables;
     GlobalFunction     = globalFunction;
     MainFunction       = mainFunction;
     Functions          = functions;
     MainAssembly       = mainAssembly;
     ReferencAssemblies = referencAssemblies;
     ResolvedTypes      = resolvedTypes;
     Diagnostics        = diagnostics;
 }
示例#2
0
 public BoundProgram(
     ImmutableArray <Diagnostic> diagnostics,
     FunctionSymbol?mainFunction,
     FunctionSymbol?scriptFunction,
     ImmutableDictionary <FunctionSymbol, LoweredFunction> functions)
 {
     Diagnostics    = diagnostics;
     MainFunction   = mainFunction;
     ScriptFunction = scriptFunction;
     Functions      = functions;
 }
示例#3
0
 public BoundProgram(BoundProgram?previous,
                     ImmutableArray <Diagnostic> diagnostics,
                     FunctionSymbol?mainFunction,
                     FunctionSymbol?scriptFunction,
                     ImmutableDictionary <FunctionSymbol, BoundBlockStatement> functions)
 {
     Previous       = previous;
     Diagnostics    = diagnostics;
     MainFunction   = mainFunction;
     ScriptFunction = scriptFunction;
     Functions      = functions;
 }
示例#4
0
 public BoundProgram(BoundProgram?previous,
                     FunctionSymbol?mainFunction,
                     FunctionSymbol?evalFunction,
                     ImmutableArray <Diagnostic> diagnostics,
                     ImmutableDictionary <DeclaredFunctionSymbol, BoundBlockStatement> functions)
 {
     this.Previous     = previous;
     this.MainFunction = mainFunction;
     this.EvalFunction = evalFunction;
     this.Diagnostics  = diagnostics;
     this.Functions    = functions;
 }
示例#5
0
 internal FunctionSymbol(string name,
                         ImmutableArray <ParameterSymbol> parameters,
                         TypeSymbol returnType,
                         FunctionDeclarationSyntax?declaration = null,
                         FunctionSymbol?overloadFor            = null,
                         ClassSymbol?receiver = null)
     : base(name)
 {
     Parameters  = parameters;
     ReturnType  = returnType;
     Declaration = declaration;
     OverloadFor = overloadFor;
     Receiver    = receiver;
 }
示例#6
0
 public BoundProgram(BoundProgram?previous,
                     ImmutableArray <Diagnostic> diagnostics,
                     FunctionSymbol?mainFunction,
                     FunctionSymbol?scriptFunction,
                     ImmutableDictionary <FunctionSymbol, BoundBlockStatement> functions)
 {
     Previous           = previous;
     Diagnostics        = diagnostics;
     MainFunction       = mainFunction;
     ScriptFunction     = scriptFunction;
     Functions          = functions;
     ErrorDiagnostics   = Diagnostics.Where(d => d.IsError).ToImmutableArray();
     WarningDiagnostics = Diagnostics.Where(d => d.IsWarning).ToImmutableArray();
 }
示例#7
0
 public BoundGlobalScope(BoundGlobalScope?previous,
                         ImmutableArray <Diagnostic> diagnostics,
                         FunctionSymbol?mainFunction,
                         FunctionSymbol?scriptFunction,
                         ImmutableArray <FunctionSymbol> functions,
                         ImmutableArray <VariableSymbol> variables,
                         ImmutableArray <BoundStatement> statements)
 {
     Previous       = previous;
     Diagnostics    = diagnostics;
     MainFunction   = mainFunction;
     ScriptFunction = scriptFunction;
     Functions      = functions;
     Variables      = variables;
     Statements     = statements;
 }
示例#8
0
        public LookupResult LookupFunction(Spanned <string> identifier)
        {
            string          name            = identifier.Value;
            BuiltInFunction?builtInFunction = WellKnownSymbols.LookupBuiltInFunction(name);

            if (builtInFunction.HasValue)
            {
                return(new LookupResult(builtInFunction.Value));
            }

            FunctionSymbol?function = _module.LookupFunction(name);

            if (function is not null)
            {
                return(new LookupResult(function));
            }

            ReportUnresolvedIdentifier(identifier);
            return(LookupResult.Empty);
        }
示例#9
0
        public FunctionSymbol?LookupFunction(string name)
        {
            FunctionSymbol?function = RootSourceFile.LookupFunction(name);

            if (function is not null)
            {
                return(function);
            }

            foreach (SourceFileSymbol file in ReferencedSourceFiles)
            {
                function = file.LookupFunction(name);
                if (function is not null)
                {
                    break;
                }
            }

            return(function);
        }
示例#10
0
        private static async Task ValidateOffset(ILanguageClient client, DocumentUri uri, BicepFile bicepFile, int offset, FunctionSymbol?symbol, bool expectDecorator)
        {
            var position = PositionHelper.GetPosition(bicepFile.LineStarts, offset);
            var initial  = await RequestSignatureHelp(client, position, uri);

            // fancy method to give us some annotated source code to look at if any assertions fail :)
            using (new AssertionScope().WithVisualCursor(bicepFile, new TextSpan(offset, 0)))
            {
                if (symbol is not null)
                {
                    // real function should have valid signature help
                    AssertValidSignatureHelp(initial, symbol, expectDecorator);

                    if (initial !.Signatures.Count() >= 2)
                    {
                        // update index to 1 to mock user changing active signature
                        const int ExpectedActiveSignatureIndex = 1;
                        var       modified = initial with
                        {
                            ActiveSignature = ExpectedActiveSignatureIndex
                        };

                        var shouldRemember = await RequestSignatureHelp(client, position, uri, new SignatureHelpContext
                        {
                            ActiveSignatureHelp = modified,
                            IsRetrigger         = true,
                            TriggerKind         = SignatureHelpTriggerKind.ContentChange
                        });

                        // we passed the same signature help as content with a different active index
                        // should get the same index back
                        AssertValidSignatureHelp(shouldRemember, symbol, expectDecorator);
                        shouldRemember !.ActiveSignature.Should().Be(ExpectedActiveSignatureIndex);
                    }
                }
                else
                {
                    // not a real function - no signature help expected
                    initial.Should().BeNull();
                }
            }
        }
示例#11
0
        private static async Task ValidateOffset(ILanguageClient client, DocumentUri uri, SyntaxTree tree, int offset, FunctionSymbol?symbol, bool expectDecorator)
        {
            var position = PositionHelper.GetPosition(tree.LineStarts, offset);
            var initial  = await RequestSignatureHelp(client, position, uri);

            if (symbol != null)
            {
                // real function should have valid signature help
                AssertValidSignatureHelp(initial, symbol, expectDecorator);

                if (initial !.Signatures.Count() >= 2)
                {
                    // update index to 1 to mock user changing active signature
                    initial.ActiveSignature = 1;

                    var shouldRemember = await RequestSignatureHelp(client, position, uri, new SignatureHelpContext
                    {
                        ActiveSignatureHelp = initial,
                        IsRetrigger         = true,
                        TriggerKind         = SignatureHelpTriggerKind.ContentChange
                    });

                    // we passed the same signature help as content with a different active index
                    // should get the same index back
                    AssertValidSignatureHelp(shouldRemember, symbol, expectDecorator);
                    shouldRemember !.ActiveSignature.Should().Be(1);
                }
            }
            else
            {
                // not a real function - no signature help expected
                initial.Should().BeNull();
            }
        }
示例#12
0
 public bool Equals(FunctionSymbol?other) => ReferenceEquals(Declaration, other?.Declaration);