Exemple #1
0
        public static string[] GetCompiledFunctionSignature(ParsingScript script, out Dictionary <string, Variable> dict)
        {
            script.MoveForwardIf(Constants.START_ARG, Constants.SPACE);

            int endArgs = script.FindFirstOf(Constants.END_ARG.ToString());

            if (endArgs < 0)
            {
                throw new ArgumentException("Couldn't extract function signature");
            }

            string        argStr = script.Substr(script.Pointer, endArgs - script.Pointer);
            List <string> args   = GetCompiledArgs(argStr);

            //string[] args = argStr.Split(Constants.NEXT_ARG_ARRAY, StringSplitOptions.RemoveEmptyEntries);

            dict = new Dictionary <string, Variable>(args.Count);
            var sep = new char [] { ' ' };

            for (int i = 0; i < args.Count; i++)
            {
                string[]         pair = args[i].Trim().Split(sep, StringSplitOptions.RemoveEmptyEntries);
                Variable.VarType type = pair.Length > 1 ? Constants.StringToType(pair[0]) : Variable.VarType.STRING;
                dict.Add(pair[pair.Length - 1], new Variable(type));
                args[i] = pair[pair.Length - 1];
            }

            string[] result = args.Select(element => element.Trim()).ToArray();
            script.Pointer = endArgs + 1;

            return(result);
        }
Exemple #2
0
 public static void RegisterReturnType(string functionName, string functionType)
 {
     m_returnTypes[functionName] = Constants.StringToType(functionType);
 }