Statements - Testura/Testura.Code GitHub Wiki

Statements

A statement is the smallest standalone element of an imperative programming language that expresses some action to be carried out. Testura.Code provides a couple of different help classes to generate statements:

  • DeclerationStatement - Declare and assign varilables
  • IterationStatement - Loops
  • JumpStatement - Returns
  • SelectionStatement - If statement
  • ExpressionStatement - Invocation of methods

They can all be accessed through the static Statment-class.

Declare statements

Methods

  • Declare
  • Assign
  • DeclareAndAssign

Example

Usage

Statement.Decleration.DeclareAndAssign("testVariable", 1));

Result

var testVariable = 1;

Iteration statements

Methods

  • For (fixed)
  • For (references)

Example

Usage

Statement.Iteration.For(1, 2, "i", BodyGenerator.Create()

Result

for(inti = 1; i < 2; i++)
{
}

Jump statements

Methods

  • ReturnTrue
  • ReturnFalse
  • Return

Example

Usage

Statement.Jump.ReturnTrue();

Result

return true;

Selection statements

Methods

  • If

Example

Usage

Statement.Selection.If(new ValueArgument(2), new ValueArgument(3), ConditionalStatements.Equal, BodyGenerator.Create())

Result

if(2 == 3)
{
}

Selection statements

Expression statements

  • Invoke

Example

Usage

Statement.Expression.Invoke("myClass", "Do", new List<IArgument> { new ValueArgument(1) })

Result

myClass.Do(1);
⚠️ **GitHub.com Fallback** ⚠️