コード例 #1
0
        public Block BuildDocument(int indentation)
        {
            Paragraph p = new Paragraph();

            p.Inlines.Add(new Run("if")
            {
                Foreground = StyleSettings.KeyWordColor
            });
            p.Inlines.Add(" (");
            p.Inlines.AddRange(CheckExpression.BuildDocument());
            p.Inlines.Add(")");

            Section s = new Section()
            {
                Margin = new Thickness(indentation, 0, 0, 0)
            };

            s.Blocks.Add(p);
            s.Blocks.Add(IfTrueBody.BuildDocument(indentation));
            s.Blocks.Add(new Paragraph(new Run("else")
            {
                Foreground = StyleSettings.KeyWordColor
            }));
            s.Blocks.Add(IfFalseBody.BuildDocument(indentation));

            return(s);
        }
コード例 #2
0
        public void TypeCheck(ITypeEnvironment env)
        {
            if (!CheckExpression.TypeCheck(env).CompatibleWith(ExpressionType))
            {
                env.ReportError("Unable to evaluate 'if'. Expression must be of type bool!",
                                SourceStartPosition, SourceEndPosition);
            }

            IfTrueBody.TypeCheck(env);
        }
コード例 #3
0
        public override bool Equals(object obj)
        {
            if (!(obj is IfStmnt))
            {
                return(false);
            }

            IfStmnt other = (IfStmnt)obj;

            return(CheckExpression.Equals(other.CheckExpression) && IfTrueBody.Equals(other.IfTrueBody));
        }
コード例 #4
0
        public FrameworkElement BuildForm(IValueEnvironment vEnv, ITypeEnvironment tEnv)
        {
            ValueContainer value = CheckExpression.Evaluate(vEnv);

            StackPanel sp             = new StackPanel();
            Action     onValueChanged = () =>
            {
                sp.Visibility = Convert.ToBoolean(value.Value) ? Visibility.Visible : Visibility.Collapsed;
            };

            value.ValueChanged += onValueChanged;
            onValueChanged();

            sp.Children.Add(IfTrueBody.BuildForm(vEnv, tEnv));

            return(sp);
        }
コード例 #5
0
 public override int GetHashCode()
 {
     return(CheckExpression.GetHashCode() ^ IfTrueBody.GetHashCode() ^ IfFalseBody.GetHashCode());
 }