DartBlockProgram class
The full DartBlock program, containing both its default main function (entry point) and any additional custom functions defined by the user.
- Annotations
-
- @JsonSerializable.new(explicitToJson: true)
Constructors
-
DartBlockProgram(DartBlockTypedLanguage mainLanguage, DartBlockFunction mainFunction, List<
DartBlockFunction> customFunctions, int version) - Helper constructor, used internally for serialization. Do not use this constructor, instead opt for the .init() named constructor.
- DartBlockProgram.example()
- An example DartBlock program, available as an additional constructor.
-
DartBlockProgram.fromJson(Map<
String, dynamic> json) -
factory
-
DartBlockProgram.init(List<
Statement> statements, List<DartBlockFunction> customFunctions, {DartBlockTypedLanguage mainLanguage = DartBlockTypedLanguage.java}) - The main constructor.
Properties
-
customFunctions
→ List<
DartBlockFunction> -
Any additional custom functions defined in addition to the default main function.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- mainFunction → DartBlockFunction
-
The entry point of a DartBlock program.
final
- mainLanguage → DartBlockTypedLanguage
-
The typed language associated with the DartBlock program.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- version → int
-
The version of DartBlock which was used to build this DartBlock program.
final
Methods
-
addStatementToMain(
Statement statement) → void - Add a statement to the main function.
-
buildTree(
) → DartBlockProgramTreeNode - Build a tree-based representation of the DartBlock program.
-
copy(
) → DartBlockProgram -
getHints(
) → List< String> - Generate a list of hints for the DartBlock program.
-
getMaxDepth(
) → int? - Retrieve the maximum depth of the DartBlock program across its main and custom functions, if the program is not empty.
-
getStatementTypeUsageCount(
) → Map< StatementType, int> - Count the usage of each statement type across the main function and custom functions.
-
isEmpty(
) → bool - Whether the main function and any potential custom functions are all empty, i.e., they do not contain any statements.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
shuffle(
{bool deep = false}) → DartBlockProgram - Randomly re-order the statements in the main function, as well as the custom functions.
-
toJson(
) → Map< String, dynamic> -
toScript(
{DartBlockTypedLanguage language = DartBlockTypedLanguage.java}) → String - Export the DartBlock program to a typed language.
-
toString(
) → String -
A string representation of this object.
inherited
-
trim(
{required double trimPercentage, bool trimMainFunction = true, bool trimCustomFunctions = true}) → DartBlockProgram - Shorten the DartBlock program based on the given percentage value, by starting from the end of the program!
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override