Generate hello world Zig code
This commit is contained in:
@@ -106,6 +106,26 @@ type Stmt interface {
|
||||
isStmt()
|
||||
}
|
||||
|
||||
// ExprStmt represents an expression statement (e.g. a function call as a statement).
|
||||
type ExprStmt struct {
|
||||
Expr Expr
|
||||
}
|
||||
|
||||
func (*ExprStmt) isStmt() {}
|
||||
|
||||
// VarDeclStmt represents a variable or const declaration at statement level, supporting destructuring and multi-var declarations.
|
||||
type VarDeclStmt struct {
|
||||
Const bool
|
||||
Pattern VarPattern // Destructuring or multiple variable names
|
||||
Type TypeExpr // Optional
|
||||
Value Expr // Optional initializer
|
||||
ByteAlign Expr // Optional
|
||||
AddrSpace Expr // Optional
|
||||
LinkSection Expr // Optional
|
||||
}
|
||||
|
||||
func (*VarDeclStmt) isStmt() {}
|
||||
|
||||
// ReturnStmt represents a 'return' statement.
|
||||
type ReturnStmt struct {
|
||||
Value Expr // Optional
|
||||
@@ -321,6 +341,9 @@ type CallExpr struct {
|
||||
}
|
||||
|
||||
// FieldAccessExpr represents a field/member access as a suffix operation (e.g. foo.bar).
|
||||
//
|
||||
// Note: in order to call a function on an object, use a CallExpr with a Fun of a FieldAccessExpr.
|
||||
// See TestHelloWorld for example.
|
||||
type FieldAccessExpr struct {
|
||||
Receiver Expr // The object being accessed
|
||||
Field string // The field name
|
||||
@@ -475,23 +498,3 @@ type SwitchElseProng struct {
|
||||
type VarPattern struct {
|
||||
Names []string // Variable names (single or multiple for destructuring)
|
||||
}
|
||||
|
||||
// VarDeclStmt represents a variable or const declaration at statement level, supporting destructuring and multi-var declarations.
|
||||
type VarDeclStmt struct {
|
||||
Const bool
|
||||
Pattern VarPattern // Destructuring or multiple variable names
|
||||
Type TypeExpr // Optional
|
||||
Value Expr // Optional initializer
|
||||
ByteAlign Expr // Optional
|
||||
AddrSpace Expr // Optional
|
||||
LinkSection Expr // Optional
|
||||
}
|
||||
|
||||
func (*VarDeclStmt) isStmt() {}
|
||||
|
||||
// DotCallExpr represents a method call expression where a method is called on a receiver.
|
||||
// For example, in the expression `foo.bar()`, `foo` is the Receiver and `bar()` is the Call.
|
||||
type DotCallExpr struct {
|
||||
Receiver Expr // The expression being called (e.g. foo)
|
||||
Call *CallExpr
|
||||
}
|
||||
|
Reference in New Issue
Block a user