Improved error handling for struct types
This commit is contained in:
parent
97cdcbd1cb
commit
526385280a
@ -13,7 +13,7 @@ accept(fd Int, address Pointer, length Int) -> Int {
|
|||||||
return syscall(43, fd, address, length)
|
return syscall(43, fd, address, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
bind(fd Int, address Pointer, length Int) -> Int {
|
bind(fd Int, address *sockaddr_in, length Int) -> Int {
|
||||||
return syscall(49, fd, address, length)
|
return syscall(49, fd, address, length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
nanosleep(duration Pointer) -> Int {
|
struct timespec {
|
||||||
|
seconds Int
|
||||||
|
nanoseconds Int
|
||||||
|
}
|
||||||
|
|
||||||
|
nanosleep(duration *timespec) -> Int {
|
||||||
return syscall(35, duration, 0)
|
return syscall(35, duration, 0)
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ sleep(nanoseconds Int) {
|
|||||||
seconds, nanoseconds = nanoseconds / 1000000000
|
seconds, nanoseconds = nanoseconds / 1000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
duration := new(timespec)
|
duration := new(sys.timespec)
|
||||||
duration.seconds = seconds
|
duration.seconds = seconds
|
||||||
duration.nanoseconds = nanoseconds
|
duration.nanoseconds = nanoseconds
|
||||||
sys.nanosleep(duration)
|
sys.nanosleep(duration)
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
struct timespec {
|
|
||||||
seconds Int
|
|
||||||
nanoseconds Int
|
|
||||||
}
|
|
@ -8,7 +8,13 @@ import (
|
|||||||
func ByName(name string, pkg string, structs map[string]*Struct) Type {
|
func ByName(name string, pkg string, structs map[string]*Struct) Type {
|
||||||
if strings.HasPrefix(name, "*") {
|
if strings.HasPrefix(name, "*") {
|
||||||
to := strings.TrimPrefix(name, "*")
|
to := strings.TrimPrefix(name, "*")
|
||||||
return &Pointer{To: ByName(to, pkg, structs)}
|
typ := ByName(to, pkg, structs)
|
||||||
|
|
||||||
|
if typ != nil {
|
||||||
|
return &Pointer{To: typ}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch name {
|
switch name {
|
||||||
@ -32,5 +38,11 @@ func ByName(name string, pkg string, structs map[string]*Struct) Type {
|
|||||||
return PointerAny
|
return PointerAny
|
||||||
}
|
}
|
||||||
|
|
||||||
return structs[pkg+"."+name]
|
typ, exists := structs[pkg+"."+name]
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return typ
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user