yast2-core
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
Type Class Reference

YCP type. More...

#include <Type.h>

Inheritance diagram for Type:
Rep BlockType FlexType FunctionType ListType MapType NFlexType TupleType VariableType

List of all members.

Public Types

enum  type_kind {
  UnspecT = 0, ErrorT, AnyT, BooleanT,
  ByteblockT, FloatT, IntegerT, LocaleT,
  PathT, StringT, SymbolT, TermT,
  VoidT, WildcardT, FlexT, VariableT,
  ListT, MapT, BlockT, TupleT,
  FunctionT, NilT, NFlexT
}
typedef enum Type::type_kind tkind

Public Member Functions

 Type ()
 Type (tkind kind, bytecodeistream &str)
virtual ~Type ()
virtual string toString () const
virtual string toXmlString () const
virtual std::ostream & toStream (std::ostream &str) const
virtual std::ostream & toXml (std::ostream &str, int indent) const
virtual bool isBasetype () const
virtual constTypePtr matchFlex (constTypePtr, unsigned int=0) const
virtual int match (constTypePtr expected) const
virtual int matchvalue (YCPValue value) const
virtual bool canCast (constTypePtr to) const
virtual TypePtr clone () const
virtual constTypePtr unflex (constTypePtr type, unsigned int number=0) const
string preToString () const
string postToString () const
bool isConst () const
void asConst ()
bool isReference () const
void asReference ()
int basematch (constTypePtr expected) const
virtual bool equals (constTypePtr expected) const
bool isUnspec () const
bool isError () const
bool isAny () const
bool isBoolean () const
bool isByteblock () const
bool isFloat () const
bool isInteger () const
bool isLocale () const
bool isPath () const
bool isString () const
bool isSymbol () const
bool isTerm () const
bool isVoid () const
bool isWildcard () const
bool isFlex () const
bool isNFlex () const
bool isVariable () const
bool isList () const
bool isMap () const
bool isBlock () const
bool isTuple () const
bool isFunction () const
bool isNil () const
YCPValueType valueType () const
virtual constTypePtr commontype (constTypePtr type) const
virtual constTypePtr detailedtype (constTypePtr type) const
- Public Member Functions inherited from Rep
 Rep ()
 Rep (const Rep &)
Repoperator= (const Rep &)
virtual ~Rep ()
void ref () const
void unref () const
unsigned refCount () const
virtual const char * repName () const
virtual std::ostream & dumpOn (std::ostream &str) const

Static Public Member Functions

static void setNocheck (bool nocheck)
static constTypePtr vt2type (enum YCPValueType vt)
static int nextToken (const char **signature)
static constTypePtr fromSignature (const char **signature)
static constTypePtr fromSignature (const string &signature)
static constTypePtr determineFlexType (constFunctionTypePtr actual, constFunctionTypePtr declared)
static FunctionTypePtr Function (constTypePtr return_type)
- Static Public Member Functions inherited from Rep
static void ref (const Rep *obj_r)
static void unref (const Rep *obj_r)

Static Public Attributes

static const constTypePtr Unspec = TypePtr ( new Type (UnspecT))
static const constTypePtr Error = TypePtr ( new Type (ErrorT))
static const constTypePtr Any = TypePtr ( new Type (AnyT))
static const constTypePtr Void = TypePtr ( new Type (VoidT))
static const constTypePtr Boolean = TypePtr ( new Type (BooleanT))
static const constTypePtr Byteblock = TypePtr ( new Type (ByteblockT))
static const constTypePtr Float = TypePtr ( new Type (FloatT))
static const constTypePtr Integer = TypePtr ( new Type (IntegerT))
static const constTypePtr Locale = TypePtr ( new Type (LocaleT))
static const constTypePtr Path = TypePtr ( new Type (PathT))
static const constTypePtr String = TypePtr ( new Type (StringT))
static const constTypePtr Symbol = TypePtr ( new Type (SymbolT))
static const constTypePtr Term = TypePtr ( new Type (TermT))
static const constTypePtr Wildcard = TypePtr ( new Type (WildcardT))
static const constTypePtr ConstAny = TypePtr ( new Type (AnyT, true))
static const constTypePtr ConstVoid = TypePtr ( new Type (VoidT, true))
static const constTypePtr ConstBoolean = TypePtr ( new Type (BooleanT, true))
static const constTypePtr ConstByteblock = TypePtr ( new Type (ByteblockT, true))
static const constTypePtr ConstFloat = TypePtr ( new Type (FloatT, true))
static const constTypePtr ConstInteger = TypePtr ( new Type (IntegerT, true))
static const constTypePtr ConstLocale = TypePtr ( new Type (LocaleT, true))
static const constTypePtr ConstPath = TypePtr ( new Type (PathT, true))
static const constTypePtr ConstString = TypePtr ( new Type (StringT, true))
static const constTypePtr ConstSymbol = TypePtr ( new Type (SymbolT, true))
static const constTypePtr ConstTerm = TypePtr ( new Type (TermT, true))
static const constTypePtr ConstList = TypePtr ( new Type (ListT, true))
static const constTypePtr ConstMap = TypePtr ( new Type (MapT, true))
static const constTypePtr Flex = TypePtr ( new FlexType())
static const constTypePtr ConstFlex = TypePtr ( new FlexType (true))
static const constTypePtr NFlex1 = TypePtr ( new NFlexType(1))
static const constTypePtr ConstNFlex1 = TypePtr ( new NFlexType (1, true))
static const constTypePtr NFlex2 = TypePtr ( new NFlexType(2))
static const constTypePtr ConstNFlex2 = TypePtr ( new NFlexType (2, true))
static const constTypePtr NFlex3 = TypePtr ( new NFlexType(3))
static const constTypePtr ConstNFlex3 = TypePtr ( new NFlexType (3, true))
static const constTypePtr NFlex4 = TypePtr ( new NFlexType(4))
static const constTypePtr ConstNFlex4 = TypePtr ( new NFlexType (4, true))
static const constTypePtr ListUnspec = new ListType (Type::Unspec)
static const constTypePtr List = new ListType (Type::Any)
static const constTypePtr MapUnspec = new MapType (Type::Unspec, Type::Unspec)
static const constTypePtr Map = new MapType (Type::Any, Type::Any)
static const constTypePtr Variable = new VariableType (Type::Any)
static const constTypePtr Block = new BlockType (Type::Any)
static const constTypePtr Nil = TypePtr ( new Type (NilT))

Protected Member Functions

 Type (tkind kind, bool as_const=false, bool as_reference=false)
- Protected Member Functions inherited from Rep
virtual void ref_to (unsigned) const
virtual void unref_to (unsigned) const

Protected Attributes

tkind m_kind
bool m_const
bool m_reference

Private Member Functions

 REP_BODY (Type)
tkind kind () const

Detailed Description

YCP type.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
UnspecT 
ErrorT 
AnyT 
BooleanT 
ByteblockT 
FloatT 
IntegerT 
LocaleT 
PathT 
StringT 
SymbolT 
TermT 
VoidT 
WildcardT 
FlexT 
VariableT 
ListT 
MapT 
BlockT 
TupleT 
FunctionT 
NilT 
NFlexT 

Constructor & Destructor Documentation

Type::Type ( tkind  kind,
bool  as_const = false,
bool  as_reference = false 
)
inlineprotected
Type::Type ( )
Type::Type ( tkind  kind,
bytecodeistream str 
)

References m_const, m_kind, m_reference, and y2debug.

Type::~Type ( )
virtual

Member Function Documentation

void Type::asConst ( )
inline

set const qualifier

References m_const.

void Type::asReference ( )
inline

set reference qualifier

References m_reference.

int Type::basematch ( constTypePtr  expected) const

check if base matches with expected type <0: no match, ==0: full match, >0: propagated match

References AnyT, ErrorT, FlexT, isBasetype(), isConst(), isError(), isVoid(), NFlexT, UnspecT, WildcardT, and y2debug.

Referenced by match(), VariableType::match(), ListType::match(), MapType::match(), BlockType::match(), TupleType::match(), and FunctionType::match().

bool Type::canCast ( constTypePtr  to) const
virtual

check, if the type can be casted (at runtime considered to be - similar to dynamic_cast) to another type

Reimplemented in FunctionType, TupleType, BlockType, MapType, and ListType.

References isAny(), match(), toString(), and y2debug.

TypePtr Type::clone ( ) const
virtual

clone this type

Reimplemented in FunctionType, TupleType, BlockType, MapType, ListType, VariableType, NFlexType, and FlexType.

References m_kind.

Referenced by unflex().

constTypePtr Type::commontype ( constTypePtr  type) const
virtual

Finds a type that can hold both given types This should be the narrowest such type - TODO

Reimplemented in MapType, and ListType.

References Any, isAny(), isVoid(), match(), toString(), and y2debug.

constTypePtr Type::detailedtype ( constTypePtr  type) const
virtual

Finds a type which contains most information This should be the narrowest such type - TODO

Reimplemented in MapType, and ListType.

References Error, isAny(), isUnspec(), isVoid(), match(), toString(), and y2debug.

constTypePtr Type::determineFlexType ( constFunctionTypePtr  actual,
constFunctionTypePtr  declared 
)
static

determine actual type if declared type contains 'flex' or 'flexN' Returns actual - unchanged or fixed

determine actual type if declared type contains flex type Returns actual - unchanged or fixed or NULL on error

Parameters:
symboltype of a symbol parameter from YEBuiltin, else isUnspec

References y2debug, and ycp2error.

Referenced by YEBuiltin::finalize(), and YEBinary::type().

bool Type::equals ( constTypePtr  expected) const
virtual

check equality of the types, without any assumptions like any == unspec

Reimplemented in FunctionType, TupleType, BlockType, MapType, ListType, and VariableType.

References isBasetype(), and m_kind.

constTypePtr Type::fromSignature ( const char **  signature)
static
static constTypePtr Type::fromSignature ( const string &  signature)
inlinestatic

Construct from a string literal type code

Parameters:
seg. string("list <string>")

References fromSignature().

FunctionTypePtr Type::Function ( constTypePtr  return_type)
static
bool Type::isAny ( ) const
inline

References AnyT, and m_kind.

Referenced by canCast(), commontype(), detailedtype(), match(), and matchvalue().

virtual bool Type::isBasetype ( ) const
inlinevirtual
bool Type::isBlock ( ) const
inline

References BlockT, and m_kind.

bool Type::isBoolean ( ) const
inline

References BooleanT, and m_kind.

Referenced by matchvalue().

bool Type::isByteblock ( ) const
inline

References ByteblockT, and m_kind.

Referenced by matchvalue().

bool Type::isConst ( ) const
inline

return const qualifier

References m_const.

Referenced by basematch(), FlexType::unflex(), and NFlexType::unflex().

bool Type::isError ( ) const
inline

References ErrorT, and m_kind.

Referenced by basematch().

bool Type::isFlex ( ) const
inline

References FlexT, m_kind, and NFlexT.

Referenced by FlexType::unflex().

bool Type::isFloat ( ) const
inline

References FloatT, and m_kind.

Referenced by match(), and matchvalue().

bool Type::isFunction ( ) const
inline

References FunctionT, and m_kind.

bool Type::isInteger ( ) const
inline

References IntegerT, and m_kind.

Referenced by match(), and matchvalue().

bool Type::isList ( ) const
inline

References ListT, and m_kind.

Referenced by matchvalue().

bool Type::isLocale ( ) const
inline

References LocaleT, and m_kind.

Referenced by match().

bool Type::isMap ( ) const
inline

References m_kind, and MapT.

Referenced by matchvalue().

bool Type::isNFlex ( ) const
inline

References m_kind, and NFlexT.

Referenced by NFlexType::unflex().

bool Type::isNil ( ) const
inline

References m_kind, and NilT.

bool Type::isPath ( ) const
inline

References m_kind, and PathT.

Referenced by matchvalue().

bool Type::isReference ( ) const
inline

return reference qualifier

References m_reference.

Referenced by FlexType::unflex(), and NFlexType::unflex().

bool Type::isString ( ) const
inline

References m_kind, and StringT.

Referenced by match(), and matchvalue().

bool Type::isSymbol ( ) const
inline

References m_kind, and SymbolT.

Referenced by matchvalue().

bool Type::isTerm ( ) const
inline

References m_kind, and TermT.

Referenced by matchvalue().

bool Type::isTuple ( ) const
inline

References m_kind, and TupleT.

bool Type::isUnspec ( ) const
inline

References m_kind, and UnspecT.

Referenced by detailedtype(), and match().

bool Type::isVariable ( ) const
inline

References m_kind, and VariableT.

bool Type::isVoid ( ) const
inline

References m_kind, and VoidT.

Referenced by basematch(), commontype(), detailedtype(), and match().

bool Type::isWildcard ( ) const
inline

References m_kind, and WildcardT.

tkind Type::kind ( ) const
inlineprivate

References m_kind.

int Type::match ( constTypePtr  expected) const
virtual

check match with expected type <0: no match, ==0: full match, >0: propagated match

Reimplemented in FunctionType, TupleType, BlockType, MapType, ListType, VariableType, NFlexType, and FlexType.

References AnyT, basematch(), FlexT, FloatT, IntegerT, isAny(), isFloat(), isInteger(), isLocale(), isString(), isUnspec(), isVoid(), LocaleT, m_kind, NFlexT, StringT, toString(), UnspecT, WildcardT, and y2debug.

Referenced by canCast(), commontype(), and detailedtype().

virtual constTypePtr Type::matchFlex ( constTypePtr  ,
unsigned int  = 0 
) const
inlinevirtual
int Type::matchvalue ( YCPValue  value) const
virtual
int Type::nextToken ( const char **  signature)
static

signature parser, get next token

signature parser, get next token >= 0 -> tkind -1 -> const -100 (-x) -> NFlex '&' -> reference '<' '>' ',' '(' ')'

References AnyT, BlockT, BooleanT, ByteblockT, ErrorT, FlexT, FloatT, IntegerT, ListT, LocaleT, MapT, PathT, StringT, SymbolT, TermT, TupleT, UnspecT, VariableT, VoidT, and WildcardT.

Referenced by fromSignature().

string Type::postToString ( ) const
inline
string Type::preToString ( ) const
inline
Type::REP_BODY ( Type  )
private
static void Type::setNocheck ( bool  nocheck)
static

enable/disable type checking

std::ostream & Type::toStream ( std::ostream &  str) const
virtual

write bytecode out to stream

write out to bytecode stream

Reimplemented in FunctionType, TupleType, BlockType, MapType, ListType, VariableType, NFlexType, and FlexType.

References m_const, m_kind, m_reference, str, toString(), Bytecode::writeBool(), Bytecode::writeInt32(), and y2debug.

string Type::toString ( void  ) const
virtual
std::ostream & Type::toXml ( std::ostream &  str,
int  indent 
) const
virtual

write xml out to stream

References m_const, m_reference, str, and toXmlString().

string Type::toXmlString ( ) const
virtual
constTypePtr Type::unflex ( constTypePtr  type,
unsigned int  number = 0 
) const
virtual

replace any 'FlexT' (number == 0) or 'NFlexT' (number != 0) with 'type'

Reimplemented in FunctionType, TupleType, BlockType, MapType, ListType, VariableType, NFlexType, and FlexType.

References clone().

YCPValueType Type::valueType ( ) const
constTypePtr Type::vt2type ( enum YCPValueType  vt)
static

Member Data Documentation

const constTypePtr Type::Any = TypePtr ( new Type (AnyT))
static
const constTypePtr Type::Block = new BlockType (Type::Any)
static

Referenced by vt2type().

const constTypePtr Type::Boolean = TypePtr ( new Type (BooleanT))
static
const constTypePtr Type::Byteblock = TypePtr ( new Type (ByteblockT))
static

Referenced by fromSignature(), main(), and vt2type().

const constTypePtr Type::ConstAny = TypePtr ( new Type (AnyT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstBoolean = TypePtr ( new Type (BooleanT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstByteblock = TypePtr ( new Type (ByteblockT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstFlex = TypePtr ( new FlexType (true))
static

Referenced by fromSignature().

const constTypePtr Type::ConstFloat = TypePtr ( new Type (FloatT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstInteger = TypePtr ( new Type (IntegerT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstList = TypePtr ( new Type (ListT, true))
static
const constTypePtr Type::ConstLocale = TypePtr ( new Type (LocaleT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstMap = TypePtr ( new Type (MapT, true))
static
const constTypePtr Type::ConstNFlex1 = TypePtr ( new NFlexType (1, true))
static

Referenced by fromSignature().

const constTypePtr Type::ConstNFlex2 = TypePtr ( new NFlexType (2, true))
static

Referenced by fromSignature().

const constTypePtr Type::ConstNFlex3 = TypePtr ( new NFlexType (3, true))
static

Referenced by fromSignature().

const constTypePtr Type::ConstNFlex4 = TypePtr ( new NFlexType (4, true))
static

Referenced by fromSignature().

const constTypePtr Type::ConstPath = TypePtr ( new Type (PathT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstString = TypePtr ( new Type (StringT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstSymbol = TypePtr ( new Type (SymbolT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstTerm = TypePtr ( new Type (TermT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::ConstVoid = TypePtr ( new Type (VoidT, true))
static

Referenced by fromSignature(), and YConst::type().

const constTypePtr Type::Error = TypePtr ( new Type (ErrorT))
static
const constTypePtr Type::Flex = TypePtr ( new FlexType())
static

Referenced by fromSignature().

const constTypePtr Type::Float = TypePtr ( new Type (FloatT))
static

Referenced by fromSignature(), main(), and vt2type().

const constTypePtr Type::Integer = TypePtr ( new Type (IntegerT))
static

Referenced by fromSignature(), main(), and vt2type().

const constTypePtr Type::List = new ListType (Type::Any)
static

Referenced by vt2type().

const constTypePtr Type::ListUnspec = new ListType (Type::Unspec)
static

Referenced by YConst::type().

const constTypePtr Type::Locale = TypePtr ( new Type (LocaleT))
static
bool Type::m_const
protected
tkind Type::m_kind
protected
bool Type::m_reference
protected
const constTypePtr Type::Map = new MapType (Type::Any, Type::Any)
static

Referenced by vt2type().

const constTypePtr Type::MapUnspec = new MapType (Type::Unspec, Type::Unspec)
static

Referenced by YConst::type().

const constTypePtr Type::NFlex1 = TypePtr ( new NFlexType(1))
static

Referenced by fromSignature().

const constTypePtr Type::NFlex2 = TypePtr ( new NFlexType(2))
static

Referenced by fromSignature().

const constTypePtr Type::NFlex3 = TypePtr ( new NFlexType(3))
static

Referenced by fromSignature().

const constTypePtr Type::NFlex4 = TypePtr ( new NFlexType(4))
static

Referenced by fromSignature().

const constTypePtr Type::Nil = TypePtr ( new Type (NilT))
static
const constTypePtr Type::Path = TypePtr ( new Type (PathT))
static

Referenced by fromSignature(), main(), and vt2type().

const constTypePtr Type::String = TypePtr ( new Type (StringT))
static

Referenced by fromSignature(), main(), and vt2type().

const constTypePtr Type::Symbol = TypePtr ( new Type (SymbolT))
static
const constTypePtr Type::Term = TypePtr ( new Type (TermT))
static
const constTypePtr Type::Unspec = TypePtr ( new Type (UnspecT))
static
const constTypePtr Type::Variable = new VariableType (Type::Any)
static

Referenced by vt2type().

const constTypePtr Type::Void = TypePtr ( new Type (VoidT))
static
const constTypePtr Type::Wildcard = TypePtr ( new Type (WildcardT))
static

Referenced by fromSignature().


The documentation for this class was generated from the following files:

Generated on a sunny day for yast2-core by doxygen 1.8.1