示例#1
0
 private bool IsSingleIfStatement(List<AbsynStatement> stms, out AbsynIf elseIf)
 {
     elseIf = null;
     if (stms.Count != 1)
         return false;
     elseIf = stms[0] as AbsynIf;
     return elseIf != null;
 }
示例#2
0
		private void WriteIf(AbsynIf ifs)
		{
			writer.WriteKeyword("if");
            writer.Write(" (");
			WriteExpression(ifs.Condition);
			writer.Write(")");
			writer.Terminate();

			WriteIndentedStatements(ifs.Then, false);

			if (ifs.Else != null && ifs.Else.Count > 0)
			{
				writer.Indent();
				writer.WriteKeyword("else");
                AbsynIf elseIf;
                if (IsSingleIfStatement(ifs.Else, out elseIf))
				{
					writer.Write(" ");
					WriteIf(elseIf);
				}
				else
				{
					writer.Terminate();
					WriteIndentedStatements(ifs.Else, false);
				}
			}
		}
示例#3
0
 public void VisitIf(AbsynIf ifStm)
 {
     stms.Add(ifStm);
 }
示例#4
0
		public void VisitIf(AbsynIf ifs)
		{
			writer.Indent();
			WriteIf(ifs);
		}
示例#5
0
        private AbsynIf EmitIfCondition(Expression exp, Conditional cond, AbsynStatementEmitter emitter)
        {
            if (cond is IfElse || cond is IfThenElse)
            {
                exp = exp.Invert();
            }
            AbsynIf ifStm = new AbsynIf();
            ifStm.Condition = exp;
            emitter.EmitStatement(ifStm);

            return ifStm;
        }