Skip to content

Commit 84d7373

Browse files
committed
Implement indirect gotos and operators to get the address of a label
Fixes #569 Signed-off-by: Roberto Raggi <[email protected]>
1 parent 7f36cfc commit 84d7373

29 files changed

+1481
-1138
lines changed

packages/cxx-frontend/src/AST.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,27 +3490,41 @@ export class GotoStatementAST extends StatementAST {
34903490
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
34913491
}
34923492

3493+
/**
3494+
* Returns the location of the star token in this node
3495+
*/
3496+
getStarToken(): Token | undefined {
3497+
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
3498+
}
3499+
34933500
/**
34943501
* Returns the location of the identifier token in this node
34953502
*/
34963503
getIdentifierToken(): Token | undefined {
3497-
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
3504+
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
34983505
}
34993506

35003507
/**
35013508
* Returns the location of the semicolon token in this node
35023509
*/
35033510
getSemicolonToken(): Token | undefined {
3504-
return Token.from(cxx.getASTSlot(this.getHandle(), 2), this.parser);
3511+
return Token.from(cxx.getASTSlot(this.getHandle(), 3), this.parser);
35053512
}
35063513

35073514
/**
35083515
* Returns the identifier attribute of this node
35093516
*/
35103517
getIdentifier(): string | undefined {
3511-
const slot = cxx.getASTSlot(this.getHandle(), 3);
3518+
const slot = cxx.getASTSlot(this.getHandle(), 4);
35123519
return cxx.getIdentifierValue(slot);
35133520
}
3521+
3522+
/**
3523+
* Returns the isIndirect attribute of this node
3524+
*/
3525+
getIsIndirect(): boolean {
3526+
return cxx.getASTSlot(this.getHandle(), 5) !== 0;
3527+
}
35143528
}
35153529

35163530
/**
@@ -5666,6 +5680,46 @@ export class ReflectExpressionAST extends ExpressionAST {
56665680
}
56675681
}
56685682

5683+
/**
5684+
* LabelAddressExpressionAST node.
5685+
*/
5686+
export class LabelAddressExpressionAST extends ExpressionAST {
5687+
/**
5688+
* Traverse this node using the given visitor.
5689+
* @param visitor the visitor.
5690+
* @param context the context.
5691+
* @returns the result of the visit.
5692+
*/
5693+
accept<Context, Result>(
5694+
visitor: ASTVisitor<Context, Result>,
5695+
context: Context,
5696+
): Result {
5697+
return visitor.visitLabelAddressExpression(this, context);
5698+
}
5699+
5700+
/**
5701+
* Returns the location of the ampAmp token in this node
5702+
*/
5703+
getAmpAmpToken(): Token | undefined {
5704+
return Token.from(cxx.getASTSlot(this.getHandle(), 0), this.parser);
5705+
}
5706+
5707+
/**
5708+
* Returns the location of the identifier token in this node
5709+
*/
5710+
getIdentifierToken(): Token | undefined {
5711+
return Token.from(cxx.getASTSlot(this.getHandle(), 1), this.parser);
5712+
}
5713+
5714+
/**
5715+
* Returns the identifier attribute of this node
5716+
*/
5717+
getIdentifier(): string | undefined {
5718+
const slot = cxx.getASTSlot(this.getHandle(), 2);
5719+
return cxx.getIdentifierValue(slot);
5720+
}
5721+
}
5722+
56695723
/**
56705724
* UnaryExpressionAST node.
56715725
*/
@@ -13279,6 +13333,7 @@ const AST_CONSTRUCTORS: Array<
1327913333
NamespaceReflectExpressionAST,
1328013334
TypeIdReflectExpressionAST,
1328113335
ReflectExpressionAST,
13336+
LabelAddressExpressionAST,
1328213337
UnaryExpressionAST,
1328313338
AwaitExpressionAST,
1328413339
SizeofExpressionAST,

packages/cxx-frontend/src/ASTKind.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export enum ASTKind {
114114
NamespaceReflectExpression,
115115
TypeIdReflectExpression,
116116
ReflectExpression,
117+
LabelAddressExpression,
117118
UnaryExpression,
118119
AwaitExpression,
119120
SizeofExpression,

0 commit comments

Comments
 (0)