public ClassVisitor(ResolverContext resolver, SymbolTable rootTable, LabelTable labelTable) : base(UdonSharpSyntaxWalkerDepth.ClassDefinitions, resolver, rootTable, labelTable) { methodVisitor = new MethodVisitor(resolver, rootTable, labelTable); classDefinition = new ClassDefinition(); }
internal static void CheckGenerateLiteralDc(IAdrCodeGenerator target, String expected, String message) { LabelTable lblTable = new LabelTable(); String actual = target.GenerateLiteralDc(lblTable); Assert.AreEqual(expected, actual, message); }
internal static LabelAddressResolver Make() { LabelTable labelTable = new LabelTable(); EntryPointTable entryPointTable = new EntryPointTable(); return(new LabelAddressResolver(labelTable, entryPointTable)); }
public void TestInitialize() { m_lblTable = new LabelTable(); m_literal1 = new Label("LTRL0001"); m_literal2 = new Label("LTRL0002"); m_literal3 = new Label("LTRL0003"); }
public void GenerateLiteralDc() { ProgramInstruction target = ProgramInstructionTest.Make(MnemonicDef.LD, "GR1,=1234,GR2"); LabelTable lblTable = new LabelTable(); String actual = target.GenerateLiteralDc(lblTable); String expected = ProgramLineTest.MakeGeneratedLine("LTRL0001", "DC", "1234"); Assert.AreEqual(expected, actual, "リテラルの DC 命令が生成される"); }
public void GenerateCode() { LabelTable lblTable = new LabelTable(); m_target.GenerateLiteralDc(lblTable); Word[] expectedWords = TestUtils.MakeArray(Word.Zero); ICodeGeneratorTest.CheckGenerateCode( m_target, expectedWords, "オブジェクトコードにラベルのアドレスが入る場所を確保する値 0 の語が追加される"); // RelocatableModule に LabelReference が追加されることは、RelocatableModule のテストで確認する。 }
public static double[] GetNetworkInput(this LabelTable table) { IList <Label> labels = table.Labels; double[] result = new double[labels.Count]; int i = 0; foreach (Label label in labels) { result[i++] = (label.BackColor == Commons.BACK_COLOR) ? -1 : 1; } return(result); }
public CompilationModule(UdonSharpProgramAsset sourceAsset) { programAsset = sourceAsset; resolver = new ResolverContext(); moduleSymbols = new SymbolTable(resolver, null); moduleLabels = new LabelTable(); fieldsWithInitializers = new HashSet <FieldDeclarationSyntax>(); if (programAsset.sourceCsScript == null) { throw new System.ArgumentException($"Asset '{AssetDatabase.GetAssetPath(programAsset)}' does not have a valid program source to compile from"); } settings = UdonSharpSettings.GetSettings(); }
// Resolve any labels that didn't have addresses at the time of creation public string GetAssemblyStr(LabelTable labelTable = null) { if (labelTable == null) { return(assemblyTextBuilder.ToString()); } string assemblyString = assemblyTextBuilder.ToString(); #if !USE_UDON_LABELS assemblyString = ReplaceLabels(assemblyString, labelTable); #endif return(assemblyString); }
private void CheckProcess(String[] textLines, String[] expectedProcessedText, String message) { LabelTable lblTable = new LabelTable(); try { IEnumerable <ProgramLine> processedLines = TextLineProcessor.Process(textLines, lblTable); Assert.IsNotNull(expectedProcessedText, message); ProgramLineTest.CheckProgramLines(processedLines, expectedProcessedText, message); } catch (Casl2SimulatorException) { Assert.IsNull(expectedProcessedText, message); } }
private void CheckGenerateLiteralDc(String text, String expected, String message) { ProgramLine target = ProgramLine.Parse(text); LabelTable lblTable = new LabelTable(); ProgramLine generatedLine = target.GenerateLiteralDc(lblTable); if (generatedLine == null) { Assert.IsNull(expected, message); } else { String actual = generatedLine.Text; Assert.AreEqual(expected, actual, message); } }
public void SetLabelOffset() { ProgramLine instructionLine = ProgramLine.Parse("LBL001 LD GR1,GR2"); LabelTable lblTable = new LabelTable(); instructionLine.RegisterLabel(lblTable); MemoryOffset offsetSet = new MemoryOffset(0xABCD); instructionLine.SetLabelOffset(lblTable, offsetSet); LabelDefinition labelDef = lblTable.GetDefinitionFor(instructionLine.Label); MemoryOffset offsetGot = labelDef.RelOffset; MemoryOffsetTest.Check( offsetSet, offsetGot, "SetLabelOffset() で設定したラベルのオフセットが取得できる"); }
public Script() { // 寄存器初始化 _ret_val = new Op { type = OpType.Null }; funcTable = new FuncTable(); symbolTable = new SymbolTable(); labelTable = new LabelTable(); stringTable = new StringTable(); instrStream = new InstrStream(); stack = new RuntimeStack(); // 初始化运行时堆栈大小 stack.SetStackSize(1024); }
private void DecompileLabelTable() { PopByte(); var name = ReadNameReference(); var ofs = ReadUInt32(); while (ofs != 0x0000FFFF) // ends with non-ref + max-offset { LabelTable.Add(new LabelTableEntry { NameRef = name, Offset = ofs }); name = ReadNameReference(); ofs = ReadUInt32(); } }
private void DecompileLabelTable() { PopByte(); var name = ReadNameRef(); var ofs = ReadUInt32(); while (ofs != 0x0000FFFF) // ends with non-ref + max-offset { var entry = new LabelTableEntry(); entry.NameRef = name; entry.Name = PCC.GetName(name); entry.Offset = ofs; LabelTable.Add(entry); name = ReadNameRef(); ofs = ReadUInt32(); } }
private string ReplaceLabels(string assemblyString, LabelTable labelTable) { StringBuilder newAssemblyBuilder = new StringBuilder(); using (StringReader reader = new StringReader(assemblyString)) { string currentLine = reader.ReadLine(); while (currentLine != null) { string line = currentLine.TrimStart(_trimChars); if (line.StartsWith("JUMP_LABEL,", StringComparison.Ordinal)) { int startIdx = line.IndexOf('[') + 1; int endIdx = line.IndexOf(']'); string labelName = line.Substring(startIdx, endIdx - startIdx); JumpLabel label = labelTable.GetLabel(labelName); newAssemblyBuilder.AppendFormat(" JUMP, {0}\n", label.AddresStr()); } else if (line.StartsWith("JUMP_IF_FALSE_LABEL,", StringComparison.Ordinal)) { int startIdx = line.IndexOf('[') + 1; int endIdx = line.IndexOf(']'); string labelName = line.Substring(startIdx, endIdx - startIdx); JumpLabel label = labelTable.GetLabel(labelName); newAssemblyBuilder.AppendFormat(" JUMP_IF_FALSE, {0}\n", label.AddresStr()); } else { newAssemblyBuilder.Append(currentLine); newAssemblyBuilder.Append("\n"); } currentLine = reader.ReadLine(); } } return(newAssemblyBuilder.ToString()); }
public StatusEntry(string id, string level, string label_enu, string detail_enu, string label_fra, string detail_fra) { int.TryParse(id, out int IdInt); Id = IdInt; int.TryParse(level, out int LevelInt); Level = LevelInt; string EnglishLabel = Language.ReplaceHtml(label_enu); LabelTable.Add(LanguageStates.English, EnglishLabel); string EnglishDetail = Language.ReplaceHtml(detail_enu); DetailTable.Add(LanguageStates.English, EnglishDetail); string FrenchLabel = Language.ReplaceHtml(label_fra); LabelTable.Add(LanguageStates.French, FrenchLabel); string FrenchDetail = Language.ReplaceHtml(detail_fra); DetailTable.Add(LanguageStates.French, FrenchDetail); }
public UdonSharpSyntaxWalker(UdonSharpSyntaxWalkerDepth depth, ResolverContext resolver, SymbolTable rootTable, LabelTable labelTable, ClassDebugInfo classDebugInfo = null) : base(SyntaxWalkerDepth.Node) { syntaxWalkerDepth = depth; visitorContext = new ASTVisitorContext(resolver, rootTable, labelTable, classDebugInfo); }
public PropertyVisitor(ResolverContext resolver, SymbolTable rootTable, LabelTable labelTable) : base(UdonSharpSyntaxWalkerDepth.ClassDefinitions, resolver, rootTable, labelTable) { }
public void TestInitialize() { m_lblTable = new LabelTable(); }
public UdonSharpFieldVisitor(HashSet <FieldDeclarationSyntax> fieldsWithInitializers, ResolverContext resolver, SymbolTable rootTable, LabelTable labelTable, List <ClassDefinition> classDefinitions, ClassDebugInfo classDebugInfo) : base(UdonSharpSyntaxWalkerDepth.ClassDefinitions, resolver, rootTable, labelTable, classDebugInfo) { this.fieldsWithInitializers = fieldsWithInitializers; visitorContext.externClassDefinitions = classDefinitions; }
private void InitializePatternInput() { this.patternInputLabelTable = new LabelTable(Commons.PATTERN_HEIGHT, Commons.PATTERN_WIDTH, Commons.PATTERN_LABEL_SIZE, Commons.BACK_COLOR); this.Controls.Add(this.patternInputLabelTable); this.patternInputLabelTable.SetLabelMouseClickEventHandler(new MouseEventHandler(OnLabelMouseClick)); }
public void TestInitialize() { m_labelAddrResolver = Make(); m_labelTable = m_labelAddrResolver.LabelTable; m_entryPointTable = m_labelAddrResolver.EntryPointTable; }
public void Preprocess() { int current_section = -1; if (InputData.Count != 0) { current_section = 0; } int LabelIndex; if (current_section == 0) { for (int i = 0; i < InputData.Count; i++) { ReadInstruction(i, false); CurrentInstruction = RemoveSpaces(CurrentInstruction); if (CurrentInstruction == "") { continue; } LabelIndex = CurrentInstruction.IndexOf(':'); if (LabelIndex == -1) { break; } if (LabelIndex == 0) { gui.ReportError("Error: Label name expected"); return; } int j = LabelIndex - 1; while (j > 0 && (CurrentInstruction.ElementAt(j) == ' ' || CurrentInstruction.ElementAt(j) == '\t')) { j--; } string tempString = ""; bool doneFlag = false; for (; j >= 0; j--) { char tempChar = CurrentInstruction.ElementAt(j); if (tempChar != ' ' && tempChar != '\t' && !doneFlag) { tempString = tempChar + tempString; } else if (tempChar != ' ' && tempChar != '\t' && doneFlag) { gui.ReportError("Error: Unexpected text before label name"); return; } else { doneFlag = true; } } if (!assertLabelAllowed(tempString)) { return; } MemoryData tempMemory = new MemoryData(); tempMemory.Label = tempString; int wordIndex = CurrentInstruction.IndexOf(".word"); // TODO: Add directives for .float int floatIndex = CurrentInstruction.IndexOf(".float"); if (!(floatIndex != -1 || wordIndex != -1)) { gui.ReportError("Error: .word or .float not found"); return; } bool floatFlag; int Index; if (wordIndex == -1) { floatFlag = true; Index = floatIndex; } else { floatFlag = false; Index = wordIndex; } tempMemory.floatFlag = floatFlag; if (tempMemory.floatFlag) { MemoryData.StaticMemory += 4; } if (!OnlySpaces(LabelIndex + 1, Index, CurrentInstruction)) { return; } bool foundValue = false; bool doneFinding = false; tempString = ""; for (j = Index + (floatFlag ? 6 : 5); j < CurrentInstruction.Length; j++) { char temp = CurrentInstruction.ElementAt(j); if (foundValue && (temp == ' ' || temp == '\t') && !doneFinding) { doneFinding = true; } else if (foundValue && temp != ' ' && temp != '\t' && doneFinding) { gui.ReportError("Error: Unexpected text after value"); return; } else if (!foundValue && temp != ' ' && temp != '\t') { foundValue = true; tempString = tempString + temp; } else if (foundValue && temp != ' ' && temp != '\t') { tempString = tempString + temp; } } if (floatFlag) { double tempValue; if (!double.TryParse(tempString, out tempValue)) { gui.ReportError("Error: Float conversion error"); return; } tempMemory.Value = tempString; } else { int tempValue; if (!int.TryParse(tempString, out tempValue)) { gui.ReportError("Error: Int conversion error"); return; } tempMemory.Value = tempString; } MemoryTable.Add(tempMemory); } } MemoryTable.Sort(delegate(MemoryData m1, MemoryData m2) { return(m1.Label.CompareTo(m2.Label)); }); for (int i = 0; i < MemoryTable.Count - 1; i++) { if (MemoryTable.ElementAt(i) == MemoryTable.ElementAt(i + 1)) { gui.ReportError("Error: One or more labels are repeated"); return; } } if (InputText.Count != 0) { current_section = 1; } if (current_section != 1) { gui.ReportError("Error: Text section does not exist or found unknown string"); return; } int MainIndex = 0; bool FoundMain = false; LabelIndex = 0; for (int i = 0; i < InputText.Count; i++) { ReadInstruction(i, true); if (CurrentInstruction == "") { continue; } LabelIndex = CurrentInstruction.IndexOf(":"); if (LabelIndex == 0) { gui.ReportError("Error: Label name expected"); return; } if (LabelIndex == -1) { continue; } int j = LabelIndex - 1; while (j > 0 && CurrentInstruction.ElementAt(j) == ' ' && CurrentInstruction.ElementAt(j) == '\t') { j--; } string tempString = ""; bool isLabel = false; bool doneFlag = false; for (; j >= 0; j--) { char temp = CurrentInstruction.ElementAt(j); if (temp != ' ' && temp != '\t' && !doneFlag) { isLabel = true; tempString = temp + tempString; } else if (temp != ' ' && temp != '\t' && doneFlag) { gui.ReportError("Error: Unexpected text before label name"); return; } else if (!isLabel) { gui.ReportError("Error: Label name expected"); return; } else { doneFlag = true; } } if (!assertLabelAllowed(tempString)) { return; } if (!OnlySpaces(LabelIndex + 1, CurrentInstruction.Length, CurrentInstruction)) { return; } if (tempString == "main") { FoundMain = true; MainIndex = CurrentLine; } else { LabelData tempLabel = new LabelData();; tempLabel.Address = CurrentLine; tempLabel.Label = tempString; LabelTable.Add(tempLabel); } } LabelTable.Sort(delegate(LabelData l1, LabelData l2) { return(l1.Label.CompareTo(l2.Label)); }); for (int i = 0; LabelTable.Count > 0 && i < LabelTable.Count - 1; i++) { if (LabelTable[i].Label == LabelTable[i + 1].Label) { gui.ReportError("Error: One or more labels are repeated"); return; } } if (!FoundMain) { gui.ReportError("Error: Could not find main"); return; } CurrentLine = MainIndex; gui.SendLog("Initialized and ready to execute."); gui.updateState(); }