コード例 #1
0
        private static CompilerError CreateJavaErrorFromString(JavaCompiler compiler, string next)
        {
            CompilerError result = new CompilerError();

            int    errorCol = 0;
            string col      = next.Trim();

            if (col.Length == 1 && col == "^")
            {
                errorCol = next.IndexOf("^");
            }

            int index1 = next.IndexOf(".java:");

            if (index1 < 0)
            {
                return(null);
            }

            string s2     = next.Substring(index1 + 6);
            int    index2 = s2.IndexOf(":");
            int    line   = Int32.Parse(next.Substring(index1 + 6, index2));
            string msg    = next.Substring(index1 + index2 + 7).Trim();

            if (msg.StartsWith("warning:"))
            {
                result.IsWarning = true;
                msg = msg.Substring(8).Trim();
            }
            result.Column    = errorCol;
            result.Line      = line;
            result.ErrorText = msg;
            result.FileName  = Path.GetFullPath(next.Substring(0, index1) + ".java");
            return(result);
        }
コード例 #2
0
ファイル: Java.cs プロジェクト: obejnen/CodeInterpreter
 public override string Render()
 {
     executableCode += ((JavaParser)parser).Parse(codeTemplate, variables, values);
     using (compiler = new JavaCompiler())
     {
         compiler.Compile(executableCode);
     }
     return(compiler.Result);
 }
コード例 #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: SourceCompiler sourceCompilerFor(Configuration configuration, org.neo4j.codegen.CodeGenerationStrategy<?> strategy) throws org.neo4j.codegen.CodeGenerationStrategyNotSupportedException
            internal override SourceCompiler sourceCompilerFor <T1>(Configuration configuration, CodeGenerationStrategy <T1> strategy)
            {
                JavaCompiler jdkCompiler = ToolProvider.SystemJavaCompiler;

                if (jdkCompiler == null)
                {
                    throw new CodeGenerationStrategyNotSupportedException(strategy, "no java source compiler available");
                }
                return(new JdkCompiler(jdkCompiler, configuration));
            }
コード例 #4
0
        private T Compile <T>(string className, string source, CompilationListener <T> listener)
        {
            JavaCompiler    systemCompiler = ToolProvider.SystemJavaCompiler;
            JavaFileManager manager        = new InMemFileManager();
            DiagnosticCollector <JavaFileObject> diagnosticsCollector = new DiagnosticCollector <JavaFileObject>();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: Iterable<? extends javax.tools.JavaFileObject> sources = java.util.Collections.singletonList(new InMemSource(className, source));
            IEnumerable <JavaFileObject> sources = Collections.singletonList(new InMemSource(className, source));

            JavaCompiler.CompilationTask task = systemCompiler.getTask(null, manager, diagnosticsCollector, null, null, sources);
            bool?success = task.call();

            return(listener.Compiled(success, manager, diagnosticsCollector.Diagnostics));
        }
コード例 #5
0
        static void ParseIkvmOutput(JavaCompiler compiler, string errorStr, CompilerResults cr)
        {
            TextReader reader = new StringReader(errorStr);
            string     line;

            while ((line = reader.ReadLine()) != null)
            {
                CompilerError error = CreateIkvmErrorFromString(line);
                if (error != null)
                {
                    cr.Errors.Add(error);
                }
            }
            reader.Close();
        }
コード例 #6
0
		static void ParseIkvmOutput (JavaCompiler compiler, string errorStr, CompilerResults cr)
		{
			TextReader reader = new StringReader (errorStr);
			string line;
			while ((line = reader.ReadLine ()) != null) {
				CompilerError error = CreateIkvmErrorFromString (line);
				if (error != null) 
					cr.Errors.Add (error);
			}
			reader.Close ();
		}
コード例 #7
0
		private static CompilerError CreateJavaErrorFromString (JavaCompiler compiler, string next)
		{
			CompilerError result = new CompilerError ();

			int errorCol = 0;
			string col = next.Trim ();
			if (col.Length == 1 && col == "^")
				errorCol = next.IndexOf ("^");

			int index1 = next.IndexOf (".java:");
			if (index1 < 0)
				return null;
		
			string s2 = next.Substring (index1 + 6);									
			int index2  = s2.IndexOf (":");				
			int line = Int32.Parse (next.Substring (index1 + 6, index2));
			string msg = next.Substring (index1 + index2 + 7).Trim ();
			if (msg.StartsWith ("warning:")) {
				result.IsWarning = true;
				msg = msg.Substring (8).Trim ();
			}
			result.Column = errorCol;
			result.Line = line;
			result.ErrorText = msg;
			result.FileName = Path.GetFullPath (next.Substring (0, index1) + ".java");
			return result;
		}
コード例 #8
0
 internal JdkCompiler(JavaCompiler compiler, Configuration configuration)
 {
     this._compiler      = compiler;
     this._configuration = configuration;
 }
コード例 #9
0
 void ParseJavaOutput(JavaCompiler jc, string errorStr, CompilerResults cr)
 {
     TextReader sr = new StringReader (errorStr);
     string next = sr.ReadLine ();
     while (next != null)
     {
         CompilerError error = CreateJavaErrorFromString (jc, next);
         if (error != null) cr.Errors.Add (error);
         next = sr.ReadLine ();
     }
     sr.Close ();
 }
コード例 #10
0
        // FIXME: the various java compilers will probably need to be parse on
        // their own and then ikvmc would need one as well
        private static CompilerError CreateJavaErrorFromString(JavaCompiler jc, string next)
        {
            CompilerError error = new CompilerError ();

            int errorCol = 0;
            string col = next.Trim ();
            if (col.Length == 1 && col == "^")
                errorCol = next.IndexOf ("^");

            int index1 = next.IndexOf (".java:");
            if (index1 < 0)
                return null;

            //string s1 = next.Substring (0, index1);
            string s2 = next.Substring (index1 + 6);
            int index2  = s2.IndexOf (":");
            int line = Int32.Parse (next.Substring (index1 + 6, index2));
            //error.IsWarning   = what[0] == "warning";
            //error.ErrorNumber = what[what.Length - 1];

            error.Column = errorCol;
            error.Line = line;
            error.ErrorText = next.Substring (index1 + index2 + 7);
            error.FileName = Path.GetFullPath (next.Substring (0, index1) + ".java"); //Path.GetFileName(filename);
            return error;
        }