/**
  * @param TES5BasicType $scriptType
  * @throws ConversionException
  */
 public function setNativeType(TES5BasicType $scriptType)
 {
     if (!$this->inheritanceAnalyzer->isExtending($scriptType, $this->scriptType->getNativeType())) {
         throw new ConversionException("Cannot set script type to non-extending type - current native type " . $this->scriptType->getNativeType()->value() . ", new type " . $scriptType->value());
     }
     $this->scriptType->setNativeType($scriptType->getNativeType());
 }
 public function output()
 {
     if ($this->manualCastTo !== null) {
         return [$this->referencesTo->getPropertyName() . ' as ' . $this->manualCastTo->value()];
     }
     return [$this->referencesTo->getPropertyName()];
 }
 public function output()
 {
     $codeLines = [];
     $localScope = [];
     foreach ($this->localScope->getLocalVariables() as $localVariable) {
         $localScope[] = $localVariable->getPropertyType()->output() . ' ' . $localVariable->getPropertyName();
     }
     $localScope = '(' . implode(', ', $localScope) . ')';
     $functionReturnType = $this->returnType !== null ? $this->returnType->value() . ' ' : "";
     $codeLines[] = $functionReturnType . "Function " . $this->functionName . $localScope;
     $codeLines = array_merge($codeLines, $this->codeScope->output());
     $codeLines[] = "EndFunction";
     return $codeLines;
 }
 public function trackRemoteScript(TES5ScriptHeader $scriptHeader)
 {
     $this->trackedScript = $scriptHeader;
     $ourNativeType = $this->propertyType->getNativeType();
     $remoteNativeType = $this->trackedScript->getScriptType()->getNativeType();
     /**
      * Scenario 1 - types are equal or the remote type is higher than ours in which case we do nothing as they have the good type anyway
      */
     if ($ourNativeType == $remoteNativeType || TES5InheritanceGraphAnalyzer::isExtending($remoteNativeType, $ourNativeType)) {
         return;
     } elseif (TES5InheritanceGraphAnalyzer::isExtending($ourNativeType, $remoteNativeType)) {
         $this->trackedScript->setNativeType($ourNativeType);
     } else {
         throw new ConversionException("TES5Property::trackRemoteScript() - The definitions of local property type and remote property type have diverged\r\n            ( ours: " . $ourNativeType->value() . ", remote: " . $remoteNativeType->value());
     }
 }
 public function output()
 {
     return [$this->type->value() . ' ' . $this->variableName];
 }
 public static function findReturnTypeForObjectCall(TES5Type $calledOnType, $methodName)
 {
     if (!isset(self::$callReturns[$calledOnType->value()])) {
         //Type not present in inheritance graph, check if its a basic type ( which means its basically an exception )
         if ($calledOnType->isNativePapyrusType()) {
             throw new ConversionException("Inference type exception - no call returns for " . $calledOnType->value() . "!");
         } else {
             //Otherwise, treat it like a base script
             $calledOnType = $calledOnType->getNativeType();
         }
     }
     foreach (self::$callReturns[$calledOnType->value()] as $method => $functionData) {
         if (strtolower($method) == strtolower($methodName)) {
             return TES5TypeFactory::memberByValue($functionData['returnType']);
         }
     }
     return self::findReturnTypeForObjectCall(self::findBaseClassFor($calledOnType), $methodName);
 }