#ifndef KSGSBefehl_H #define KSGSBefehl_H #include #include using namespace Framework; namespace KSGScript { class KSGScriptObj; // ../Main/KSGScriptObj.h struct KSGSLeseBefehl; // ../Leser/KSGSLeser.h struct KSGSLeseDebug; // ../Leser/KSGSLeser.h struct KSGSBefehlParameter; // aus dieser Datei class KSGSCompKlassTable; // ../Leser/Compile.h class KSGSCompFuncTable; // ../Leser/Compile.h class KSGSCompVarTable; // ../Leser/Compile.h class KSGSBefehl; // aus dieser Datei class KSGSFunktionInstanz; // KSGSFunktion class KSGSVariable; // KSGSKlasse.h class KSGScriptProcessor; struct KSGSBefehlVariable { int varId; int varSichtbar; // 0 = global, 1 = klasse, 2 = parameter, 3 = lokal // Konstruktor __declspec( dllexport ) KSGSBefehlVariable( Text *txt, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName, int *typId, bool *ok ); }; struct KSGSBefehlFunktion { int funcId; int funkSichtbar; Array< KSGSBefehlParameter * > parameter; // Konstruktor __declspec( dllexport ) KSGSBefehlFunktion( KSGScriptProcessor *zObj, Text *txt, KSGSLeseDebug *dbg, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName, int *typId, bool *ok ); // Destruktor ~KSGSBefehlFunktion(); }; struct KSGSBefehlMember { enum Typ { BEFEHL, FUNKTION, VARIABLE }; Typ typ; KSGSBefehl *bef; KSGSBefehlFunktion *funk; KSGSBefehlVariable *var; // Konstruktor __declspec( dllexport ) KSGSBefehlMember( KSGScriptProcessor *zObj, Text *txt, KSGSLeseDebug *dbg, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName, int *typId, bool *ok ); // Destruktor __declspec( dllexport ) ~KSGSBefehlMember(); }; struct KSGSBefehlParameter { enum Typ { WERT, OBJEKT }; Typ typ; Text wert; Array< KSGSBefehlMember * > objekt; // Konstruktor __declspec( dllexport ) KSGSBefehlParameter( KSGScriptProcessor *zObj, Text *txt, KSGSLeseDebug *dbg, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName, int *typId, bool *ok ); // Destruktor __declspec( dllexport ) ~KSGSBefehlParameter(); }; struct KSGSBefehlErstell { int id; int typId; bool konstruktor; KSGSBefehlParameter *param; // Konstruktor __declspec( dllexport ) KSGSBefehlErstell( KSGScriptProcessor *zObj, Text *txt, KSGSLeseDebug *dbg, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName, bool *ok ); // Destruktor __declspec( dllexport ) ~KSGSBefehlErstell(); }; class KSGSBefehl : public virtual ReferenceCounter { public: enum Typ { CALL, OPERATOR, IF, FOR, WHILE, RETURN, BREAK, CONTINUE, VARIABLE }; protected: Typ typ; bool fehler; int returnTyp; public: // Konstruktor __declspec( dllexport ) KSGSBefehl( Typ typ ); // Destruktor __declspec( dllexport ) virtual ~KSGSBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const; __declspec( dllexport ) bool hatFehler() const; __declspec( dllexport ) int getReturnTyp() const; __declspec( dllexport ) bool istTyp( Typ t ) const; // static __declspec( dllexport ) static KSGSVariable *prozessVariable( KSGSVariable *zVorObj, KSGSBefehlVariable *zVar, KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ); __declspec( dllexport ) static KSGSVariable *prozessFunktion( KSGSVariable *zVorObj, KSGSBefehlFunktion *zFunk, KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ); __declspec( dllexport ) static KSGSVariable *prozessMember( KSGSVariable *zVorObj, KSGSBefehlMember *zMem, KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ); __declspec( dllexport ) static KSGSVariable *prozessParameter( KSGSBefehlParameter *zParam, KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ); __declspec( dllexport ) static KSGSVariable *prozessErstell( KSGSBefehlErstell *zErst, KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ); }; class KSGSCallBefehl : public KSGSBefehl { private: Array< KSGSBefehlMember * > objekt; public: // Konstruktor __declspec( dllexport ) KSGSCallBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSCallBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSOperatorBefehl : public KSGSBefehl { private: KSGSBefehlParameter *paramL; int operatorId; KSGSBefehlParameter *paramR; public: // Konstruktor __declspec( dllexport ) KSGSOperatorBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSOperatorBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSIfBefehl : public KSGSBefehl { private: KSGSBefehlParameter *bedingung; RCArray< KSGSBefehl > bTrue; RCArray< KSGSBefehl > bFalse; public: // Konstruktor __declspec( dllexport ) KSGSIfBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSIfBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSForBefehl : public KSGSBefehl { private: KSGSBefehl *links; KSGSBefehlParameter *bedingung; KSGSBefehl *rechts; RCArray< KSGSBefehl > schleife; public: // Konstruktor __declspec( dllexport ) KSGSForBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSForBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSWhileBefehl : public KSGSBefehl { private: KSGSBefehlParameter *bedingung; RCArray< KSGSBefehl > schleife; public: // Konstruktor __declspec( dllexport ) KSGSWhileBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSWhileBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSReturnBefehl : public KSGSBefehl { private: KSGSBefehlParameter *param; public: // Konstruktor __declspec( dllexport ) KSGSReturnBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSReturnBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSBreakBefehl : public KSGSBefehl { private: public: // Konstruktor __declspec( dllexport ) KSGSBreakBefehl( KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSBreakBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSContinueBefehl : public KSGSBefehl { private: public: // Konstruktor __declspec( dllexport ) KSGSContinueBefehl( KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSContinueBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; class KSGSVariableBefehl : public KSGSBefehl { private: KSGSBefehlErstell *erstell; public: // Konstruktor __declspec( dllexport ) KSGSVariableBefehl( KSGScriptProcessor *zObj, KSGSLeseBefehl *bef, KSGSCompKlassTable *zKT, KSGSCompFuncTable *zFT, KSGSCompVarTable *zVT, const char *klassName, const char *funktionName ); // Destruktor __declspec( dllexport ) ~KSGSVariableBefehl(); // constant __declspec( dllexport ) virtual KSGSVariable *execute( KSGScriptProcessor *zObj, KSGSFunktionInstanz *zFI, KSGSVariable *zKI ) const override; }; } #endif