Example #1
0
 /**
  * Checks this type is compactible with another type
  * Note: implementation of IType::isCompatibleWith
  * 
  * @param IType $type Type to check compactibility
  * 
  * @return boolean 
  */
 public function isCompatibleWith(IType $type)
 {
     switch ($type->getTypeCode()) {
         case TypeCode::BYTE:
         case TypeCode::CHAR:
             return true;
     }
     return false;
 }
 /**
  * Get the function prototype as string
  *
  * @return string
  */
 public function getProtoTypeAsString()
 {
     $str = $this->returnType->getFullTypeName() . ' ' . $this->functionName . '(';
     foreach ($this->argumentTypes as $argumentType) {
         $str .= $argumentType->getFullTypeName() . ', ';
     }
     return rtrim($str, ', ') . ')';
 }
Example #3
0
 /**
  * Checks this type (Void) is compactible with another type
  * Note: implementation of IType::isCompatibleWith
  * 
  * @param IType $type Type to check compactibility
  * 
  * @return boolean 
  */
 public function isCompatibleWith(IType $type)
 {
     return $type->getTypeCode() == TypeCode::VOID;
 }
 /**
  * Checks expression is a specific type
  * 
  * @param IType $type The type to check
  * 
  * @return boolean
  */
 public function typeIs(IType $type)
 {
     return $this->type->getTypeCode() == $type->getTypeCode();
 }
 /**
  * Parse primitive type literal.
  *
  * @param IType $targetType Expected type of the current literal.
  *
  * @return AbstractExpression
  *
  * @throws ODataException
  */
 private function _parseTypedLiteral(IType $targetType)
 {
     $literal = $this->_lexer->getCurrentToken()->Text;
     $outVal = null;
     if (!$targetType->validate($literal, $outVal)) {
         ODataException::createSyntaxError(Messages::expressionParserUnrecognizedLiteral($targetType->getFullTypeName(), $literal, $this->_lexer->getCurrentToken()->Position));
     }
     $result = new ConstantExpression($outVal, $targetType);
     $this->_lexer->nextToken();
     return $result;
 }