示例#1
0
 /// <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);
 }
示例#2
0
        public void PrintDecoratedAutoclass(string script)
        {
            string code = File.ReadAllText(script);

            var decorated = AutoclassPrecompiler.Process(code);

            print(decorated);
        }
示例#3
0
        //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;
        }
示例#5
0
        /// <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);
        }
示例#6
0
        /// <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));
        }