Ejemplo n.º 1
0
        public void Visit(StatementUnit node)
        {
            node.Expression.Accept(this);

            DeclareNewVariable(node.Identifier, node.DataType);

            if (node.DataType.GetReturnType() != DetermineType(node.Expression))
            {
                Exceptions.Add(new TypeCheckerError(String.Format(
                "Expression inside the statement declared as {0}, but resolves into type {1} instead",
                node.DataType.GetReturnType(),
                DetermineType(node.Expression))));
            }
        }
Ejemplo n.º 2
0
        public void Visit(StatementUnit node)
        {
            ITerminalWrapper evaluatedResult = ReferenceTables.GetValueOrNull(node.Expression);
            node.Value = evaluatedResult;

            WidgetBase unitWrapper = _widgetFactory.GetWidget(node);
            unitWrapper.Visibility = _parentExpressionDidNotEvaluate ? Visibility.Collapsed : Visibility.Visible;

            int index = _elementsToDisplay.ToList().FindIndex(elem => elem.Unit.Identifier == unitWrapper.Unit.Identifier);
            if (index < 0)
            {
                _elementsToDisplay.Add(unitWrapper);
            }
            else
            {
                _elementsToDisplay[index].Visibility = unitWrapper.Visibility;
            }
        }
Ejemplo n.º 3
0
 public WidgetBase GetWidget(StatementUnit unit)
 {
     return new StatementWidget(unit);
 }
Ejemplo n.º 4
0
 public void Visit(StatementUnit node)
 {
     node.Expression.Accept(this);
     ReferenceTables.SetReference(node.Identifier, node.Expression);
 }
Ejemplo n.º 5
0
 public void Visit(StatementUnit node)
 {
     _unitsToAnswers.Add(node.Text, node.Value);
 }
Ejemplo n.º 6
0
        public override void ExitStatementUnit(QLParser.StatementUnitContext context)
        {
            IList<ElementBase> children = GetChildren();

            ThrowExceptionIfAny();
            if (children.Count() != 2)
            {
                _astBuilderExceptions.Add(new ParserError("A statement should have only expression and an identifier as children."));
            }

            StatementUnit statement = new StatementUnit(
                (Identifier)children[0],
                (Expression)children[1],
                context.TEXT().GetText(),
                _terminalTypeFactory.GetTypeInstance(context.type()),
                SourceLocation.CreateFor(context)
                );
            AppendToAST(statement);
        }