diff --git a/src/bind.inc.php b/src/bind.inc.php index 16bad56..ae6ae9e 100644 --- a/src/bind.inc.php +++ b/src/bind.inc.php @@ -286,16 +286,20 @@ function norm_name($name) function bhl_type_ref($type_str) { - if(preg_match('~\[\]((\w|\.)+)~', $type_str, $ms)) - return "types.TArr(\"{$ms[1]}\")"; - else if(preg_match('~coro\s+func\s+((\w|\.)+)\s*\(\)~', $type_str, $ms)) - return "types.TFunc(true, \"{$ms[1]}\")"; + if(preg_match('~coro\s+func\s+((\w|\.)+)\s*\(\)~', $type_str, $ms)) + return "types.TFunc(true, ".bhl_type_ref($ms[1]).")"; + else if(preg_match('~coro\s+func\s+((\w|\.)+)\s*\(((\w|\.|\[|\])+)\)~', $type_str, $ms)) + return "types.TFunc(true, ".bhl_type_ref($ms[1]).", ".bhl_type_ref($ms[3]).")"; else if(preg_match('~func\s+((\w|\.)+)\s*\(\)~', $type_str, $ms)) - return "types.TFunc(false, \"{$ms[1]}\")"; - else if(preg_match('~func\s+((\w|\.)+)\s*\(((\w|\.)+)\)~', $type_str, $ms)) - return "types.TFunc(false, \"{$ms[1]}\", \"{$ms[3]}\")"; + return "types.TFunc(false, ".bhl_type_ref($ms[1]).")"; + else if(preg_match('~func\s+((\w|\.)+)\s*\(((\w|\.|\[|\])+)\)~', $type_str, $ms)) + return "types.TFunc(false, ".bhl_type_ref($ms[1]).", ".bhl_type_ref($ms[3]).")"; + else if(preg_match('~func\s+((\w|\.)+)\s*\(((\w|\.|\[|\])+)\s*,((\w|\.|\[|\])+)\)~', $type_str, $ms)) + return "types.TFunc(false, ".bhl_type_ref($ms[1]).", ".bhl_type_ref($ms[3]).", ".bhl_type_ref($ms[5]).")"; + else if(preg_match('~\[\]((\w|\.)+)~', $type_str, $ms)) + return "types.TArr(".bhl_type_ref($ms[1]).")"; else if(preg_match('~((\w|\.)+)\,((\w|\.)+)~', $type_str, $ms)) - return "types.T(\"{$ms[1]}\", \"{$ms[3]}\")"; + return "types.T(".bhl_type_ref($ms[1]).", ".bhl_type_ref($ms[3]).")"; else return "types.T(\"$type_str\")"; }