aMaking bhl_type_ref a bit more generic and uglier

This commit is contained in:
Madpwnhammer 2023-03-02 12:33:43 +03:00
parent 62f61e4674
commit 62912023dc
1 changed files with 12 additions and 8 deletions

View File

@ -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\")";
}