Rhino.Context.GetSourcePositionFromStack C# (CSharp) Method

GetSourcePositionFromStack() static private method

static private GetSourcePositionFromStack ( int linep ) : string
linep int
return string
		internal static string GetSourcePositionFromStack(int[] linep)
		{
			Context cx = GetCurrentContext();
			if (cx == null)
			{
				return null;
			}
			if (cx.lastInterpreterFrame != null)
			{
				Evaluator evaluator = CreateInterpreter();
				if (evaluator != null)
				{
					return evaluator.GetSourcePositionFromStack(cx, linep);
				}
			}
			StringWriter writer = new StringWriter();
			Exception re = new Exception();
			Sharpen.Runtime.PrintStackTrace(re, new PrintWriter(writer));
			string s = writer.ToString();
			int open = -1;
			int close = -1;
			int colon = -1;
			for (int i = 0; i < s.Length; i++)
			{
				char c = s[i];
				if (c == ':')
				{
					colon = i;
				}
				else
				{
					if (c == '(')
					{
						open = i;
					}
					else
					{
						if (c == ')')
						{
							close = i;
						}
						else
						{
							if (c == '\n' && open != -1 && close != -1 && colon != -1 && open < colon && colon < close)
							{
								string fileStr = Sharpen.Runtime.Substring(s, open + 1, colon);
								if (!fileStr.EndsWith(".java"))
								{
									string lineStr = Sharpen.Runtime.Substring(s, colon + 1, close);
									try
									{
										linep[0] = System.Convert.ToInt32(lineStr);
										if (linep[0] < 0)
										{
											linep[0] = 0;
										}
										return fileStr;
									}
									catch (FormatException)
									{
									}
								}
								// fall through
								open = close = colon = -1;
							}
						}
					}
				}
			}
			return null;
		}
Context