#include "KSGSBool.h" #include "KSGSTyp.h" #include "../Error/Error.h" #include "KSGSInt.h" #include "KSGSDouble.h" #include "KSGSText.h" using namespace KSGScript; // Inhalt der KSGSBoolKlasse Klasse aus KSGSBool.h // Konstruktor KSGSBoolKlasse::KSGSBoolKlasse( KSGScriptProcessor *zObj, bool std ) : KSGSKlasseInstanz( KSGS_BOOL, 0, 0, zObj ) { val = std; } // Destruktor KSGSBoolKlasse::~KSGSBoolKlasse() { } // nicht constant KSGSVariable *KSGSBoolKlasse::doOperator( int id, KSGSVariable *rechts ) { if( !rechts && id != KSGS_O_NICHT && id != KSGS_O_MINUS1 && id != KSGS_O_PLUS1 ) { if( rechts ) rechts->release(); error( 3, {}, obj ); return 0; } KSGSVariable *ret = 0; switch( id ) { case KSGS_O_SET: val = rechts->getBool(); ret = dynamic_cast( getThis() ); break; case KSGS_O_PLUSSET: val = ( val + rechts->getBool() ) != 0; ret = dynamic_cast( getThis() ); break; case KSGS_O_MINUSSET: val = ( val - rechts->getBool() ) != 0; ret = dynamic_cast( getThis() ); break; case KSGS_O_MAHLSET: val = ( val * rechts->getBool() ) != 0; ret = dynamic_cast( getThis() ); break; case KSGS_O_UNDSET: val &= rechts->getBool(); ret = dynamic_cast( getThis() ); break; case KSGS_O_ODERSET: val |= rechts->getBool(); ret = dynamic_cast( getThis() ); break; case KSGS_O_GLEICH: ret = new KSGSBoolKlasse( obj, val == rechts->getBool() ); break; case KSGS_O_KLEINERGLEICH: ret = new KSGSBoolKlasse( obj, val <= rechts->getBool() ); break; case KSGS_O_GREATERGLEICH: ret = new KSGSBoolKlasse( obj, val >= rechts->getBool() ); break; case KSGS_O_UNGLEICH: ret = new KSGSBoolKlasse( obj, val != rechts->getBool() ); break; case KSGS_O_KLEINER: ret = new KSGSBoolKlasse( obj, val < rechts->getBool() ); break; case KSGS_O_GREATER: ret = new KSGSBoolKlasse( obj, val > rechts->getBool() ); break; case KSGS_O_ODER: ret = new KSGSBoolKlasse( obj, val || rechts->getBool() ); break; case KSGS_O_UND: ret = new KSGSBoolKlasse( obj, val && rechts->getBool() ); break; case KSGS_O_BITODER: ret = new KSGSBoolKlasse( obj, val | rechts->getBool() ); break; case KSGS_O_BITUND: ret = new KSGSBoolKlasse( obj, val & rechts->getBool() ); break; case KSGS_O_PLUS: ret = new KSGSBoolKlasse( obj, ( val + rechts->getBool() ) != 0 ); break; case KSGS_O_MINUS: ret = new KSGSBoolKlasse( obj, ( val - rechts->getBool() ) != 0 ); break; case KSGS_O_MAHL: ret = new KSGSBoolKlasse( obj, ( val * rechts->getBool() ) != 0 ); break; case KSGS_O_PLUS1: ret = new KSGSBoolKlasse( obj, val != 0 ); val = 1; break; case KSGS_O_MINUS1: ret = new KSGSBoolKlasse( obj, ( val - 1 ) != 0 ); break; case KSGS_O_NICHT: ret = new KSGSBoolKlasse( obj, !val ); break; } if( !ret ) error( 21, {}, obj ); if( rechts ) rechts->release(); return ret; } // constant bool KSGSBoolKlasse::getVal() const { return val; } KSGSVariable *KSGSBoolKlasse::umwandelnIn( int typ ) const { switch( typ ) { case KSGS_INT: return new KSGSIntKlasse( obj, val ); case KSGS_DOUBLE: return new KSGSDoubleKlasse( obj, val ); case KSGS_TEXT: return new KSGSTextKlasse( obj, Text() += (int)val ); } error( 16, {}, obj ); return 0; }