Mercurial > repos > tabletprog
view modules/dl.tp @ 331:61f5b794d939
Breaking change: method call syntax now always uses the syntactic receiver as the actual receiver. This makes its behavior different from function call syntax, but solves some problems with methods being shadowed by local variables and the like.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 28 Mar 2015 14:21:04 -0700 |
parents | cba0cb39517a |
children |
line wrap: on
line source
#{ includeSystemHeader: "dlfcn.h" llMessage: sym:from withVars: { handle <- obj_uint64 ptr name <- string ptr intret <- obj_uint64 ptr } andCode: :name :handle { intret <- make_object: (addr_of: obj_int64_meta) NULL 0 intret num!: (dlsym: (handle num) (name data)) intret } llMessage: open:withFlags withVars: { name <- string ptr intret <- obj_uint64 ptr flags <- obj_int32 ptr } andCode: :name :flags { intret <- make_object: (addr_of: obj_int64_meta) NULL 0 if: (name len) > 0 { intret num!: (dlopen: (name data) (flags num)) } else: { intret num!: (dlopen: NULL (flags num)) } intret } llMessage: LAZY withVars: { flagret <- obj_int32 ptr } andCode: { flagret <- make_object: (addr_of: obj_int64_meta) NULL 0 flagret num!: RTLD_LAZY flagret } llMessage: NOW withVars: { flagret <- obj_int32 ptr } andCode: { flagret <- make_object: (addr_of: obj_int64_meta) NULL 0 flagret num!: RTLD_NOW flagret } main <- :args { library <- "" func <- "main" if: (args length) > 2 { library <- args get: 1 func <- args get: 2 } else: { if: (args length) > 1 { func <- args get: 1 } } handle <- open: library withFlags: NOW print: "handle: " . handle . "\n" address <- sym: func from: handle if: (library length) > 0 { print: library . " - " . func . ": " . address . "\n" } else: { print: func . ": " . address . "\n" } 0 } }