UNPKG

@specs-feup/clava

Version:

A C/C++ source-to-source compiler written in Typescript

1,175 lines (1,144 loc) 127 kB
/////////////////////////////////////////////////// // This file is generated by build-interfaces.js // /////////////////////////////////////////////////// /* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-unsafe-return */ /* eslint-disable @typescript-eslint/no-duplicate-type-constituents */ import { LaraJoinPoint, type JoinpointMapperType, registerJoinpointMapper, wrapJoinPoint, unwrapJoinPoint, } from "@specs-feup/lara/api/LaraJoinPoint.js"; type PrivateMapper = { "Joinpoint": typeof Joinpoint, "Attribute": typeof Attribute, "ClavaException": typeof ClavaException, "Comment": typeof Comment, "Decl": typeof Decl, "Empty": typeof Empty, "Expression": typeof Expression, "FileJp": typeof FileJp, "ImplicitValue": typeof ImplicitValue, "Include": typeof Include, "InitList": typeof InitList, "Literal": typeof Literal, "MemberAccess": typeof MemberAccess, "NamedDecl": typeof NamedDecl, "NewExpr": typeof NewExpr, "Op": typeof Op, "ParenExpr": typeof ParenExpr, "Pragma": typeof Pragma, "Program": typeof Program, "RecordJp": typeof RecordJp, "Statement": typeof Statement, "Struct": typeof Struct, "Switch": typeof Switch, "SwitchCase": typeof SwitchCase, "Tag": typeof Tag, "TernaryOp": typeof TernaryOp, "This": typeof This, "Type": typeof Type, "TypedefNameDecl": typeof TypedefNameDecl, "TypedefType": typeof TypedefType, "UnaryExprOrType": typeof UnaryExprOrType, "UnaryOp": typeof UnaryOp, "UndefinedType": typeof UndefinedType, "Varref": typeof Varref, "WrapperStmt": typeof WrapperStmt, "AccessSpecifier": typeof AccessSpecifier, "AdjustedType": typeof AdjustedType, "ArrayAccess": typeof ArrayAccess, "ArrayType": typeof ArrayType, "BinaryOp": typeof BinaryOp, "BoolLiteral": typeof BoolLiteral, "Break": typeof Break, "BuiltinType": typeof BuiltinType, "Call": typeof Call, "Case": typeof Case, "Cast": typeof Cast, "CilkSpawn": typeof CilkSpawn, "CilkSync": typeof CilkSync, "Class": typeof Class, "Continue": typeof Continue, "CudaKernelCall": typeof CudaKernelCall, "DeclStmt": typeof DeclStmt, "Declarator": typeof Declarator, "Default": typeof Default, "DeleteExpr": typeof DeleteExpr, "ElaboratedType": typeof ElaboratedType, "EmptyStmt": typeof EmptyStmt, "EnumDecl": typeof EnumDecl, "EnumeratorDecl": typeof EnumeratorDecl, "ExprStmt": typeof ExprStmt, "Field": typeof Field, "FloatLiteral": typeof FloatLiteral, "FunctionJp": typeof FunctionJp, "FunctionType": typeof FunctionType, "GotoStmt": typeof GotoStmt, "If": typeof If, "IncompleteArrayType": typeof IncompleteArrayType, "IntLiteral": typeof IntLiteral, "LabelDecl": typeof LabelDecl, "LabelStmt": typeof LabelStmt, "Loop": typeof Loop, "Marker": typeof Marker, "MemberCall": typeof MemberCall, "Method": typeof Method, "Omp": typeof Omp, "ParenType": typeof ParenType, "PointerType": typeof PointerType, "QualType": typeof QualType, "ReturnStmt": typeof ReturnStmt, "Scope": typeof Scope, "TagType": typeof TagType, "TemplateSpecializationType": typeof TemplateSpecializationType, "TypedefDecl": typeof TypedefDecl, "Vardecl": typeof Vardecl, "VariableArrayType": typeof VariableArrayType, "Body": typeof Body, "CilkFor": typeof CilkFor, "EnumType": typeof EnumType, "Param": typeof Param, }; type DefaultAttributeMap = { FileJp: "name", Include: "name", NamedDecl: "name", Pragma: "name", Program: "name", RecordJp: "name", Struct: "name", Tag: "id", TypedefNameDecl: "name", Varref: "name", AccessSpecifier: "kind", Call: "name", CilkSpawn: "name", Class: "name", CudaKernelCall: "name", Declarator: "name", EnumDecl: "name", EnumeratorDecl: "name", Field: "name", FunctionJp: "name", LabelDecl: "name", Loop: "kind", Marker: "id", MemberCall: "name", Method: "name", Omp: "kind", TypedefDecl: "name", Vardecl: "name", CilkFor: "kind", Param: "name", } export class Joinpoint extends LaraJoinPoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * String with a dump of the AST representation starting from this node. This representation corresponds to the internal Java representation of the ClavaAst, where the node names correspond to Java classes. To get an equivalent representation with join point names, use the attribute 'dump' */ get ast(): string { return wrapJoinPoint(this._javaObject.getAst()) } /** * Returns an array with the children of the node, considering null nodes */ get astChildren(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getAstChildren()) } /** * String that uniquely identifies this node */ get astId(): string { return wrapJoinPoint(this._javaObject.getAstId()) } /** * The name of the Java class of this node, which is similar to the equivalent node in Clang AST */ get astName(): string { return wrapJoinPoint(this._javaObject.getAstName()) } /** * Returns the number of children of the node, considering null nodes */ get astNumChildren(): number { return wrapJoinPoint(this._javaObject.getAstNumChildren()) } /** * The bit width of the type returned by this join point, in relation to the definitions of its Translation Unit, or undefined if there is no type or bitwidth defined, or if the join point is not in a TranslationUnit */ get bitWidth(): number { return wrapJoinPoint(this._javaObject.getBitWidth()) } /** * String list of the names of the join points that form a path from the root to this node */ get chain(): string[] { return wrapJoinPoint(this._javaObject.getChain()) } /** * Returns an array with the children of the node, ignoring null nodes */ get children(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getChildren()) } /** * String with the code represented by this node */ get code(): string { return wrapJoinPoint(this._javaObject.getCode()) } /** * The starting column of the current node in the original code */ get column(): number { return wrapJoinPoint(this._javaObject.getColumn()) } /** * Returns the node that declares the scope of this node */ get currentRegion(): Joinpoint { return wrapJoinPoint(this._javaObject.getCurrentRegion()) } /** * JS object associated with this node, containing parsed data of #pragma clava data when the node can be a target of pragmas. This is a special object, managed internally, and cannot be reassigned, to change its contents requires using key-value pairs. If the node can be the target of a pragma, the information stored in this object is persisted between rebuilds. */ get data(): any { const data = (this._javaObject.getData() as string | undefined); return data ? JSON.parse(data) : data; } /** * JS object associated with this node, containing parsed data of #pragma clava data when the node can be a target of pragmas. This is a special object, managed internally, and cannot be reassigned, to change its contents requires using key-value pairs. If the node can be the target of a pragma, the information stored in this object is persisted between rebuilds. */ set data(value: object) { this._javaObject.setData(JSON.stringify(value)); } /** * The depth of this join point in the AST. If it is the root join point returns 0, if it is a child of the root node returns 1, etc. */ get depth(): number { return wrapJoinPoint(this._javaObject.getDepth()) } /** * Retrieves all descendants of the join point */ get descendants(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getDescendants()) } /** * The ending column of the current node in the original code */ get endColumn(): number { return wrapJoinPoint(this._javaObject.getEndColumn()) } /** * The ending line of the current node in the original code */ get endLine(): number { return wrapJoinPoint(this._javaObject.getEndLine()) } /** * The name of the file where the code of this node is located, if available */ get filename(): string { return wrapJoinPoint(this._javaObject.getFilename()) } /** * The complete path to the file where the code of this node comes from */ get filepath(): string { return wrapJoinPoint(this._javaObject.getFilepath()) } /** * Returns the first child of this node, or undefined if it has no child */ get firstChild(): Joinpoint { return wrapJoinPoint(this._javaObject.getFirstChild()) } /** * Returns the first child of this node, or undefined if it has no child */ set firstChild(value: Joinpoint) { this._javaObject.setFirstChild(unwrapJoinPoint(value)); } /** * True if the node has children, false otherwise */ get hasChildren(): boolean { return wrapJoinPoint(this._javaObject.getHasChildren()) } /** * True if this node has a parent */ get hasParent(): boolean { return wrapJoinPoint(this._javaObject.getHasParent()) } /** * True, if the join point has a type */ get hasType(): boolean { return wrapJoinPoint(this._javaObject.getHasType()) } /** * Returns comments that are not explicitly in the AST, but embedded in other nodes */ get inlineComments(): Comment[] { return wrapJoinPoint(this._javaObject.getInlineComments()) } /** * Returns comments that are not explicitly in the AST, but embedded in other nodes */ set inlineComments(value: string[] | string) { this._javaObject.setInlineComments(unwrapJoinPoint(value)); } /** * True if this is a Cilk node (i.e., cilk_spawn, cilk_sync or cilk_for) */ get isCilk(): boolean { return wrapJoinPoint(this._javaObject.getIsCilk()) } /** * True, if the join point is part of a system header file */ get isInSystemHeader(): boolean { return wrapJoinPoint(this._javaObject.getIsInSystemHeader()) } /** * True, if the join point is inside a header (e.g., if condition, for, while) */ get isInsideHeader(): boolean { return wrapJoinPoint(this._javaObject.getIsInsideHeader()) } /** * True, if the join point is inside a loop header (e.g., for, while) */ get isInsideLoopHeader(): boolean { return wrapJoinPoint(this._javaObject.getIsInsideLoopHeader()) } /** * True if any descendant or the node itself was defined as a macro */ get isMacro(): boolean { return wrapJoinPoint(this._javaObject.getIsMacro()) } /** * The names of the Java fields of this node. Can be used as key of the attribute 'javaValue' * * @deprecated used attribute 'keys' instead, together with 'getValue' */ get javaFields(): string[] { return wrapJoinPoint(this._javaObject.getJavaFields()) } /** * Id that is based on the position of the node in the code, and should remain stable between compilations (warning: only a few nodes - file, function, loop - currently support it) */ get jpId(): string { return wrapJoinPoint(this._javaObject.getJpId()) } /** * A list of the properties currently supported by this node. Can be used as parameter of the attribute 'getValue' */ get keys(): string[] { return wrapJoinPoint(this._javaObject.getKeys()) } /** * Returns the last child of this node, or undefined if it has no child */ get lastChild(): Joinpoint { return wrapJoinPoint(this._javaObject.getLastChild()) } /** * Returns the last child of this node, or undefined if it has no child */ set lastChild(value: Joinpoint) { this._javaObject.setLastChild(unwrapJoinPoint(value)); } /** * Returns the node that came before this node, or undefined if there is none */ get leftJp(): Joinpoint { return wrapJoinPoint(this._javaObject.getLeftJp()) } /** * The starting line of the current node in the original code */ get line(): number { return wrapJoinPoint(this._javaObject.getLine()) } /** * A string with information about the file and code position of this node, if available */ get location(): string { return wrapJoinPoint(this._javaObject.getLocation()) } /** * Returns the number of children of the node, ignoring null nodes */ get numChildren(): number { return wrapJoinPoint(this._javaObject.getNumChildren()) } /** * If this join point was not originally from the parsed AST, returns the first join point of the original AST that contributed to its origin */ get originNode(): Joinpoint { return wrapJoinPoint(this._javaObject.getOriginNode()) } /** * Returns the parent node in the AST, or undefined if it is the root node */ get parent(): Joinpoint { return wrapJoinPoint(this._javaObject.getParent()) } /** * Returns the node that declares the scope that is a parent of the scope of this node */ get parentRegion(): Joinpoint { return wrapJoinPoint(this._javaObject.getParentRegion()) } /** * The pragmas associated with this node */ get pragmas(): Pragma[] { return wrapJoinPoint(this._javaObject.getPragmas()) } /** * Returns the node that comes after this node, or undefined if there is none */ get rightJp(): Joinpoint { return wrapJoinPoint(this._javaObject.getRightJp()) } /** * Returns the 'program' joinpoint */ get root(): Program { return wrapJoinPoint(this._javaObject.getRoot()) } /** * The nodes of the scope of the current join point. If this node has a body (e.g., loop, function) corresponds to the children of the body. Otherwise, returns an empty array */ get scopeNodes(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getScopeNodes()) } /** * Returns an array with the siblings that came before this node */ get siblingsLeft(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getSiblingsLeft()) } /** * Returns an array with the siblings that come after this node */ get siblingsRight(): Joinpoint[] { return wrapJoinPoint(this._javaObject.getSiblingsRight()) } /** * Converts this join point to a statement, or returns undefined if it was not possible */ get stmt(): Statement { return wrapJoinPoint(this._javaObject.getStmt()) } get type(): Type { return wrapJoinPoint(this._javaObject.getType()) } set type(value: Type) { this._javaObject.setType(unwrapJoinPoint(value)); } /** * True, if this node is a Java instance of the given name, which corresponds to a simple Java class name of an AST node. For an equivalent function for join point names, use 'instanceOf(joinPointName)' */ astIsInstance(className: string): boolean { return wrapJoinPoint(this._javaObject.astIsInstance(unwrapJoinPoint(className))); } /** * True if the given node is a descendant of this node */ contains(jp: Joinpoint): boolean { return wrapJoinPoint(this._javaObject.contains(unwrapJoinPoint(jp))); } /** * Looks for an ancestor joinpoint name, walking back on the AST */ getAncestor(type: string): Joinpoint { return wrapJoinPoint(this._javaObject.getAncestor(unwrapJoinPoint(type))); } /** * @deprecated Looks for an ancestor AST name, walking back on the AST */ getAstAncestor(type: string): Joinpoint { return wrapJoinPoint(this._javaObject.getAstAncestor(unwrapJoinPoint(type))); } /** * Returns the child of the node at the given index, considering null nodes */ getAstChild(index: number): Joinpoint { return wrapJoinPoint(this._javaObject.getAstChild(unwrapJoinPoint(index))); } /** * Looks for an ancestor joinpoint name, walking back on the joinpoint chain */ getChainAncestor(type: string): Joinpoint { return wrapJoinPoint(this._javaObject.getChainAncestor(unwrapJoinPoint(type))); } /** * Returns the child of the node at the given index, ignoring null nodes */ getChild(index: number): Joinpoint { return wrapJoinPoint(this._javaObject.getChild(unwrapJoinPoint(index))); } /** * Retrieves the descendants of the given type */ getDescendants(type: string): Joinpoint[] { return wrapJoinPoint(this._javaObject.getDescendants(unwrapJoinPoint(type))); } /** * Retrieves the descendants of the given type, including the node itself */ getDescendantsAndSelf(type: string): Joinpoint[] { return wrapJoinPoint(this._javaObject.getDescendantsAndSelf(unwrapJoinPoint(type))); } /** * Looks in the descendants for the first node of the given type */ getFirstJp(type: string): Joinpoint { return wrapJoinPoint(this._javaObject.getFirstJp(unwrapJoinPoint(type))); } /** * String with the full Java class name of the type of the Java field with the provided name */ getJavaFieldType(fieldName: string): string { return wrapJoinPoint(this._javaObject.getJavaFieldType(unwrapJoinPoint(fieldName))); } /** * Java Class instance with the type of the given key */ getKeyType(key: string): object { return wrapJoinPoint(this._javaObject.getKeyType(unwrapJoinPoint(key))); } /** * Retrives values that have been associated to nodes of the AST with 'setUserField' */ getUserField(fieldName: string): object { return wrapJoinPoint(this._javaObject.getUserField(unwrapJoinPoint(fieldName))); } /** * The value associated with the given property key */ getValue(key: string): object { return wrapJoinPoint(this._javaObject.getValue(unwrapJoinPoint(key))); } /** * True, if the given join point or AST node is the same (== test) as the current join point AST node */ hasNode(nodeOrJp: object): boolean { return wrapJoinPoint(this._javaObject.hasNode(unwrapJoinPoint(nodeOrJp))); } /** * Performs a copy of the node and its children, but not of the nodes in its fields */ copy(): Joinpoint { return wrapJoinPoint(this._javaObject.copy()); } /** * Clears all properties from the .data object */ dataClear(): void { return wrapJoinPoint(this._javaObject.dataClear()); } /** * Performs a copy of the node and its children, including the nodes in their fields (only the first level of field nodes, this function is not recursive) */ deepCopy(): Joinpoint { return wrapJoinPoint(this._javaObject.deepCopy()); } /** * Removes the node associated to this joinpoint from the AST */ detach(): Joinpoint { return wrapJoinPoint(this._javaObject.detach()); } /** * Inserts the given join point after this join point */ insertAfter(node: Joinpoint): Joinpoint; /** * Overload which accepts a string */ insertAfter(code: string): Joinpoint; /** * Inserts the given join point after this join point */ insertAfter(p1: Joinpoint | string): Joinpoint { return wrapJoinPoint(this._javaObject.insertAfter(unwrapJoinPoint(p1))); } /** * Inserts the given join point before this join point */ insertBefore(node: Joinpoint): Joinpoint; /** * Overload which accepts a string */ insertBefore(node: string): Joinpoint; /** * Inserts the given join point before this join point */ insertBefore(p1: Joinpoint | string): Joinpoint { return wrapJoinPoint(this._javaObject.insertBefore(unwrapJoinPoint(p1))); } /** * Adds a message that will be printed to the user after weaving finishes. Identical messages are removed */ messageToUser(message: string): void { return wrapJoinPoint(this._javaObject.messageToUser(unwrapJoinPoint(message))); } /** * Removes the children of this node */ removeChildren(): void { return wrapJoinPoint(this._javaObject.removeChildren()); } /** * Replaces this node with the given node */ replaceWith(node: Joinpoint): Joinpoint; /** * Overload which accepts a string */ replaceWith(node: string): Joinpoint; /** * Overload which accepts a list of join points */ replaceWith(node: Joinpoint[]): Joinpoint; /** * Replaces this node with the given node */ replaceWith(p1: Joinpoint | string | Joinpoint[]): Joinpoint { return wrapJoinPoint(this._javaObject.replaceWith(unwrapJoinPoint(p1))); } /** * Overload which accepts a list of strings */ replaceWithStrings(node: string[]): Joinpoint { return wrapJoinPoint(this._javaObject.replaceWithStrings(unwrapJoinPoint(node))); } /** * Setting data directly is not supported, this action just emits a warning and does nothing */ setData(source: object): void { return wrapJoinPoint(this._javaObject.setData(JSON.stringify(source))); } /** * Replaces the first child, or inserts the join point if no child is present. Returns the replaced child, or undefined if there was no child present. */ setFirstChild(node: Joinpoint): Joinpoint { return wrapJoinPoint(this._javaObject.setFirstChild(unwrapJoinPoint(node))); } /** * Sets the commented that are embedded in a node */ setInlineComments(comments: string[]): void; /** * Sets the commented that are embedded in a node */ setInlineComments(comments: string): void; /** * Sets the commented that are embedded in a node */ setInlineComments(p1: string[] | string): void { return wrapJoinPoint(this._javaObject.setInlineComments(unwrapJoinPoint(p1))); } /** * Replaces the last child, or inserts the join point if no child is present. Returns the replaced child, or undefined if there was no child present. */ setLastChild(node: Joinpoint): Joinpoint { return wrapJoinPoint(this._javaObject.setLastChild(unwrapJoinPoint(node))); } /** * Sets the type of a node, if it has a type */ setType(type: Type): void { return wrapJoinPoint(this._javaObject.setType(unwrapJoinPoint(type))); } /** * Associates arbitrary values to nodes of the AST */ setUserField(fieldName: string, value: object): object; /** * Overload which accepts a map */ setUserField(fieldNameAndValue: Record<string, any>): object; /** * Associates arbitrary values to nodes of the AST */ setUserField(p1: string | Record<string, any>, p2?: object): object { return wrapJoinPoint(this._javaObject.setUserField(unwrapJoinPoint(p1), unwrapJoinPoint(p2))); } /** * Sets the value associated with the given property key */ setValue(key: string, value: object): Joinpoint { return wrapJoinPoint(this._javaObject.setValue(unwrapJoinPoint(key), unwrapJoinPoint(value))); } /** * Replaces this join point with a comment with the same contents as .code */ toComment(prefix: string = "", suffix: string = ""): Joinpoint { return wrapJoinPoint(this._javaObject.toComment(unwrapJoinPoint(prefix), unwrapJoinPoint(suffix))); } } export class Attribute extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get kind(): string { return wrapJoinPoint(this._javaObject.getKind()) } } /** * Utility joinpoint, to represent certain problems when generating join points */ export class ClavaException extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get exception(): object { return wrapJoinPoint(this._javaObject.getException()) } get exceptionType(): string { return wrapJoinPoint(this._javaObject.getExceptionType()) } get message(): string { return wrapJoinPoint(this._javaObject.getMessage()) } } export class Comment extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get text(): string { return wrapJoinPoint(this._javaObject.getText()) } set text(value: string) { this._javaObject.setText(unwrapJoinPoint(value)); } setText(text: string): void { return wrapJoinPoint(this._javaObject.setText(unwrapJoinPoint(text))); } } /** * Represents one declaration (e.g., int foo(){return 0;}) or definition (e.g., int foo();) in the code */ export class Decl extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * The attributes (e.g. Pure, CUDAGlobal) associated to this decl */ get attrs(): Attribute[] { return wrapJoinPoint(this._javaObject.getAttrs()) } } /** * Utility joinpoint, to represent empty nodes when directly accessing the tree */ export class Empty extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; } export class Expression extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * A 'decl' join point that represents the declaration associated with this expression, or undefined if there is none */ get decl(): Decl { return wrapJoinPoint(this._javaObject.getDecl()) } /** * Returns a cast joinpoint if this expression has an associated implicit cast, undefined otherwise */ get implicitCast(): Cast { return wrapJoinPoint(this._javaObject.getImplicitCast()) } /** * True if the expression is part of an argument of a function call */ get isFunctionArgument(): boolean { return wrapJoinPoint(this._javaObject.getIsFunctionArgument()) } get use(): "read" | "write" | "readwrite" { return wrapJoinPoint(this._javaObject.getUse()) } get vardecl(): Vardecl { return wrapJoinPoint(this._javaObject.getVardecl()) } } /** * Represents a source file (.c, .cpp., .cl, etc) */ export class FileJp extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; /** * The path to the source folder that was given as the base folder of this file */ get baseSourcePath(): string { return wrapJoinPoint(this._javaObject.getBaseSourcePath()) } /** * The output of the parser if there were errors during parsing */ get errorOutput(): string { return wrapJoinPoint(this._javaObject.getErrorOutput()) } /** * A Java file to the file that originated this translation unit */ get file(): object { return wrapJoinPoint(this._javaObject.getFile()) } /** * True if this file contains a 'main' method */ get hasMain(): boolean { return wrapJoinPoint(this._javaObject.getHasMain()) } /** * True if there were errors during parsing */ get hasParsingErrors(): boolean { return wrapJoinPoint(this._javaObject.getHasParsingErrors()) } /** * The includes of this file */ get includes(): Include[] { return wrapJoinPoint(this._javaObject.getIncludes()) } /** * True if this file is considered a C++ file */ get isCxx(): boolean { return wrapJoinPoint(this._javaObject.getIsCxx()) } /** * True if this file is considered a header file */ get isHeader(): boolean { return wrapJoinPoint(this._javaObject.getIsHeader()) } /** * True if this file is an OpenCL filetype */ get isOpenCL(): boolean { return wrapJoinPoint(this._javaObject.getIsOpenCL()) } /** * The name of the file */ get name(): string { return wrapJoinPoint(this._javaObject.getName()) } /** * The name of the file */ set name(value: string) { this._javaObject.setName(unwrapJoinPoint(value)); } /** * The folder of the source file */ get path(): string { return wrapJoinPoint(this._javaObject.getPath()) } /** * The path to the file relative to the base source path */ get relativeFilepath(): string { return wrapJoinPoint(this._javaObject.getRelativeFilepath()) } /** * The path to the folder of the source file relative to the base source path */ get relativeFolderpath(): string { return wrapJoinPoint(this._javaObject.getRelativeFolderpath()) } /** * The path to the folder of the source file relative to the base source path */ set relativeFolderpath(value: string) { this._javaObject.setRelativeFolderpath(unwrapJoinPoint(value)); } /** * The name of the source folder of this file, or undefined if it has none */ get sourceFoldername(): string { return wrapJoinPoint(this._javaObject.getSourceFoldername()) } /** * The complete path to the file that will be generated by the weaver, given a destination folder */ getDestinationFilepath(destinationFolderpath?: string): string { return wrapJoinPoint(this._javaObject.getDestinationFilepath(unwrapJoinPoint(destinationFolderpath))); } /** * Adds a C include to the current file. If the file already has the include, it does nothing */ addCInclude(name: string, isAngled: boolean = false): void { return wrapJoinPoint(this._javaObject.addCInclude(unwrapJoinPoint(name), unwrapJoinPoint(isAngled))); } /** * Adds a function to the file that returns void and has no parameters */ addFunction(name: string): Joinpoint { return wrapJoinPoint(this._javaObject.addFunction(unwrapJoinPoint(name))); } /** * Adds a global variable to this file */ addGlobal(name: string, type: Joinpoint, initValue: string): Vardecl { return wrapJoinPoint(this._javaObject.addGlobal(unwrapJoinPoint(name), unwrapJoinPoint(type), unwrapJoinPoint(initValue))); } /** * Adds an include to the current file. If the file already has the include, it does nothing */ addInclude(name: string, isAngled: boolean = false): void { return wrapJoinPoint(this._javaObject.addInclude(unwrapJoinPoint(name), unwrapJoinPoint(isAngled))); } /** * Overload of addInclude which accepts a join point */ addIncludeJp(jp: Joinpoint): void { return wrapJoinPoint(this._javaObject.addIncludeJp(unwrapJoinPoint(jp))); } /** * Adds the node in the join point to the start of the file */ insertBegin(node: Joinpoint): void; /** * Adds the String as a Decl to the end of the file */ insertBegin(code: string): void; /** * Adds the node in the join point to the start of the file */ insertBegin(p1: Joinpoint | string): void { return wrapJoinPoint(this._javaObject.insertBegin(unwrapJoinPoint(p1))); } /** * Adds the node in the join point to the end of the file */ insertEnd(node: Joinpoint): void; /** * Adds the String as a Decl to the end of the file */ insertEnd(code: string): void; /** * Adds the node in the join point to the end of the file */ insertEnd(p1: Joinpoint | string): void { return wrapJoinPoint(this._javaObject.insertEnd(unwrapJoinPoint(p1))); } /** * Recompiles only this file, returns a join point to the new recompiled file, or throws an exception if a problem happens */ rebuild(): FileJp { return wrapJoinPoint(this._javaObject.rebuild()); } /** * Recompiles only this file, returns a join point to the new recompiled file, or returns a clavaException join point if a problem happens */ rebuildTry(): Joinpoint { return wrapJoinPoint(this._javaObject.rebuildTry()); } /** * Changes the name of the file */ setName(filename: string): void { return wrapJoinPoint(this._javaObject.setName(unwrapJoinPoint(filename))); } /** * Sets the path to the folder of the source file relative to the base source path */ setRelativeFolderpath(path: string): void { return wrapJoinPoint(this._javaObject.setRelativeFolderpath(unwrapJoinPoint(path))); } /** * Writes the code of this file to a given folder */ write(destinationFoldername: string): string { return wrapJoinPoint(this._javaObject.write(unwrapJoinPoint(destinationFoldername))); } } export class ImplicitValue extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; } /** * Represents an include directive (e.g., #include <stdio.h>) */ export class Include extends Decl { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; /** * True if this is an angled include (i.e., system include) */ get isAngled(): boolean { return wrapJoinPoint(this._javaObject.getIsAngled()) } /** * The name of the include */ get name(): string { return wrapJoinPoint(this._javaObject.getName()) } /** * The path to the folder of the source file of the include, relative to the name of the include */ get relativeFolderpath(): string { return wrapJoinPoint(this._javaObject.getRelativeFolderpath()) } } export class InitList extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * [May be undefined] If this initializer list initializes an array with more elements than there are initializers in the list, specifies an expression to be used for value initialization of the rest of the elements */ get arrayFiller(): Expression { return wrapJoinPoint(this._javaObject.getArrayFiller()) } } export class Literal extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; } export class MemberAccess extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * True if this is a member access that uses arrow (i.e., foo->bar), false if uses dot (i.e., foo.bar) */ get arrow(): boolean { return wrapJoinPoint(this._javaObject.getArrow()) } /** * True if this is a member access that uses arrow (i.e., foo->bar), false if uses dot (i.e., foo.bar) */ set arrow(value: boolean) { this._javaObject.setArrow(unwrapJoinPoint(value)); } /** * Expression of the base of this member access */ get base(): Expression { return wrapJoinPoint(this._javaObject.getBase()) } get memberChain(): Expression[] { return wrapJoinPoint(this._javaObject.getMemberChain()) } get memberChainNames(): string[] { return wrapJoinPoint(this._javaObject.getMemberChainNames()) } get name(): string { return wrapJoinPoint(this._javaObject.getName()) } setArrow(isArrow: boolean): void { return wrapJoinPoint(this._javaObject.setArrow(unwrapJoinPoint(isArrow))); } } /** * Represents a decl with a name */ export class NamedDecl extends Decl { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; get isPublic(): boolean { return wrapJoinPoint(this._javaObject.getIsPublic()) } get name(): string { return wrapJoinPoint(this._javaObject.getName()) } set name(value: string) { this._javaObject.setName(unwrapJoinPoint(value)); } get qualifiedName(): string { return wrapJoinPoint(this._javaObject.getQualifiedName()) } set qualifiedName(value: string) { this._javaObject.setQualifiedName(unwrapJoinPoint(value)); } get qualifiedPrefix(): string { return wrapJoinPoint(this._javaObject.getQualifiedPrefix()) } set qualifiedPrefix(value: string) { this._javaObject.setQualifiedPrefix(unwrapJoinPoint(value)); } /** * Sets the name of this namedDecl */ setName(name: string): void { return wrapJoinPoint(this._javaObject.setName(unwrapJoinPoint(name))); } /** * Sets the qualified name of this namedDecl (changes both the name and qualified prefix) */ setQualifiedName(name: string): void { return wrapJoinPoint(this._javaObject.setQualifiedName(unwrapJoinPoint(name))); } /** * Sets the qualified prefix of this namedDecl */ setQualifiedPrefix(qualifiedPrefix: string): void { return wrapJoinPoint(this._javaObject.setQualifiedPrefix(unwrapJoinPoint(qualifiedPrefix))); } } export class NewExpr extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; } export class Op extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get isBitwise(): boolean { return wrapJoinPoint(this._javaObject.getIsBitwise()) } /** * The kind of the operator. If it is a binary operator, can be one of: ptr_mem_d, ptr_mem_i, mul, div, rem, add, sub, shl, shr, cmp, lt, gt, le, ge, eq, ne, and, xor, or, l_and, l_or, assign, mul_assign, div_assign, rem_assign, add_assign, sub_assign, shl_assign, shr_assign, and_assign, xor_assign, or_assign, comma. If it is a unary operator, can be one of: post_inc, post_dec, pre_inc, pre_dec, addr_of, deref, plus, minus, not, l_not, real, imag, extension, cowait. */ get kind(): string { return wrapJoinPoint(this._javaObject.getKind()) } get operator(): string { return wrapJoinPoint(this._javaObject.getOperator()) } } export class ParenExpr extends Expression { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * Returns the expression inside this parenthesis expression */ get subExpr(): Expression { return wrapJoinPoint(this._javaObject.getSubExpr()) } } /** * Represents a pragma in the code (e.g., #pragma kernel) */ export class Pragma extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; /** * Everything that is after the name of the pragma */ get content(): string { return wrapJoinPoint(this._javaObject.getContent()) } /** * Everything that is after the name of the pragma */ set content(value: string) { this._javaObject.setContent(unwrapJoinPoint(value)); } /** * The name of the pragma. E.g. for #pragma foo bar, returns 'foo' */ get name(): string { return wrapJoinPoint(this._javaObject.getName()) } /** * The name of the pragma. E.g. for #pragma foo bar, returns 'foo' */ set name(value: string) { this._javaObject.setName(unwrapJoinPoint(value)); } /** * The first node below the pragma that is not a comment or another pragma. Example of pragma targets are statements and declarations */ get target(): Joinpoint { return wrapJoinPoint(this._javaObject.getTarget()) } /** * All the nodes below the target node, including the target node, up until a pragma with the name given by argument 'endPragma'. If no end pragma is found, returns the same result as if not providing the argument */ getTargetNodes(endPragma?: string): Joinpoint[] { return wrapJoinPoint(this._javaObject.getTargetNodes(unwrapJoinPoint(endPragma))); } setContent(content: string): void { return wrapJoinPoint(this._javaObject.setContent(unwrapJoinPoint(content))); } setName(name: string): void { return wrapJoinPoint(this._javaObject.setName(unwrapJoinPoint(name))); } } /** * Represents the complete program and is the top-most joinpoint in the hierarchy */ export class Program extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; get baseFolder(): string { return wrapJoinPoint(this._javaObject.getBaseFolder()) } get defaultFlags(): string[] { return wrapJoinPoint(this._javaObject.getDefaultFlags()) } /** * Paths to includes that the current program depends on */ get extraIncludes(): string[] { return wrapJoinPoint(this._javaObject.getExtraIncludes()) } /** * Link libraries of external projects the current program depends on */ get extraLibs(): string[] { return wrapJoinPoint(this._javaObject.getExtraLibs()) } /** * Paths to folders of projects that the current program depends on */ get extraProjects(): string[] { return wrapJoinPoint(this._javaObject.getExtraProjects()) } /** * Paths to sources that the current program depends on */ get extraSources(): string[] { return wrapJoinPoint(this._javaObject.getExtraSources()) } /** * The source files in this program */ get files(): FileJp[] { return wrapJoinPoint(this._javaObject.getFiles()) } get includeFolders(): string[] { return wrapJoinPoint(this._javaObject.getIncludeFolders()) } /** * True if the program was compiled with a C++ standard */ get isCxx(): boolean { return wrapJoinPoint(this._javaObject.getIsCxx()) } /** * A function join point with the main function of the program, if one is available */ get main(): FunctionJp { return wrapJoinPoint(this._javaObject.getMain()) } get name(): string { return wrapJoinPoint(this._javaObject.getName()) } /** * The name of the standard (e.g., c99, c++11) */ get standard(): string { return wrapJoinPoint(this._javaObject.getStandard()) } /** * The flag of the standard (e.g., -std=c++11) */ get stdFlag(): string { return wrapJoinPoint(this._javaObject.getStdFlag()) } get userFlags(): string[] { return wrapJoinPoint(this._javaObject.getUserFlags()) } get weavingFolder(): string { return wrapJoinPoint(this._javaObject.getWeavingFolder()) } /** * Adds a path to an include that the current program depends on */ addExtraInclude(path: string): void { return wrapJoinPoint(this._javaObject.addExtraInclude(unwrapJoinPoint(path))); } /** * Adds a path based on a git repository to an include that the current program depends on */ addExtraIncludeFromGit(gitRepo: string, path?: string): void { return wrapJoinPoint(this._javaObject.addExtraIncludeFromGit(unwrapJoinPoint(gitRepo), unwrapJoinPoint(path))); } /** * Adds a library (e.g., -pthreads) that the current program depends on */ addExtraLib(lib: string): void { return wrapJoinPoint(this._javaObject.addExtraLib(unwrapJoinPoint(lib))); } /** * Adds a path to a source that the current program depends on */ addExtraSource(path: string): void { return wrapJoinPoint(this._javaObject.addExtraSource(unwrapJoinPoint(path))); } /** * Adds a path based on a git repository to a source that the current program depends on */ addExtraSourceFromGit(gitRepo: string, path?: string): void { return wrapJoinPoint(this._javaObject.addExtraSourceFromGit(unwrapJoinPoint(gitRepo), unwrapJoinPoint(path))); } /** * Adds a file join point to the current program */ addFile(file: FileJp): Joinpoint { return wrapJoinPoint(this._javaObject.addFile(unwrapJoinPoint(file))); } /** * Adds a file join point to the current program, from the given path, which can be either a Java File or a String */ addFileFromPath(filepath: object): Joinpoint { return wrapJoinPoint(this._javaObject.addFileFromPath(unwrapJoinPoint(filepath))); } /** * Adds a path based on a git repository to a project that the current program depends on */ addProjectFromGit(gitRepo: string, libs: string[], path?: string): void { return wrapJoinPoint(this._javaObject.addProjectFromGit(unwrapJoinPoint(gitRepo), unwrapJoinPoint(libs), unwrapJoinPoint(path))); } /** * Registers a function to be executed when the program exits */ atexit(func: FunctionJp): void { return wrapJoinPoint(this._javaObject.atexit(unwrapJoinPoint(func))); } /** * Discards the AST at the top of the ASt stack */ pop(): void { return wrapJoinPoint(this._javaObject.pop()); } /** * Creates a copy of the current AST and pushes it to the top of the AST stack */ push(): void { return wrapJoinPoint(this._javaObject.push()); } /** * Recompiles the program currently represented by the AST, transforming literal code into AST nodes. Returns true if all files could be parsed correctly, or false otherwise */ rebuild(): boolean { return wrapJoinPoint(this._javaObject.rebuild()); } /** * Similar to rebuild, but tries to fix compilation errors. Resulting program may not represent the originally intended functionality */ rebuildFuzzy(): void { return wrapJoinPoint(this._javaObject.rebuildFuzzy()); } } /** * Common class of struct, union and class */ export class RecordJp extends NamedDecl { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; get fields(): Field[] { return wrapJoinPoint(this._javaObject.getFields()) } get functions(): FunctionJp[] { return wrapJoinPoint(this._javaObject.getFunctions()) } /** * True if this particular join point is an implementation (i.e. has its body fully specified), false otherwise */ get isImplementation(): boolean { return wrapJoinPoint(this._javaObject.getIsImplementation()) } /** * True if this particular join point is a prototype (i.e. does not have its body fully specified), false otherwise */ get isPrototype(): boolean { return wrapJoinPoint(this._javaObject.getIsPrototype()) } get kind(): string { return wrapJoinPoint(this._javaObject.getKind()) } /** * Adds a field to a record (struct, class). */ addField(field: Field): void { return wrapJoinPoint(this._javaObject.addField(unwrapJoinPoint(field))); } } export class Statement extends Joinpoint { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get isFirst(): boolean { return wrapJoinPoint(this._javaObject.getIsFirst()) } get isLast(): boolean { return wrapJoinPoint(this._javaObject.getIsLast()) } } /** * Represets a struct declaration */ export class Struct extends RecordJp { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "name", }; } export class Switch extends Statement { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; /** * The case statements inside this switch */ get cases(): Case[] { return wrapJoinPoint(this._javaObject.getCases()) } /** * The condition of this switch statement */ get condition(): Expression { return wrapJoinPoint(this._javaObject.getCondition()) } /** * The default case statement of this switch statement or undefined if it does not have a default case */ get getDefaultCase(): Case { return wrapJoinPoint(this._javaObject.getGetDefaultCase()) } /** * True if there is a default case in this switch statement, false otherwise */ get hasDefaultCase(): boolean { return wrapJoinPoint(this._javaObject.getHasDefaultCase()) } } export class SwitchCase extends Statement { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; } /** * A pragma that references a point in the code and sticks to it */ export class Tag extends Pragma { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: "id", }; /** * The ID of the pragma */ get id(): string { return wrapJoinPoint(this._javaObject.getId()) } } export class TernaryOp extends Op { /** * @internal */ static readonly _defaultAttributeInfo: {readonly map?: DefaultAttributeMap, readonly name: string | null, readonly type?: PrivateMapper, readonly jpMapper?: typeof JoinpointMapper} = { name: null, }; get cond(): Expression { return wrapJoinPoint(this._javaObject.getCond()) } get falseExpr(): Expression { return wrapJoinPoint(this._javaObject.getFalseExpr()) } get trueExpr(): Expression { return wrapJoinPoint(this._javaObject.getTrueExpr()) } } export class This extends Expression { /** * @internal */ static readonly _defaultAttribute