Skip to content

Commit

Permalink
增加测试case
Browse files Browse the repository at this point in the history
  • Loading branch information
lvyahui8 committed Oct 2, 2024
1 parent 3b1ed5e commit acaa907
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ellyn_ast/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,12 @@ func (f *FileVisitor) addFuncByDecl(fName string, decl *ast.FuncDecl) {

func (f *FileVisitor) addFunc(fName string, begin, end, bodyBegin token.Position, funcType *ast.FuncType) {
fc := f.prog.addMethod(f.fileId, fName, begin, end, funcType)

f.insert(bodyBegin.Offset+1,
fmt.Sprintf(
`_ellynCtx := ellyn_agent.Agent.GetCtx();ellyn_agent.Agent.Push(_ellynCtx,%d);defer ellyn_agent.Agent.Pop(_ellynCtx);`, fc.Id),
"_ellynCtx := ellyn_agent.Agent.GetCtx();"+
"ellyn_agent.Agent.Push(_ellynCtx,%d);"+
"defer ellyn_agent.Agent.Pop(_ellynCtx);", fc.Id),
1)
}

Expand Down
7 changes: 5 additions & 2 deletions example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,18 @@ func N(n int) int {
return n * N(n-1)
}

func WithUnusualParam(a, b int, c string, _ bool, bool int) (x, y int, _ error) {
func WithUnusualParam(a, b int,
c string, _ bool, bool int) (x, y int,
_ error) {
time.Sleep(10 * time.Millisecond)
if bool == 0 {
return 0, 0, errors.New("test")
}
return 0, 0, nil
}

func NoName(int, string) (byte, bool) {
func NoName(int,
string) (byte, bool) {
_ = fmt.Sprintf("x%d", runtime.NumCPU())
return 0, false
}
Expand Down

0 comments on commit acaa907

Please sign in to comment.