public PyTabPage(string name, PyPath pyPath) : base(name) { PyPath = pyPath; FastColoredTextBox = new FastColoredTextBoxNS.FastColoredTextBox(); FastColoredTextBox.Dock = DockStyle.Fill; FastColoredTextBox.AutoIndent = true; FastColoredTextBox.AutoIndentChars = false; this.Controls.Add(FastColoredTextBox); }
public static MyError MainNotFound(PyPath nodePath, MyError error) { error.Message = "Main no definido"; error.Set(-1, -1, nodePath.StringValue, MyError.ErrorType.Semantic, MyError.ErrorLevel.Warning); AddError(error); return(error); }
internal static void InitialiseScriptingEnvironment() { ScriptRuntimeSetup Setup = new ScriptRuntimeSetup(); Setup.LanguageSetups.Add(IronRuby.Ruby.CreateRubySetup()); Setup.LanguageSetups.Add(IronPython.Hosting.Python.CreateLanguageSetup(null)); RunTime = new ScriptRuntime(Setup); Engine = RunTime.GetEngine("py"); Scope = RunTime.CreateScope(); RunTime.IO.SetOutput(ShellOutStream, Encoding.UTF8); RunTime.IO.SetErrorOutput(ShellOutStream, Encoding.UTF8); Assembly MainAssembly = Assembly.GetExecutingAssembly(); string RootDir = Directory.GetParent(MainAssembly.Location).FullName; string HAGPath = Path.Combine(RootDir, "HtmlAgilityPack.dll"); Assembly HAGAssembly = Assembly.LoadFile(HAGPath); RunTime.LoadAssembly(MainAssembly); RunTime.LoadAssembly(HAGAssembly); RunTime.LoadAssembly(typeof(String).Assembly); RunTime.LoadAssembly(typeof(Uri).Assembly); RunTime.LoadAssembly(typeof(XmlDocument).Assembly); Engine.Runtime.TryGetEngine("py", out Engine); List <string> PySearchPaths = new List <string>(); foreach (string PyPath in PyPaths) { PySearchPaths.Add(PyPath.Replace("$ROOTDIR", RootDir)); } try { Engine.SetSearchPaths(PySearchPaths); } catch (Exception Exp) { IronException.Report("Unable to set PyPaths", Exp.Message, Exp.StackTrace); } foreach (string PyCommand in PyCommands) { try { ExecuteStartUpCommand(PyCommand); } catch (Exception Exp) { IronException.Report("Unable to execute Python startup command - " + PyCommand, Exp.Message, Exp.StackTrace); } } Engine.Runtime.TryGetEngine("rb", out Engine); List <string> RbSearchPaths = new List <string>(); foreach (string RbPath in RbPaths) { RbSearchPaths.Add(RbPath.Replace("$ROOTDIR", RootDir)); } Engine.SetSearchPaths(RbSearchPaths); foreach (string RbCommand in RbCommands) { try { ExecuteStartUpCommand(RbCommand); } catch (Exception Exp) { IronException.Report("Unable to execute Ruby startup command" + RbCommand, Exp.Message, Exp.StackTrace); } } Engine.Runtime.TryGetEngine("py", out Engine); ExecuteStartUpCommand("print 123"); ShellOutText = new StringBuilder(); IronUI.ResetInteractiveShellResult(); }
public Word Visit(Graph graph) { var result = graph.FileName.Accept(this); if (IsError(result)) { return(ErrorFactory.GraphError(graph.FileName, "FileName", result)); } PyObj pyObjFileName; if (IsMemoryBlock(result))//comentar ese if else si se hace la desereferencia en atomic expr. { pyObjFileName = ((MemoryBlock)result).Value; } else { pyObjFileName = (PyObj)result; } if (pyObjFileName.GetMyType() != TypeConstants.STRING) { return(ErrorFactory.GraphError(graph.DotSource, "FileName", result)); } result = graph.DotSource.Accept(this); if (IsError(result)) { return(ErrorFactory.GraphError(graph.DotSource, "DotSource", result)); } PyObj pyObjDotSource; if (IsMemoryBlock(result))//comentar ese if else si se hace la desereferencia en atomic expr. { pyObjDotSource = ((MemoryBlock)result).Value; } else { pyObjDotSource = (PyObj)result; } if (pyObjDotSource.GetMyType() != TypeConstants.STRING) { return(ErrorFactory.GraphError(graph.DotSource, "DotSource", result)); } //Chapuz hacer un nuevo my string con el pyusac type porque graph solo recibe mystrings var path = ((MyString)pyObjFileName).StringValue; if (path.Length < 1) { return(ErrorFactory.PathNotValid(graph.FileName, path)); } if ((path[0] != Path.DirectorySeparatorChar) || (path[0] != 'C' && path[0] != 'D' && path[1] != ':'))//tiene que agregar al path la ruta del archivo con el que este nodo fue creado { path = graph.NodePath.GetParentPath() + Path.DirectorySeparatorChar + PyPath.ReplaceSepartors(path); } var pyPath = new PyPath(path); if (!Directory.Exists(pyPath.GetParentPath())) { return(ErrorFactory.PathNotValid(graph.FileName, pyPath.GetParentPath())); } var myStringPath = new MyString(path); var myStringDotSource = (MyString)pyObjDotSource; var environmentGraphResult = RuntimeEnvironment.Console.Instance.Graph(myStringPath, myStringDotSource); if (environmentGraphResult != null) { return(ErrorFactory.DotError(graph.DotSource, environmentGraphResult)); } return(null); }
public override Word Visit(ImportNode importNode)//chapuz bajo: NO retorna nada nunca para que no tengamos que hacer otra clase que herrede de Word, Este metodo como tal se encarga de agregar a sus imports { string path = ((MyString)importNode.Path.Accept(this)).StringValue; if (path.Length < 1) { return(ErrorFactory.PathNotValid(importNode.Path, path)); } if ((path[0] != Path.DirectorySeparatorChar) || (path[0] != 'C' && path[0] != 'D' && path[1] != ':'))//tiene que agregar al path la ruta del archivo con el que este nodo fue creado { path = importNode.NodePath.GetParentPath() + Path.DirectorySeparatorChar + PyPath.ReplaceSepartors(path); } if (!File.Exists(path)) { ErrorFactory.FileNotFound(importNode, path); return(null); } var import = CreateStaticEntity(path); if (import == null) { ErrorFactory.SyntaxErrorInImport(importNode, path); return(null); } StaticEntity.AddImport(import); return(null); }