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); }
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); }
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)); }
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); }
public override int GetHashCode() { return(CheckExpression.GetHashCode() ^ IfTrueBody.GetHashCode() ^ IfFalseBody.GetHashCode()); }