123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- #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( KSGScriptObj *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 = getThis();
- break;
- case KSGS_O_PLUSSET:
- val = ( val + rechts->getBool() ) != 0;
- ret = getThis();
- break;
- case KSGS_O_MINUSSET:
- val = ( val - rechts->getBool() ) != 0;
- ret = getThis();
- break;
- case KSGS_O_MAHLSET:
- val = ( val * rechts->getBool() ) != 0;
- ret = getThis();
- break;
- case KSGS_O_UNDSET:
- val &= rechts->getBool();
- ret = getThis();
- break;
- case KSGS_O_ODERSET:
- val |= rechts->getBool();
- ret = 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_GRÖßERGLEICH:
- 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_GRÖßER:
- 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 );
- 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;
- }
- // Reference Counting
- KSGSVariable *KSGSBoolKlasse::release()
- {
- ref--;
- if( !ref )
- delete this;
- return 0;
- }
|