public void Clear() { symtab.Clear(); main_ns = null; tree = null; namespaces.Clear(); }
public IProgramNode Convert(ICompiler Compiler, IProgramNode ProgramNode) { Optimizer Optimizer = new Optimizer(); Compiler.AddWarnings(Optimizer.Optimize(ProgramNode as PascalSharp.Internal.TreeConverter.TreeRealization.program_node)); return(ProgramNode); }
public override void InitialiseNode() { base.InitialiseNode(); if (FirstBodyNodeObject != null) { firstBodyNode = FirstBodyNodeObject.GetComponent <NodeBase>(); } }
public IProgramNode Convert(IProgramNode ProgramNode) { foreach (ISemanticTreeConverter SemanticTreeConverter in semanticTreeConverters) { ChangeState(State.Convert, SemanticTreeConverter); ProgramNode = SemanticTreeConverter.Convert(Compiler, ProgramNode); } return(ProgramNode); }
public virtual void Start() { // Find owner computer { Transform computerTransform = transform.parent; while (computerTransform) { if (computerTransform.GetComponent <EditorProgram>()) { computer = computerTransform.GetComponent <EditorProgram>().programController; break; } else { computerTransform = computerTransform.parent; } } } FindPrevNode(); // Unless overriden, not null and not in a loop, assign nextNode as node interface of the NextNodeObject if (nextNode == null && /*!inLoop &&*/ NextNodeObject != null) { NodeBase nextNodeBase = NextNodeObject.GetComponent <NodeBase>(); nextNode = (IProgramNode)nextNodeBase; } if (prevNode == null && /*!inLoop &&*/ PrevNodeObject != null) { NodeBase prevNodeBase = PrevNodeObject.GetComponent <NodeBase>(); prevNode = (IProgramNode)prevNodeBase; } if (prevNode == null && /*!inLoop &&*/ ownerLoop != null) { PrevNodeObject = ownerLoop.gameObject; NodeBase prevNodeBase = PrevNodeObject.GetComponent <NodeBase>(); prevNode = (IProgramNode)prevNodeBase; } if (NextNodeObject == null) { Logger.LogWarning($"NextNodeObject on {gameObject}::{this} is set to null! If this is intended (e.g. last node in a loop), this should be corrected on startup."); } if (PrevNodeObject == null) { Logger.LogWarning($"PrevNodeObject on {gameObject}::{this} is set to null! This is usually not intended."); } // TODO: Perhaps search for ProgramEnd as nextNode fallback? // TODO: only initialise if !isInitialised? InitialiseNode(); }
public virtual string SerializeBlockBody() { string fullBody = ""; IProgramNode currentNode = firstBodyNode; while (currentNode != null) { fullBody += $"{currentNode.Serialize()}\n"; // TODO: could this fail potentially? currentNode = ((NodeBase)currentNode).nextNode; } return(fullBody); }
internal void SetSemanticTree(IProgramNode tree) { this.tree = tree; if (tree != null) { foreach (ICommonNamespaceNode cnn in tree.namespaces) { if (string.Compare(cnn.namespace_name, Name, true) == 0) { main_ns = cnn; namespaces.Add(cnn); break; } } } }
public virtual void visit(IProgramNode value) { }
private ILConverter il_converter; //=new NETGenerator.ILConverter(); public void Compile(IProgramNode ProgramTree, string TargetFileName, string SourceFileName, CompilerOptions options, Hashtable StandartDirectories, string[] ResourceFiles) { il_converter = new ILConverter(StandartDirectories); il_converter.ConvertFromTree(ProgramTree, TargetFileName, SourceFileName, options, ResourceFiles); }
public void visit(IProgramNode value, TreeNodeCollection t) { string s = value.GetType().Name + "."; ICompiledTypeNode[] ctn = new ICompiledTypeNode[0]; prepare_base_node_collection(ctn, "compiled types", "->", 0); prepare_node(value.main_function, s + "main_function"); prepare_base_node_collection(value.namespaces, s + value.namespaces[0].GetType().Name + "_list : namespaces", "namespaces", value.namespaces.Length); }
public void visit(IProgramNode value) { StringBuilder bodyBlock = new StringBuilder(""); string currNamespace = ""; // обнуляем отступ тела блокаame ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyDecrement(); if (value.main_function != null) value.main_function.visit(this); mainFunction = ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody + ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack(); // перед входом в блок ув. отступ //SemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBodyIncrement(); mainNamespace = value.main_function.comprehensive_namespace; string outdir = System.IO.Path.GetDirectoryName(mainNamespace.Location.document.file_name); foreach (ICommonNamespaceNode nodeNamespace in value.namespaces) { nodeNamespace.visit(this); bodyBlock.Append(ISemanticNodeConverter.SourceTextBuilder.TextFormatter.Indents.BlockBody); currNamespace = ISemanticNodeConverter.SourceTextBuilder.GetNodeFromStack(); bodyBlock.Append(currNamespace); if (value.namespaces[value.namespaces.Length-1] != nodeNamespace) bodyBlock.Append(System.Environment.NewLine); string name = nodeNamespace.namespace_name.Replace('$', 'S'); if (name == "") name = System.IO.Path.GetFileNameWithoutExtension(mainNamespace.Location.document.file_name); SaveTextInFile(outdir + "\\" +name+".cs", currNamespace, false); nmspaceFiles.Add(outdir + "\\" + name + ".cs"); } //bodyBlock.Append(mainFunctionNode); ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(bodyBlock.ToString()); ISemanticNodeConverter.SourceTextBuilder.AddNodeInToStack(ISemanticNodeConverter.ConvertPABCNETNodeProgram("program", value)); }