Example #1
0
        private Dictionary <string, string> GetCodeChunks(AbstractTranspiler transpiler, string userCode)
        {
            string resourcePath = transpiler.HelperCodeResourcePath;
            Dictionary <string, string> output = new Dictionary <string, string>();

            if (resourcePath == null)
            {
                return(output);
            }

            string helperCode = PastelUtil.ReadAssemblyFileText(typeof(AbstractTranspiler).Assembly, resourcePath);

            string        currentId    = null;
            List <string> currentChunk = new List <string>();

            foreach (string lineRaw in helperCode.Split('\n'))
            {
                string line = lineRaw.TrimEnd();
                if (line.Contains("PASTEL_ENTITY_ID"))
                {
                    if (currentId != null)
                    {
                        output[currentId] = string.Join("\n", currentChunk).Trim();
                    }
                    currentId = line.Split(':')[1].Trim();
                    currentChunk.Clear();
                }
                else
                {
                    currentChunk.Add(lineRaw);
                }
            }

            if (currentId != null)
            {
                output[currentId] = string.Join("\n", currentChunk).Trim();
            }

            output[""] = userCode;

            return(output);
        }
Example #2
0
 private static string GetCoreFunctionSignatureManifest()
 {
     return(PastelUtil.ReadAssemblyFileText(typeof(CoreFunctionUtil).Assembly, "CoreFunctionSignatures.txt"));
 }