1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Diagnostics;
- namespace NTERA.Engine.Compiler
- {
- [DebuggerDisplay("{Name} ({Parameters.Length})")]
- public class FunctionDefinition
- {
- public string Name { get; }
- public FunctionParameter[] Parameters { get; }
- public FunctionVariable[] Variables { get; }
- public bool IsReturnFunction { get; }
- public string Filename { get; }
- public Marker Position { get; }
- public FunctionDefinition(string name, FunctionParameter[] parameters, FunctionVariable[] methodVariables, bool isReturnFunction, string filename, Marker position = default(Marker))
- {
- Name = name;
- Parameters = parameters;
- Variables = methodVariables;
- IsReturnFunction = isReturnFunction;
- Filename = filename;
- Position = position;
- }
- }
- [Flags]
- public enum VariableType
- {
- None = 0,
- Constant = 1,
- Reference = 2,
- Dynamic = 4,
- SaveData = 8,
- CharaData = 16,
- Global = 32,
- }
- public class FunctionVariable
- {
- public string Name { get; }
- public ValueType ValueType { get; }
- public VariableType VariableType { get; }
- public Value? DefaultValue { get; }
- public Value CalculatedValue => DefaultValue ?? ValueType == ValueType.String ? new Value("") : new Value(0d);
- public FunctionVariable(string name, ValueType valueType, VariableType variableType = VariableType.None, Value? defaultValue = null)
- {
- Name = name;
- ValueType = valueType;
- VariableType = variableType;
- DefaultValue = defaultValue;
- }
- }
- public class FunctionParameter
- {
- public string Name { get; }
- public string[] Indices { get; }
- public bool IsArrayParameter { get; }
- public Value? DefaultValue { get; }
- public FunctionParameter(string name, string[] indices, Value? defaultValue = null, bool isArrayParameter = false)
- {
- Name = name;
- Indices = indices;
- DefaultValue = defaultValue;
- IsArrayParameter = isArrayParameter;
- }
- }
- }
|