Exemple #1
0
 public DiagnosticResult Bind(ScriptObjectType type, ScriptNode node)
 {
     return(DiagnosticResult.TryWithDiagnostics((diagnostics) =>
     {
         var visitor = new ScopeBindingVisitor(diagnostics, type);
         visitor.Visit(node);
     }));
 }
Exemple #2
0
 public DiagnosticResult <ScriptSymbol> Bind(ScriptNode node)
 {
     return(DiagnosticResult <ScriptSymbol> .TryWithDiagnostics((diagnostics) =>
     {
         var visitor = new SymbolBindingVisitor(diagnostics);
         return (ScriptSymbol)visitor.Visit(node, null);
     }));
 }
Exemple #3
0
        public DiagnosticResult <ScriptNode> Bind(ScriptFile file, PapyrusProgram program, IReadOnlyScriptText text, ITokenStream tokenStream, CommonTree objectNode)
        {
            return(DiagnosticResult <ScriptNode> .TryWithDiagnostics((diagnostics) =>
            {
                _text = text;
                _tokenStream = tokenStream;
                _diagnostics = diagnostics;

                _scriptNode = new ScriptNode
                {
                    File = file,
                    Program = program
                };
                _scriptNode.Script = _scriptNode;
                _scriptNode.CompilerNode = objectNode;
                _scriptNode.Range = objectNode.GetRange(tokenStream, text);
                _scriptNode.Text = text.Text;

                var children = new Scanner <CommonTree>(objectNode.GetChildren());
                children.Next();

                _scriptNode.Header = BindScriptHeader(_scriptNode, children);

                foreach (var child in children.AllRemaining())
                {
                    var blockChildren = new Scanner <CommonTree>(new CommonTree[] { child });
                    blockChildren.Next();

                    var definition = BindDefinition(_scriptNode, blockChildren);
                    if (definition != null)
                    {
                        lock (_definitionsLock)
                        {
                            _scriptNode.Definitions.Add(definition);
                        }
                    }
                }

                return _scriptNode;
            }));
        }