Beispiel #1
0
		} // ExpressionStmt
	
	
	// Return an if/then or if/then/else statement.  If there was no else
	// clause, elseClause will be null.
	public StmtFrag IfThenElse( SrcLoc loc, ExprFrag condition,
								StmtFrag ifClause, StmtFrag elseClause )
		{
		CSharpStmtFrag frag = new CSharpStmtFrag(loc);
		
		CSharpExprFrag csCondition = (CSharpExprFrag)condition;
		frag.Append("if (Support.BoolTest(" + csCondition.GenerateRHS() + "))");
		frag.AppendIndentedBody(ifClause);
		
		if (elseClause != null)
			{
			frag.Append("else");
			frag.AppendIndentedBody(elseClause);
			}
		
		return frag;
		} // IfThenElse
Beispiel #2
0
		} // WhileDo
	
	
	// Return a for statement.  init is the loop initializer, cond is the
	// loop control expression, and step is the loop increment expression.
	// Any or all of init, cond, and step can be null.
	public StmtFrag For( LoopInfo loopInfo, StmtFrag init,
						 ExprFrag cond, ExprFrag step, StmtFrag body )
		{
		CSharpLoopInfo csLoopInfo = (CSharpLoopInfo)loopInfo;
		CSharpStmtFrag frag = new CSharpStmtFrag(csLoopInfo.loc);
		
		frag.Append(init);
		
		CSharpExprFrag csCondition = (CSharpExprFrag)cond;
		frag.Append("while (Support.BoolTest(" + csCondition.GenerateRHS() + "))");
		((CSharpStmtFrag)body).Append("continueTarget_{0}:", csLoopInfo.index + 1);
		((CSharpStmtFrag)body).Append(ExpressionStmt(step));
		frag.AppendIndentedBody(body);
		frag.Append("breakTarget_{0}: {1}", csLoopInfo.index + 1, "{}");
		
		return frag;
		} // For
Beispiel #3
0
		} // Switch
	
	
	// Return a try...catch, try...finally, or try...catch...finally
	// statement.  If there was no "catch" clause, then catchVar, catchWithInfo,
	// and catchBody will be null.  If there was no "finally" clause, then
	// finallyBody will be null.  These parameters can't all be null (i.e.
	// at least one of the "catch" and "finally" clauses must have been
	// present).
	public StmtFrag TryCatchFinally( SrcLoc loc,
									 StmtFrag tryBody, string catchVar,
									 WithInfo catchWithInfo,
									 StmtFrag catchBody,
									 StmtFrag finallyBody )
		{
		CSharpStmtFrag frag = new CSharpStmtFrag(loc);
		
		frag.Append("try");
		frag.AppendIndentedBody(tryBody);
		
		if (catchBody != null)
			{
			CSharpWithInfo csWithInfo = (CSharpWithInfo)catchWithInfo;
			
			frag.Append("catch (Exception catchTemp_{0})", csWithInfo.index+1);
			frag.Indent();
			frag.Append("{");
			
			frag.Append( "JObject withTemp_{0} = Support.CreateCatchScope(catchTemp_{0}, \"{1}\");",
						 csWithInfo.index+1, catchVar );
			
			frag.Append(catchBody);
			
			frag.Append("}");
			frag.Outdent();
			}
		
		if (finallyBody != null)
			{
			frag.Append("finally");
			frag.AppendIndentedBody(finallyBody);
			}
		
		return frag;
		} // TryCatchFinally
Beispiel #4
0
		} // IfThenElse
	
	
	// Return a do...while statement.
	public StmtFrag DoWhile( LoopInfo loopInfo, StmtFrag body,
							 ExprFrag condition )
		{
		CSharpLoopInfo csLoopInfo = (CSharpLoopInfo)loopInfo;
		CSharpStmtFrag frag = new CSharpStmtFrag(csLoopInfo.loc);
		
		CSharpExprFrag csCondition = (CSharpExprFrag)condition;
		frag.Append("do");
		((CSharpStmtFrag)body).Append("continueTarget_{0}:", csLoopInfo.index + 1);
		frag.AppendIndentedBody(body);
		frag.Append("while (Support.BoolTest(" + csCondition.GenerateRHS() + "))");
		frag.Append("breakTarget_{0}: {1}", csLoopInfo.index + 1, "{}");
		
		return frag;
		} // DoWhile