Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 108 additions & 19 deletions packages/cxx-frontend/src/AST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export abstract class AttributeTokenAST extends AST {}
export abstract class CoreDeclaratorAST extends AST {}
export abstract class DeclarationAST extends AST {}
export abstract class DeclaratorChunkAST extends AST {}
export abstract class DesignatorAST extends AST {}
export abstract class ExceptionDeclarationAST extends AST {}
export abstract class ExceptionSpecifierAST extends AST {}
export abstract class ExpressionAST extends AST {}
Expand Down Expand Up @@ -6411,33 +6412,37 @@ export class DesignatedInitializerClauseAST extends ExpressionAST {
}

/**
* Returns the location of the dot token in this node
*/
getDotToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
}

/**
* Returns the location of the identifier token in this node
*/
getIdentifierToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
}

/**
* Returns the identifier attribute of this node
* Returns the designatorList of this node
*/
getIdentifier(): string | undefined {
const slot = cxx.getASTSlot(this.getHandle(), 2);
return cxx.getIdentifierValue(slot);
getDesignatorList(): Iterable<DesignatorAST | undefined> {
let it = cxx.getASTSlot(this.getHandle(), 0);
let value: DesignatorAST | undefined;
let done = false;
const p = this.parser;
function advance() {
done = it === 0;
if (done) return;
const ast = cxx.getListValue(it);
value = AST.from<DesignatorAST>(ast, p);
it = cxx.getListNext(it);
}
function next() {
advance();
return { done, value };
}
return {
[Symbol.iterator]() {
return { next };
},
};
}

/**
* Returns the initializer of this node
*/
getInitializer(): ExpressionAST | undefined {
return AST.from<ExpressionAST>(
cxx.getASTSlot(this.getHandle(), 3),
cxx.getASTSlot(this.getHandle(), 1),
this.parser,
);
}
Expand Down Expand Up @@ -6756,6 +6761,88 @@ export class ParenInitializerAST extends ExpressionAST {
}
}

/**
* DotDesignatorAST node.
*/
export class DotDesignatorAST extends DesignatorAST {
/**
* Traverse this node using the given visitor.
* @param visitor the visitor.
* @param context the context.
* @returns the result of the visit.
*/
accept<Context, Result>(
visitor: ASTVisitor<Context, Result>,
context: Context,
): Result {
return visitor.visitDotDesignator(this, context);
}

/**
* Returns the location of the dot token in this node
*/
getDotToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
}

/**
* Returns the location of the identifier token in this node
*/
getIdentifierToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
}

/**
* Returns the identifier attribute of this node
*/
getIdentifier(): string | undefined {
const slot = cxx.getASTSlot(this.getHandle(), 2);
return cxx.getIdentifierValue(slot);
}
}

/**
* SubscriptDesignatorAST node.
*/
export class SubscriptDesignatorAST extends DesignatorAST {
/**
* Traverse this node using the given visitor.
* @param visitor the visitor.
* @param context the context.
* @returns the result of the visit.
*/
accept<Context, Result>(
visitor: ASTVisitor<Context, Result>,
context: Context,
): Result {
return visitor.visitSubscriptDesignator(this, context);
}

/**
* Returns the location of the lbracket token in this node
*/
getLbracketToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
}

/**
* Returns the expression of this node
*/
getExpression(): ExpressionAST | undefined {
return AST.from<ExpressionAST>(
cxx.getASTSlot(this.getHandle(), 1),
this.parser,
);
}

/**
* Returns the location of the rbracket token in this node
*/
getRbracketToken(): Token | undefined {
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
}
}

/**
* SplicerAST node.
*/
Expand Down Expand Up @@ -12890,6 +12977,8 @@ const AST_CONSTRUCTORS: Array<
EqualInitializerAST,
BracedInitListAST,
ParenInitializerAST,
DotDesignatorAST,
SubscriptDesignatorAST,
SplicerAST,
GlobalModuleFragmentAST,
PrivateModuleFragmentAST,
Expand Down
4 changes: 4 additions & 0 deletions packages/cxx-frontend/src/ASTKind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ export enum ASTKind {
BracedInitList,
ParenInitializer,

// DesignatorAST
DotDesignator,
SubscriptDesignator,

// AST
Splicer,
GlobalModuleFragment,
Expand Down
Loading