uk.co.badgersinfoil.metaas
Interface StatementContainer

All Known Subinterfaces:
ASIfStatement, ASMethod

public interface StatementContainer

Defines the common services provided by structures which can contain ActionScript 'statements'.


Method Summary
 void addComment(java.lang.String text)
          Adds a single-line comment to list of statements being generated
 void addStmt(java.lang.String statement)
          Checks the syntax of the given code, and then adds the statement to the end of the current block.
 StatementContainer newDoWhile(java.lang.String condition)
          Adds a do-while-loop to the code.
 StatementContainer newFor(java.lang.String init, java.lang.String condition, java.lang.String update)
          Adds a C-style for-loop to the code.
 StatementContainer newForIn(java.lang.String init, java.lang.String list)
          Adds a for-in-loop to the code.
 ASIfStatement newIf(java.lang.String condition)
          Adds an if-statement to the code.
 ASSwitchStatement newSwitch(java.lang.String condition)
          Adds a switch-statement to the code.
 StatementContainer newWhile(java.lang.String condition)
          Adds a while-loop to the code.
 

Method Detail

addStmt

public void addStmt(java.lang.String statement)
Checks the syntax of the given code, and then adds the statement to the end of the current block.

Throws:
SyntaxException - if the syntax of the given code fragment is incorrect.

addComment

public void addComment(java.lang.String text)
Adds a single-line comment to list of statements being generated

Parameters:
text - the text of the comment (minus the initial '//') which must not include any newline characters.

newIf

public ASIfStatement newIf(java.lang.String condition)
Adds an if-statement to the code. e.g.
block.newIf("test()").addStmt("trace('success')")
results in
 if (test()) {
 	trace('success');
 }


newFor

public StatementContainer newFor(java.lang.String init,
                                 java.lang.String condition,
                                 java.lang.String update)
Adds a C-style for-loop to the code. e.g.
block.newFor("var i=0", "i<10", "i++").addStmt("trace(i)")
results in
 for (var i=0; i<10; i++) {
 	trace(i);
 }


newForIn

public StatementContainer newForIn(java.lang.String init,
                                   java.lang.String list)
Adds a for-in-loop to the code. e.g.
block.newForIn("var i", "myArray").addStmt("trace(i)")
results in
 for (var i in myArray) {
 	trace(i);
 }


newWhile

public StatementContainer newWhile(java.lang.String condition)
Adds a while-loop to the code. e.g.
block.newWhile("test()").addStmt("trace('hi there')")
results in
 while (test()) {
 	trace('hi there');
 }


newDoWhile

public StatementContainer newDoWhile(java.lang.String condition)
Adds a do-while-loop to the code. e.g.
block.newDoWhile("test()").addStmt("trace('hi there')")
results in
 do {
 	trace('hi there');
 } while (test());


newSwitch

public ASSwitchStatement newSwitch(java.lang.String condition)
Adds a switch-statement to the code. See ASSwitchStatement for more information.