| |
| |
| |
| |
|
|
| import modules ; |
| import numbers ; |
|
|
|
|
| |
| .pattern = ^([^%]*)%([^%]+)$ ; |
|
|
|
|
| |
| |
| |
| local rule indirect-rule ( x ) |
| { |
| if ! [ MATCH $(.pattern) : $(x) ] |
| { |
| return "expected a string of the form module%rule, but got \""$(x)"\" for argument" ; |
| } |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| rule make ( rulename bound-args * : context ? ) |
| { |
| context ?= [ CALLER_MODULE ] ; |
| context ?= "" ; |
| return $(context)%$(rulename) $(bound-args) ; |
| } |
|
|
|
|
| |
| |
| |
| |
| |
| |
| rule make-qualified ( rulename bound-args * : frames ? ) |
| { |
| if [ MATCH $(.pattern) : $(rulename) ] |
| { |
| return $(rulename) $(bound-args) ; |
| } |
| else |
| { |
| frames ?= 1 ; |
| |
| local module-context = [ MATCH ^(Jamfile<[^>]*>)\\..* : $(rulename) ] ; |
| |
| if ! $(module-context) |
| { |
| |
| |
| module-context = [ MATCH ^([^.]*)\\..* : $(rulename) ] ; |
| } |
| module-context ?= [ CALLER_MODULE $(frames) ] ; |
| return [ make $(rulename) $(bound-args) : $(module-context) ] ; |
| } |
| } |
|
|
|
|
| |
| |
| rule get-module ( [indirect-rule] x ) |
| { |
| local m = [ MATCH $(.pattern) : $(x) ] ; |
| if ! $(m[1]) |
| { |
| m = ; |
| } |
| return $(m[1]) ; |
| } |
|
|
|
|
| |
| |
| rule get-rule ( [indirect-rule] x ) |
| { |
| local m = [ MATCH $(.pattern) : $(x) ] ; |
| return $(m[2]) ; |
| } |
|
|
|
|
| |
| |
| rule call ( [indirect-rule] r args * : * ) |
| { |
| return [ modules.call-in [ get-module $(r) ] : [ get-rule $(r) ] $(args) |
| : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ] ; |
| } |
|
|
|
|
| rule __test__ |
| { |
| import assert ; |
|
|
| rule foo-barr! ( x ) |
| { |
| assert.equal $(x) : x ; |
| } |
|
|
| assert.equal [ get-rule [ make foo-barr! ] ] : foo-barr! ; |
| assert.equal [ get-module [ make foo-barr! ] ] : [ CALLER_MODULE ] ; |
|
|
| call [ make foo-barr! ] x ; |
| call [ make foo-barr! x ] ; |
| call [ make foo-barr! : [ CALLER_MODULE ] ] x ; |
| } |
|
|