Storing mtgMetaParsedModule as module in mtgMetaInfoUnit

This commit is contained in:
Pavel Shevaev 2023-11-30 18:48:28 +03:00
parent 160a3f2c24
commit 4499ce0eaa
2 changed files with 22 additions and 8 deletions

View File

@ -76,13 +76,27 @@ class mtgTypeRef implements mtgType
class mtgMetaInfoUnit
{
public ?mtgMetaParsedModule $module = null;
public string $file;
public mtgMetaUnit $object;
function __construct($f, mtgMetaUnit $o)
/**
* @param string|mtgMetaParsedModule $file_or_module
*/
function __construct($file_or_module, mtgMetaUnit $obj)
{
$this->file = $f;
$this->object = $o;
if($file_or_module instanceof mtgMetaParsedModule)
{
$this->module = $file_or_module;
$this->file = $file_or_module->file;
}
else if(is_string($file_or_module))
{
$this->module = null;
$this->file = $file_or_module;
}
$this->object = $obj;
}
}

View File

@ -409,7 +409,7 @@ class mtgMetaInfoParser
$existing->object->replace($enum);
}
else
$this->_addUnit(new mtgMetaInfoUnit($this->file, $enum));
$this->_addUnit(new mtgMetaInfoUnit($this->module, $enum));
}
static private function _isBuiltinType(int $t) : bool
@ -540,7 +540,7 @@ class mtgMetaInfoParser
$this->_nextT();
$fn = $this->_parseFunc();
$fn->setTokens(array_merge($this->shared_tokens, $fn->getTokens()));
$this->_addUnit(new mtgMetaInfoUnit($this->file, $fn));
$this->_addUnit(new mtgMetaInfoUnit($this->module, $fn));
}
private function _parseStruct()
@ -572,7 +572,7 @@ class mtgMetaInfoParser
$s = new mtgMetaStruct($name, array(), $parent, array(), $implements);
$s->setOrigin($struct_origin);
$this->_addUnit(new mtgMetaInfoUnit($this->file, $s));
$this->_addUnit(new mtgMetaInfoUnit($this->module, $s));
$tokens = $this->shared_tokens;
if($this->T == self::T_Prop)
@ -609,7 +609,7 @@ class mtgMetaInfoParser
$name = $this->_parseDotName();
$s = new mtgMetaInterface($name);
$this->_addUnit(new mtgMetaInfoUnit($this->file, $s));
$this->_addUnit(new mtgMetaInfoUnit($this->module, $s));
$tokens = $this->shared_tokens;
if($this->T == self::T_Prop)
@ -652,7 +652,7 @@ class mtgMetaInfoParser
$rsp->setFields($rsp_fields);
$rpc = new mtgMetaRPC("RPC_$name", $code, $req, $rsp, $tokens);
$this->_addUnit(new mtgMetaInfoUnit($this->file, $rpc));
$this->_addUnit(new mtgMetaInfoUnit($this->module, $rpc));
}
private function _parsePropTokens()