ANTAREX API

Clava API

LARA API

LARA Common Language API

ClavaJoinPoints

ClavaJoinPoints

ClavaJoinPoints

Utility methods related with the creation of new join points.


Static Members

accessSpecifier

accessSpecifier(accessSpecifier)

Creates an access specifier (e.g., public:), for classes.

Parameters

accessSpecifier: String - one of public, protected, private or none.

assign

assign($leftHand, $rightHand)

Parameters

$leftHand: unknown
$rightHand: unknown

binaryOp

binaryOp(op, $left, $right, $type)

Creates a new join point 'binaryOp'.

Parameters

op: String - The binary operator kind.
$left: String|$expr - The left hand of the binary operator. If a string, it is converted to a literal expression.
$right: String|$expr - The right hand of the binary operator. If a string, it is converted to a literal expression.
$type: String|$expr - The return type of the operator. If a string, it is converted to a literal type. If undefined, uses int type.

builtinType

builtinType(code)

Parameters

code: unknown

cStyleCast

cStyleCast($type, $expr)

Represents an explicit C-style cast (e.g., (double) a).

Parameters

$type: type
$expr: expr

Returns

cast

call

call($function, arguments)

Creates a new join point 'call'.

Parameters

$function: $function - The function for which the call will refer to.
arguments: ...$expression - The arguments of the function.

callFromName

callFromName(functionName, $returnType, arguments)

Creates a new join point 'call'.

Parameters

functionName: string - The name of the function to call.
$returnType: $type - The return type of the function.
arguments: ...$expression - The arguments of the function.

classDecl

classDecl(className, [fields = []])

Creates an empty class with the given name and fields.

Parameters

className: String
fields: ...$field (optional)

Returns

class

comment

comment(text)

Creates a comment join point from the given text. If text has one line, creates an inline comment, otherwise creates a multi-line comment.

Parameters

text: string - The text of the comment

Returns

@comment

compoundAssign

compoundAssign($op, $leftHand, $rightHand)

Parameters

$op: unknown
$leftHand: unknown
$rightHand: unknown

constArrayType

constArrayType(type, dims)

Builds an array type of constant dimensions.

type - Mandatory. Represents the inner type of the array. Can be either a string or a Type join point. A string will be converted to a literal type.
dims - Mandatory. Represents the dimensions of the array. Can be either a JavaScript array or variadic integers which are converted to a JavaScript array.

Parameters

type: unknown
dims: unknown

create

create(node)

This function is deprecated. use JoinPoints.getInstance().toJoinPoint(node)

Parameters

node: J#ClavaNode - A node of the AST.

cxxConstructExpr

cxxConstructExpr(type, constructorArguments)

Parameters

type: Type - The type of the constructed object
constructorArguments: ...string|joinpoint - Arguments passed to the constructor function

Returns

any

declLiteral

declLiteral(declString)

Creates a new literal join point 'decl'.

Parameters

declString: string - The literal code of the decl.

declStmt

declStmt([decls = []])

Creates an empty class with the given name and fields.

Parameters

decls: ...$decl (optional)

Returns

class

doubleLiteral

doubleLiteral(doubleLiteral)

Parameters

doubleLiteral: String|number - The number that will be a double literal.

emptyStmt

emptyStmt()

equals

equals(jp1, jp2)

Parameters

jp1: unknown
jp2: unknown

Returns

any - true, if the two join points are equal, in the sense that the underlying AST nodes are also equal, according to their .equals() method (might return true for different AST nodes).

exprLiteral

exprLiteral(code, type)

Parameters

code: unknown
type: unknown

exprStmt

exprStmt($expr)

Parameters

$expr: $expr

Returns

@exprStmt

field

field(fieldName, fieldType)

Creates a field for a class.

Parameters

fieldName: String
fieldType: $type

Returns

$field

file

file(filename, [path = ""])

Creates a new join point 'file'.

Parameters

filename: string|J#java.io.File - Name of the source file. If filename represents a path to an already existing file, literally adds the contents of the file to the join point.
path: string - The path of the new file, relative to the output folder. Absolute paths are not allowed. This path will be required when including the file (e.g., #include "/") (optional)

fileWithSource

fileWithSource(filename, source, [path = ""])

Parameters

filename: String - Name of the source file.
source: String - The contents of the source file.
path: String - The path of the new file, relative to the output folder. Absolute paths are not allowed. This path will be required when including the file (e.g., #include "/") (optional)

forStmt

forStmt([$init = undefined], [$condition = undefined], [$inc = undefined], [$body = undefined])

Creates a new join point 'if'.

Parameters

$init: String|$statement - The initialization of the for statement. If a string, it is converted to a literal expression. (optional)
$condition: String|$statement - The condition of the for statement. If a string, it is converted to a literal expression. (optional)
$inc: String|$statement - The increment of the for statement. If a string, it is converted to a literal expression. (optional)
$body: String|$statement - The body of the for statement. (optional)

functionDecl

functionDecl(functionName, $returnType, params)

Creates a new join point 'function'.
TODO update docs

Parameters

functionName: String - The name of the function.
$returnType: $returnType - The return type of the function
params: ...$Decl - The parameters of the function.

functionDeclFromType

functionDeclFromType(functionName, $functionType)

Creates a new join point 'function'.

Parameters

functionName: String - The name of the function.
$functionType: $functionType - The type of the function.

functionType

functionType($returnType, argTypes)

Creates a new join point 'functionType'.

Parameters

$returnType: $type - The return type of the function type.
argTypes: ...$type - The types of the arguments of the function type.

gotoStmt(labelDecl)

Parameters

labelDecl: unknown

ifStmt

ifStmt($condition, [$then = undefined], [$else = undefined])

Creates a new join point 'if'.

Parameters

$condition: String|$expr - The condition of the if statement. If a string, it is converted to a literal expression.
$then: $statement - The body of the if (optional)
$else: $statement - The body of the else (optional)

integerLiteral

integerLiteral(integerLiteral)

Parameters

integerLiteral: String|number - The number that will be a integer literal.

labelDecl

labelDecl(name)

Parameters

name: unknown

labelStmt

labelStmt(nameOrDecl)

Parameters

nameOrDecl: unknown

omp

omp(directiveName)

Parameters

directiveName: unknown

param

param(name, $type)

Parameters

name: string
$type: $type

parenthesis

parenthesis($expr)

Creates a new join point 'expr' representing a parenthesis expression.

Parameters

$expr: String|$expr - The expression inside the parenthesis. If a string, it is converted to a literal expression.

pointer

pointer($type)

Parameters

$type: unknown

pointerFromBuiltin

pointerFromBuiltin(code)

Parameters

code: unknown

returnStmt

returnStmt($expr)

Parameters

$expr: [$expr] - An expression to return.

scope

scope()

stmtLiteral

stmtLiteral(stmtString)

Creates a new literal join point 'stmt'.

Parameters

stmtString: string - The literal code of the statement.

structType

structType($struct)

Parameters

$struct: struct - a struct for the type

Returns

elaboratedType - an elaborated type for the given struct.

switchStmt

switchStmt($function, cases)

Creates a new join point 'switch'

Parameters

$function: $function - The literal code of the statement.
cases: ...$expression - An even number of expression join points, each pair representing the case value and expression, respectively.

ternaryOp

ternaryOp($cond, $trueExpr, $falseExpr, $type)

Creates a new join point 'ternaryOp'

Parameters

$cond: $expr|string - The condition of the operator
$trueExpr: $expr|string - The result when $cond evaluates to true
$falseExpr: $expr|string - The result when $cond evaluates to false
$type: $type|string - The type of the operation

Returns

$ternaryOp - The newly created join point

type

type(source)

Tries to convert the given source into a join point, or throws an exception if it is not possible.

If source is a string:
- If it can be converted to a builtinType, returns a builtinType;
- Otherwise, returns a typeLiteral;

If source is a join point:
- If is a $type, returns itself;
- If the property .type is not undefined, returns .type;
- Otherwise, throws an exception;

Parameters

source: string|$jp

Returns

$type

typeLiteral

typeLiteral(typeString)

Creates a new literal join point 'type'.

Parameters

typeString: string - The literal code of the type

typedefDecl

typedefDecl($underlyingType, identifier)

Parameters

$underlyingType: $type - The underlying type of the typedef.
identifier: String - The name of the typedef.

typedefType

typedefType($typedefDecl)

Parameters

$typedefDecl: $typedefDecl - A typedef declaration.

unaryOp

unaryOp(op, $expr, [$type])

Creates a new join point 'unaryOp'.

Parameters

op: String - The unary operator kind.
$expr: String|$expr - The sub-expression of the unary operator. If a string, it is converted to a literal expression.
$type: String|$expr - The return type of the operator. If a string, it is converted to a literal type. If undefined, tries to infer the correct type based on the type of the $expr (inference might not be implemented for all operators). (optional)

varDecl

varDecl(varName, init)

Parameters

varName: string
init: joinpoint

varDeclNoInit

varDeclNoInit(varName, type)

Parameters

varName: string
type: Type

varRef

varRef(decl, $type)

Parameters

decl: String|$vardecl - The name of the varref.
$type: $type - The type of the varref (only used of decl is a string).

varRefFromDecl

varRefFromDecl(declName)

This function is deprecated. use ClavaJoinPoints.varRef() instead

Parameters

declName: $vardecl - The name of the varref.

variableArrayType

variableArrayType($type, $sizeExpr)

Parameters

$type: unknown
$sizeExpr: unknown

whileStmt

whileStmt($condition, $body)

Parameters

$condition: unknown
$body: unknown