IOperandTerm.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. namespace NTERA.EmuEra.Game.EraEmu.GameData.Expression
  3. {
  4. internal abstract class IOperandTerm
  5. {
  6. public IOperandTerm(Type t)
  7. {
  8. type = t;
  9. }
  10. public Type GetOperandType()
  11. {
  12. return type;
  13. }
  14. public virtual Int64 GetIntValue(ExpressionMediator exm)
  15. {
  16. return 0;
  17. }
  18. public virtual string GetStrValue(ExpressionMediator exm, bool translate=false)
  19. {
  20. return "";
  21. }
  22. public virtual SingleTerm GetValue(ExpressionMediator exm, bool tryTranslate =false)
  23. {
  24. if (type == typeof(Int64))
  25. return new SingleTerm(0);
  26. return new SingleTerm("");
  27. }
  28. public bool IsInteger => type == typeof(Int64);
  29. public bool IsString => type == typeof(string);
  30. readonly Type type;
  31. /// <summary>
  32. /// 定数を解体して可能ならSingleTerm化する
  33. /// defineの都合上、2回以上呼ばれる可能性がある
  34. /// </summary>
  35. public virtual IOperandTerm Restructure(ExpressionMediator exm, bool tryTranslate=false)
  36. {
  37. return this;
  38. }
  39. }
  40. }