Example #1
0
 public function createType($type)
 {
     if (!isset($this->types[$type])) {
         $jittype = null;
         switch ($type) {
             case 'bool':
             case 'numeric':
             case 'long':
                 $jittype = JitType::of(JitType::long);
                 break;
             case 'double':
                 $jittype = JitType::of(JitType::double);
                 break;
             case 'string':
                 $jittype = JitType::of(JitType::string);
                 break;
             case 'void':
                 $jittype = JitType::of(JitType::void);
         }
         if (!$jittype && substr($type, -2) === '[]') {
             $subtype = $this->createType(substr($type, 0, -2));
             $jittype = new JitType($subtype, true);
         }
         if (!$jittype) {
             throw new \RuntimeException('Unknown type encountered: ' . $type);
         }
         $this->types[$type] = $jittype;
     }
     return $this->types[$type];
 }
Example #2
0
 public static function provideTestCreateType()
 {
     return [['bool', JitType::of(JitType::long)], ['numeric', JitType::of(JitType::long)], ['long', JitType::of(JitType::long)], ['double', JitType::of(JitType::double)], ['string', JitType::of(JitType::string)], ['void', JitType::of(JitType::void)], ['long[]', new JitType(JitType::of(JitType::int), true)]];
 }