Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "transpiler/transforms"

Index

Type aliases

FunctionLike

FunctionLike: MethodDeclaration | FunctionDeclaration

a FunctionLike is a method OR function - both are possible canidates for generating a generator

Variables

Const DEFAULT_TRANSFORM_CONFIG

DEFAULT_TRANSFORM_CONFIG: Readonly<TransformConfig> = Object.freeze({forLoops: {transform: true,beforeLoop: true,onlyBeforeTopLevelLoops: true,insideLoop: true},whileLoops: {transform: true},doLoops: {transform: true // no in use},callStatements: {insertYieldBeforeCall: true},ifStatements: {beforeIfStatements: false}})

defaults for the transformation config objects

Const RTJS_BUDGET_IDENTIFIER

RTJS_BUDGET_IDENTIFIER: "RTJS_BUDGET" = "RTJS_BUDGET"

name for the global budget variable

Const RTJS_DECORATOR

RTJS_DECORATOR: "rtjs" = "rtjs"

decorator name for generating generators

Const RTJS_MODULE_NAME

RTJS_MODULE_NAME: "rtjs" = "rtjs"

Let rtjsMethods

rtjsMethods: number[] = []

Functions

asRTJSFunctionLike

  • tries to find the decorator RTJS_DECORATOR for the given node, if found: add node to RTJS-function list

    Parameters

    Returns FunctionLike | undefined

    node if the decorator was found, nothing if not

createBudgetedYieldStatement

  • createBudgetedYieldStatement(): IfStatement
  • returns a budgeted version of the yield statement

    Returns IfStatement

    if ( --this.rtjs.RTJS_BUDGET < 0 ) { yield this.Schedulermessage.Continue }

createRTJSBudget

  • createRTJSBudget(): Expression

createReturnStatement

  • createReturnStatement(): Statement
  • returns a single return statement with Scheduler::TerminateTask message; indicates, that the task is finished

    Returns Statement

    ast objects for return SchedulerMessage.TerminteTask

createTaskSpawn

  • createTaskSpawn(node: CallExpression): Node
  • creates an expression like yield this.rtjs.spawnTaskFromFn(node.bind(node, SIZE), this.name + "->" + node.name, this.priority)

    Parameters

    • node: CallExpression

    Returns Node

createYieldStatement

  • createYieldStatement(): Statement
  • returns a single yield statement with the message Scheduler::Continue

    Returns Statement

    ast objects for yield SchedulerMessage.Continue

ensureGeneratorFunction

getLeadingCommentForNode

  • getLeadingCommentForNode(node: Node): string | undefined
  • returns the comment string before the node

    Parameters

    • node: Node

      node for which to get the comment

    Returns string | undefined

    comment string

modifyBlock

modifyExpresionStatement

  • modifyExpresionStatement(config: TransformConfig, expressionStatement: ExpressionStatement): Statement[]
  • inserts a budgeted yield before function calls

    Parameters

    • config: TransformConfig

      configuration variable

    • expressionStatement: ExpressionStatement

      the statement to be altered

    Returns Statement[]

modifyFor

  • modifyFor(config: TransformConfig, forStatement: ForStatement): Statement[]
  • modifies for-loops according to the config variable

    Parameters

    • config: TransformConfig

      configuration variable

    • forStatement: ForStatement

      AST node identifying the for-loop-statement

    Returns Statement[]

    <for ( ..; ..; ..)> { }

modifyFunction

modifyIf

  • modify if statements according to the config variable

    Parameters

    • config: TransformConfig

      configuration variable

    • ifStatement: IfStatement

      the AST node identifying the if-statement

    Returns Statement[]

    <if (..)> {} [else {}]

modifyStatementList

  • modifyStatementList(config: TransformConfig, statements: NodeArray<Statement>, additional?: Statement[]): NodeArray<Statement>
  • modifies a list of statements

    Parameters

    • config: TransformConfig

      configuration variable

    • statements: NodeArray<Statement>

      the list of statements of the block

    • Default value additional: Statement[] = []

      list of statements to be concatted after the modification of statements

    Returns NodeArray<Statement>

    the new list of statements

modifyWhile

  • modifyWhile(config: TransformConfig, whileStatement: WhileStatement): Statement[]
  • modifies while-loops according to the config variable

    Parameters

    • config: TransformConfig

      configuration variable

    • whileStatement: WhileStatement

      AST node identifying the while-loop-statement

    Returns Statement[]

    <while ( ... )> { }

transform

  • starts the transformation, looks for RTJS_DECORATOR and starts transforming the decorated function-likes

    Parameters

    • Default value config: TransformConfig = DEFAULT_TRANSFORM_CONFIG

      configuration variable

    Returns (Anonymous function)

Generated using TypeDoc