123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- #include "KSGSDouble.h"
- #include "KSGSTyp.h"
- #include "../Error/Error.h"
- #include "KSGSBool.h"
- #include "KSGSInt.h"
- #include "KSGSText.h"
- using namespace KSGScript;
- // Inhalt der KSGSDoubleKlasse Klasse aus KSGSDouble.h
- // Konstruktor
- KSGSDoubleKlasse::KSGSDoubleKlasse( KSGScriptProcessor *zObj, double std )
- : KSGSKlasseInstanz( KSGS_DOUBLE, 0, 0, zObj )
- {
- val = std;
- }
- // Destruktor
- KSGSDoubleKlasse::~KSGSDoubleKlasse()
- {
- }
- // nicht constant
- void KSGSDoubleKlasse::set( double d )
- {
- val = d;
- }
- KSGSVariable *KSGSDoubleKlasse::doOperator( int id, KSGSVariable *rechts )
- {
- if( !rechts && id != KSGS_O_NICHT && id != KSGS_O_MINUS1 && id != KSGS_O_PLUS1 && id != KSGS_O_BITNICHT )
- {
- if( rechts )
- rechts->release();
- error( 3, {}, obj );
- return 0;
- }
- KSGSVariable *ret = 0;
- switch( id )
- {
- case KSGS_O_SET:
- val = rechts->getDouble();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_PLUSSET:
- val += rechts->getDouble();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_MINUSSET:
- val -= rechts->getDouble();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_MAHLSET:
- val *= rechts->getDouble();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_GETEILTSET:
- val /= rechts->getDouble();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_UNDSET:
- val = (int)val & rechts->getInt();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_ODERSET:
- val = (int)val | rechts->getInt();
- ret = (KSGSVariable *)getThis();
- break;
- case KSGS_O_GLEICH:
- ret = new KSGSBoolKlasse( obj, val == rechts->getDouble() );
- break;
- case KSGS_O_KLEINERGLEICH:
- ret = new KSGSBoolKlasse( obj, val <= rechts->getDouble() );
- break;
- case KSGS_O_GRÖßERGLEICH:
- ret = new KSGSBoolKlasse( obj, val >= rechts->getDouble() );
- break;
- case KSGS_O_UNGLEICH:
- ret = new KSGSBoolKlasse( obj, val != rechts->getDouble() );
- break;
- case KSGS_O_KLEINER:
- ret = new KSGSBoolKlasse( obj, val < rechts->getDouble() );
- break;
- case KSGS_O_GRÖßER:
- ret = new KSGSBoolKlasse( obj, val > rechts->getDouble() );
- break;
- case KSGS_O_ODER:
- ret = new KSGSBoolKlasse( obj, val || rechts->getDouble() );
- break;
- case KSGS_O_UND:
- ret = new KSGSBoolKlasse( obj, val && rechts->getDouble() );
- break;
- case KSGS_O_BITODER:
- ret = new KSGSDoubleKlasse( obj, (int)val | rechts->getInt() );
- break;
- case KSGS_O_BITUND:
- ret = new KSGSDoubleKlasse( obj, (int)val & rechts->getInt() );
- break;
- case KSGS_O_PLUS:
- ret = new KSGSDoubleKlasse( obj, val + rechts->getDouble() );
- break;
- case KSGS_O_MINUS:
- ret = new KSGSDoubleKlasse( obj, val - rechts->getDouble() );
- break;
- case KSGS_O_MAHL:
- ret = new KSGSDoubleKlasse( obj, val * rechts->getDouble() );
- break;
- case KSGS_O_GETEILT:
- ret = new KSGSDoubleKlasse( obj, val / rechts->getDouble() );
- break;
- case KSGS_O_REST:
- ret = new KSGSDoubleKlasse( obj, (int)val % rechts->getInt() );
- break;
- case KSGS_O_PLUS1:
- ret = new KSGSDoubleKlasse( obj, val++ );
- break;
- case KSGS_O_MINUS1:
- ret = new KSGSDoubleKlasse( obj, val-- );
- break;
- case KSGS_O_NICHT:
- ret = new KSGSDoubleKlasse( obj, !val );
- break;
- case KSGS_O_BITNICHT:
- ret = new KSGSDoubleKlasse( obj, ~(int)val );
- break;
- case KSGS_O_NACHLINKS:
- ret = new KSGSDoubleKlasse( obj, (int)val << rechts->getInt() );
- break;
- case KSGS_O_NACHRECHTS:
- ret = new KSGSDoubleKlasse( obj, (int)val >> rechts->getInt() );
- break;
- }
- if( !ret )
- error( 21, {}, obj );
- if( rechts )
- rechts->release();
- return ret;
- }
- // constant
- double KSGSDoubleKlasse::getVal() const
- {
- return val;
- }
- KSGSVariable *KSGSDoubleKlasse::umwandelnIn( int typ ) const
- {
- switch( typ )
- {
- case KSGS_BOOL:
- return new KSGSBoolKlasse( obj, val != 0 );
- case KSGS_INT:
- return new KSGSIntKlasse( obj, (int)val );
- case KSGS_TEXT:
- return new KSGSTextKlasse( obj, Text() += val );
- }
- error( 16, {}, obj );
- return 0;
- }
|