FunctionDefinition.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  32. public class FunctionVariable
  33. {
  34. public string Name { get; }
  35. public System.ValueType ValueType { get; }
  36. public VariableType VariableType { get; }
  37. public Value? DefaultValue { get; }
  38. public FunctionVariable(string name, System.ValueType valueType, VariableType variableType = VariableType.None, Value? defaultValue = null)
  39. {
  40. Name = name;
  41. ValueType = valueType;
  42. VariableType = variableType;
  43. DefaultValue = defaultValue;
  44. }
  45. }
  46. public class FunctionParameter
  47. {
  48. public string Name { get; }
  49. public string[] Indices { get; }
  50. public Value? DefaultValue { get; }
  51. public FunctionParameter(string name, string[] indices, Value? defaultValue = null)
  52. {
  53. Name = name;
  54. Indices = indices;
  55. DefaultValue = defaultValue;
  56. }
  57. }
  58. }