FunctionDefinition.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Diagnostics;
  3. namespace NTERA.Interpreter.Compiler
  4. {
  5. [DebuggerDisplay("{Name} ({Parameters.Length})")]
  6. public class FunctionDefinition
  7. {
  8. public string Name { get; }
  9. public FunctionParameter[] Parameters { get; }
  10. public FunctionVariable[] Variables { get; }
  11. public bool IsReturnFunction { get; }
  12. public string Filename { get; }
  13. public Marker Position { get; }
  14. public FunctionDefinition(string name, FunctionParameter[] parameters, FunctionVariable[] methodVariables, bool isReturnFunction, string filename, Marker position)
  15. {
  16. Name = name;
  17. Parameters = parameters;
  18. Variables = methodVariables;
  19. IsReturnFunction = isReturnFunction;
  20. Filename = filename;
  21. Position = position;
  22. }
  23. }
  24. [Flags]
  25. public enum VariableType
  26. {
  27. None = 0,
  28. Constant = 1,
  29. Reference = 2,
  30. Dynamic = 4,
  31. SaveData = 8,
  32. CharaData = 16,
  33. Global = 32,
  34. }
  35. public class FunctionVariable
  36. {
  37. public string Name { get; }
  38. public ValueType ValueType { get; }
  39. public VariableType VariableType { get; }
  40. public Value? DefaultValue { get; }
  41. public FunctionVariable(string name, ValueType valueType, VariableType variableType = VariableType.None, Value? defaultValue = null)
  42. {
  43. Name = name;
  44. ValueType = valueType;
  45. VariableType = variableType;
  46. DefaultValue = defaultValue;
  47. }
  48. }
  49. public class FunctionParameter
  50. {
  51. public string Name { get; }
  52. public string[] Indices { get; }
  53. public bool IsArrayParameter { get; }
  54. public Value? DefaultValue { get; }
  55. public FunctionParameter(string name, string[] indices, Value? defaultValue = null, bool isArrayParameter = false)
  56. {
  57. Name = name;
  58. Indices = indices;
  59. DefaultValue = defaultValue;
  60. IsArrayParameter = isArrayParameter;
  61. }
  62. }
  63. }