public function createGlobalScopes() { $globalScopes = []; $globalScope = new TES5GlobalScope(new TES5ScriptHeader("TES4TimerHelper", "TES4TimerHelper", TES5BasicType::T_QUEST(), "")); $globalScopes[] = $globalScope; $globalScope = new TES5GlobalScope(new TES5ScriptHeader("TES4Container", "TES4Container", TES5BasicType::T_QUEST(), "")); $globalScope->add(new TES5Property("isInJail", TES5BasicType::T_BOOL(), "isInJail")); $globalScope->add(new TES5Property("isMurderer", TES5BasicType::T_BOOL(), "isMurderer")); $globalScopes[] = $globalScope; return $globalScopes; }
public function createProperties(TES4VariableDeclarationList $variableList, TES5GlobalScope $globalScope) { /** * @var TES4VariableDeclaration[] $alreadyDefinedVariables */ $alreadyDefinedVariables = []; foreach ($variableList->getVariableList() as $variable) { $theVariableName = strtolower($variable->getVariableName()); if (isset($alreadyDefinedVariables[$theVariableName])) { if ($variable->getVariableType() == $alreadyDefinedVariables[$theVariableName]->getVariableType()) { continue; //Same variable defined twice, smack the original script developer and fallthrough silently. } throw new ConversionException("Double definition of variable named " . $variable->getVariableName() . " with different types ( " . $alreadyDefinedVariables[$theVariableName]->getVariableType()->value() . " and " . $variable->getVariableType()->value() . " )"); } switch ($variable->getVariableType()) { case TES4Type::T_FLOAT(): $property = new TES5Property($variable->getVariableName(), TES5BasicType::T_FLOAT(), null); break; case TES4Type::T_INT(): case TES4Type::T_SHORT(): case TES4Type::T_LONG(): $property = new TES5Property($variable->getVariableName(), TES5BasicType::T_INT(), null); break; case TES4Type::T_REF(): $property = $this->createPropertyFromReference($variable); break; default: throw new ConversionException("Unknown variable declaration type."); } $globalScope->add($property); $alreadyDefinedVariables[$theVariableName] = $variable; } }