/// <summary> /// Processes the specified code. /// </summary> /// <param name="code">The code.</param> /// <param name="injectionPos">The injection position.</param> /// <param name="injectionLength">Length of the injection.</param> /// <returns></returns> static public string Process(string code, out int injectionPos, out int injectionLength) { AutoclassPrecompiler.Result result = AutoclassPrecompiler.Process(code, ConsoleEncoding); injectionPos = result.InjectionPos; injectionLength = result.InjectionLength; return(result.Content); }
public void PrintDecoratedAutoclass(string script) { string code = File.ReadAllText(script); var decorated = AutoclassPrecompiler.Process(code); print(decorated); }
//static string FileToClassName(string text) //{ // return Path.GetFileNameWithoutExtension(text).Replace("_", ""); //double '_' are not allowed for class names //} public static bool Compile(ref string content, string scriptFile, bool IsPrimaryScript, Hashtable context) { if (!IsPrimaryScript) { return(false); } int injectionPos; int injectionLength; content = AutoclassPrecompiler.Process(content, out injectionPos, out injectionLength, (string)context["ConsoleEncoding"]); return(true); }
/// <summary> /// Processes the specified code. /// </summary> /// <param name="code">The code.</param> /// <param name="position">The position.</param> /// <returns></returns> static public string Process(string code, ref int position) { int[] line_col = GetLineCol(code, position); int originalLine = line_col[0]; int originalCol = line_col[1]; var result = AutoclassPrecompiler.Process(code, ConsoleEncoding); if (result.InjectionPos != -1) { int line = originalLine; if (result.BodyInjectedLine != -1 && result.BodyInjectedLine <= originalLine) { line += result.BodyInjectedLineCount; if (result.FooterInjectedLine != -1 && result.FooterInjectedLine <= originalLine) line += result.FooterInjectedLineCount; } position = GetPos(result.Content, line, originalCol); } return result.Content; }
/// <summary> /// Processes the specified code. /// </summary> /// <param name="code">The code.</param> /// <param name="position">The position.</param> /// <returns></returns> static public string Process(string code, ref int position) { int injectionPos; int injectionLength; int injectedLine; int[] line_col = GetLineCol(code, position); int originalLine = line_col[0]; int originalCol = line_col[1]; string retval = AutoclassPrecompiler.Process(code, out injectionPos, out injectionLength, out injectedLine, ConsoleEncoding); if (injectionPos != -1) { if (injectedLine != -1 && injectedLine <= originalLine) { position = GetPos(retval, originalLine + 1, originalCol); } else { position = GetPos(retval, originalLine, originalCol); } } return(retval); }
/// <summary> /// Processes the specified code. /// </summary> /// <param name="code">The code.</param> /// <param name="injectionPos">The injection position.</param> /// <param name="injectionLength">Length of the injection.</param> /// <returns></returns> static public string Process(string code, out int injectionPos, out int injectionLength) { int injectedLine; return(AutoclassPrecompiler.Process(code, out injectionPos, out injectionLength, out injectedLine, ConsoleEncoding)); }