You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
882 B
62 lines
882 B
8 years ago
|
package gogen
|
||
|
|
||
|
import (
|
||
|
"go/ast"
|
||
|
"go/token"
|
||
|
)
|
||
|
|
||
|
type Increment struct {
|
||
|
Value Expression
|
||
|
}
|
||
|
|
||
|
func (me Increment) Statement() ast.Stmt {
|
||
|
return &ast.IncDecStmt{
|
||
|
X: me.Value.Expression(),
|
||
|
Tok: token.INC,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type Decrement struct {
|
||
|
Value Expression
|
||
|
}
|
||
|
|
||
|
func (me Decrement) Statement() ast.Stmt {
|
||
|
return &ast.IncDecStmt{
|
||
|
X: me.Value.Expression(),
|
||
|
Tok: token.DEC,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type Not struct {
|
||
|
Value Expression
|
||
|
}
|
||
|
|
||
|
func (me Not) Expression() ast.Expr {
|
||
|
return &ast.UnaryExpr{
|
||
|
X: me.Value.Expression(),
|
||
|
Op: token.NOT,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type AddressOf struct {
|
||
|
Value Expression
|
||
|
}
|
||
|
|
||
|
func (me AddressOf) Expression() ast.Expr {
|
||
|
return &ast.UnaryExpr{
|
||
|
X: me.Value.Expression(),
|
||
|
Op: token.AND,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
type Index struct {
|
||
|
Value, Index Expression
|
||
|
}
|
||
|
|
||
|
func (me Index) Expression() ast.Expr {
|
||
|
return &ast.IndexExpr{
|
||
|
X: me.Value.Expression(),
|
||
|
Index: me.Index.Expression(),
|
||
|
}
|
||
|
}
|