as_variablescope.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. AngelCode Scripting Library
  3. Copyright (c) 2003-2012 Andreas Jonsson
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any
  6. damages arising from the use of this software.
  7. Permission is granted to anyone to use this software for any
  8. purpose, including commercial applications, and to alter it and
  9. redistribute it freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you
  11. must not claim that you wrote the original software. If you use
  12. this software in a product, an acknowledgment in the product
  13. documentation would be appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and
  15. must not be misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source
  17. distribution.
  18. The original version of this library can be located at:
  19. http://www.angelcode.com/angelscript/
  20. Andreas Jonsson
  21. andreas@angelcode.com
  22. */
  23. //
  24. // as_variablescope.h
  25. //
  26. // A manager class for variable declarations
  27. //
  28. #ifndef AS_VARIABLESCOPE_H
  29. #define AS_VARIABLESCOPE_H
  30. #include "as_config.h"
  31. #ifndef AS_NO_COMPILER
  32. #include "as_array.h"
  33. #include "as_string.h"
  34. #include "as_datatype.h"
  35. BEGIN_AS_NAMESPACE
  36. struct sVariable
  37. {
  38. asCString name;
  39. asCDataType type;
  40. int stackOffset;
  41. bool isInitialized;
  42. bool isPureConstant;
  43. asQWORD constantValue;
  44. bool onHeap;
  45. };
  46. class asCVariableScope
  47. {
  48. public:
  49. asCVariableScope(asCVariableScope *parent);
  50. ~asCVariableScope();
  51. void Reset();
  52. int DeclareVariable(const char *name, const asCDataType &type, int stackOffset, bool isObjectOnHeap);
  53. sVariable *GetVariable(const char *name);
  54. sVariable *GetVariableByOffset(int offset);
  55. asCVariableScope *parent;
  56. bool isBreakScope;
  57. bool isContinueScope;
  58. asCArray<sVariable *> variables;
  59. };
  60. END_AS_NAMESPACE
  61. #endif // AS_NO_COMPILER
  62. #endif