Esempio n. 1
0
 public void RenameInTree(ParseNode parent)
 {
     var astVisitor = new AstTokenVisitor(parent, TokenKind.Identifier)
     {
         CallOnMatch = OnIdentifier
     };
     astVisitor.Visit();
 }
Esempio n. 2
0
 static void EvaluateFunctionReturn(ParseNode functionNode)
 {
     var astVisitor = new AstTokenVisitor(functionNode, TokenKind.Identifier)
     {
         CallOnMatch = SearchFunctionCall
     };
     astVisitor.Visit();
 }
Esempio n. 3
0
 public override void Perform(ParseNode node)
 {
     var sharpDefineVisitor = new AstTokenVisitor(node, _tokenKind)
         {
             CallOnMatch = FixLogic
         };
     sharpDefineVisitor.Visit();
 }
Esempio n. 4
0
 public void Perform()
 {
     _declarations = _functionBody.GetDeclarations();
     var visitor = new AstTokenVisitor(_functionBody, TokenKind.OpenParen)
         {
             CallOnMatch = FixLogic
         };
     visitor.Visit();
 }
Esempio n. 5
0
 static void EvaluateFunctionReturn(ParseNode functionNode)
 {
     var declarations = functionNode.GetDeclarations();
     var astVisitor = new AstTokenVisitor(functionNode, TokenKind.Identifier)
     {
         CallOnMatch = node => SearchFunctionCall(node, declarations)
     };
     astVisitor.Visit();
 }
        public void Perform()
        {
            _variableTypes = _functionBody.GetDeclarations();

            var visitorAssigns = new AstTokenVisitor(_functionBody, TokenKind.Assign)
                {
                    CallOnMatch = EvaluateAssign
                };
            visitorAssigns.Visit();
        }
 void FixDeclarationsNotInFunctionBody(ParseNode functionNode)
 {
     var functionBodyPosition = functionNode.Children.GetNextOfRule(RuleKind.BlockCode);
     var functionBody = functionNode.Children[functionBodyPosition];
     var astVisitor = new AstTokenVisitor(functionBody, TokenKind.TypeName)
     {
         CallOnMatch = node => EvaluateConflict(node, functionBody)
     };
     astVisitor.Visit();
 }
Esempio n. 8
0
 static void ResolveConflictsInFunction(ParseNode functionNode)
 {
     var functionBodyPosition = functionNode.Children.GetNextOfRule(RuleKind.BlockCode);
     var functionBody = functionNode.Children[functionBodyPosition];
     var astVisitor = new AstTokenVisitor(functionBody, TokenKind.Identifier)
     {
         CallOnMatch = RenameConflict
     };
     astVisitor.Visit();
 }
Esempio n. 9
0
 public override void Visit(List<ParseNode> astNodes)
 {
     foreach (var astNode in astNodes)
     {
         var visitor = new AstTokenVisitor(astNode, _tokenKind)
             {
                 CallOnMatch = OnVisitMatch
             };
         visitor.Visit();
     }
 }
Esempio n. 10
0
 public static Dictionary<string, TypeData> GetDeclarations(this ParseNode functionBody)
 {
     var variableTypes = new Dictionary<string, TypeData>();
     var visitorDeclarations = new AstTokenVisitor(functionBody, TokenKind.TypeName)
         {
             CallOnMatch = node => EvaluateDeclaration(node, variableTypes)
         };
     visitorDeclarations.Visit();
     ExtractParameterData(functionBody.Parent.States[2], variableTypes);
     return variableTypes;
 }
 void EvaluateFunctionReturn(ParseNode functionNode)
 {
     var parentFunctionDeclaration = functionNode.Parent.States;
     if (parentFunctionDeclaration[0].Token != TokenKind.TypeName)
         return;
     var functionTypeName = parentFunctionDeclaration[0].Content;
     if (functionTypeName != "void")
         return;
     var astVisitor = new AstTokenVisitor(functionNode, TokenKind.Return)
     {
         CallOnMatch = HandleOnReturn
     };
     astVisitor.Visit();
 }
        static void RenameConflictsInFunction(ParseNode functionNode, Dictionary<string, string> renameTable)
        {
            var functionBodyPosition = functionNode.Children.GetNextOfRule(RuleKind.BlockCode);
            var functionBody = functionNode.Children[functionBodyPosition];
            var astVisitor = new AstTokenVisitor(functionBody, TokenKind.Identifier)
            {
                CallOnMatch = node => RenameConflict(node, renameTable)
            };
            astVisitor.Visit();

            var functionName = GetFunctionName(functionNode);
            if (!renameTable.ContainsKey(functionName))
                return;
            var functionNameNode = functionNode.Children.First(it => it.GetTokenKind() == TokenKind.Identifier);
            var functionNameTokenData = functionNameNode.GetTokenData();
            functionNameTokenData.Content = renameTable[functionName];
        }
 static void EvaluateConflictsInFunction(ParseNode functionNode, Dictionary<string, bool> functionsWithConflicts)
 {
     var functionBodyPosition = functionNode.Children.GetNextOfRule(RuleKind.BlockCode);
     var functionBody = functionNode.Children[functionBodyPosition];
     var astVisitor = new AstTokenVisitor(functionBody, TokenKind.Identifier)
     {
         CallOnMatch = node => EvaluateConflict(node, functionsWithConflicts)
     };
     astVisitor.Visit();
 }