Exemplo n.º 1
0
        public void Visit(EachStatement eachStatement, CommonTree tree)
        {
            Parent(tree).Children.Add(eachStatement);
            SetLine(eachStatement, tree);

            eachStatement.IterationVariable = new VariableDeclarationStatement()
            {
                Variable = tree.GetChild(0).Text
            };
            SetLine(eachStatement.IterationVariable, tree.GetChild(0));

            var rowGetter = new TableVariableRowGetter()
            {
                Id = tree.GetChild(1).Text
            };

            SetLine(rowGetter, tree.GetChild(1));
            eachStatement.IterationVariable.Children.Add(rowGetter);

            eachStatement.TableReference = new TableVariableReference()
            {
                Id = tree.GetChild(1).Text
            };
            SetLine(eachStatement.TableReference, tree.GetChild(1));

            Visit(tree.GetChild(2));
        }
        public void Visit(TableVariableRowGetter variable)
        {
            Visit((TableVariableReference)variable);
            ScopeData <TableDescriptor> scope = new ScopeData <TableDescriptor> {
                Type = new TableDescriptor(null), CodeDomReference = new CodeTypeReference("Table", new CodeTypeReference(variable.Id))
            };

            if (Scope.Current.IsTableRegistered(variable.Id))
            {
                scope = Scope.Current.GetTableDescriptor(variable.Id);
                if (scope.CodeDomReference.TypeArguments.Count > 0)
                {
                    scope = new ScopeData <TableDescriptor> {
                        Type = scope.Type, CodeDomReference = scope.CodeDomReference.TypeArguments[0]
                    }
                }
                ;
            }

            _codeStack.Peek().Scope = scope;
        }
    }