private void Write(ExportSection es) { sb.AppendLine("[Exports section]"); for (int i = 0; i < es.Exports.Length; i++) { sb.AppendLine($"\texport_{i} = {es.Exports[i]}"); } }
public Configuration() { BindingSection(out _font, v => _font = v); BindingSection(out _analogControl, v => _analogControl = v); BindingSection(out _graphics, v => _graphics = v); BindingSection(out _cheats, v => _cheats = v); BindingSection(out _import, v => _import = v); BindingSection(out _export, v => _export = v); BindingSection(out _tetraMaster, v => _tetraMaster = v); BindingSection(out _fixes, v => _fixes = v); BindingSection(out _hacks, v => _hacks = v); BindingSection(out _battle, v => _battle = v); BindingSection(out _icons, v => _icons = v); BindingSection(out _debug, v => _debug = v); }
public AuditedDataReportDefinition() : base() { // Set the default name for this report in the header section ExportSection headerSection = GetReportSection(ExportSection.eSectionType.header); headerSection.FormattedText.RawText = "Audited Data Report"; _name = "Audited Data Report"; _reportType = eReportType.auditeddata; // Allocate the list of selected fields and pre-select that Asset Name _listSelectedFields = new List <string>(); _listSelectedFields.Add(AWMiscStrings.AssetDetails + "|" + Asset.GetAttributeName(Asset.eAttributes.assetname)); // Initialize the data set _reportDataSet.DataSetName = "auditdataDataSet"; }
public HistoryReportDefinition() : base() { // Set the default name for this report in the header section ExportSection headerSection = GetReportSection(ExportSection.eSectionType.header); headerSection.FormattedText.RawText = "Audit History Report"; // _name = "Audit History Report"; _reportType = eReportType.history; _subtype = eHistoryType.lastaudit; _startDate = new DateTime(0); _endDate = new DateTime(0); _days = 7; // Initialize the data set _reportDataSet.DataSetName = "historyDataSet"; // Create the tables, columns and relationships CreateTables(); }
/// <summary> /// Reads the non-custom section with the given header. /// </summary> /// <param name="Header">The section header.</param> /// <returns>The parsed section.</returns> protected Section ReadKnownSectionPayload(SectionHeader Header) { switch (Header.Name.Code) { case SectionCode.Type: return(TypeSection.ReadSectionPayload(Header, this)); case SectionCode.Import: return(ImportSection.ReadSectionPayload(Header, this)); case SectionCode.Function: return(FunctionSection.ReadSectionPayload(Header, this)); case SectionCode.Table: return(TableSection.ReadSectionPayload(Header, this)); case SectionCode.Memory: return(MemorySection.ReadSectionPayload(Header, this)); case SectionCode.Global: return(GlobalSection.ReadSectionPayload(Header, this)); case SectionCode.Export: return(ExportSection.ReadSectionPayload(Header, this)); case SectionCode.Start: return(StartSection.ReadSectionPayload(Header, this)); case SectionCode.Element: return(ElementSection.ReadSectionPayload(Header, this)); case SectionCode.Code: return(CodeSection.ReadSectionPayload(Header, this)); case SectionCode.Data: return(DataSection.ReadSectionPayload(Header, this)); default: return(ReadUnknownSectionPayload(Header)); } }
// strict parse means all sections must come in order public void ParseAsWASM(string filename, bool strict_parse = true) { if (!BitConverter.IsLittleEndian) { throw new NotImplementedException("LEB128 implementation only handles little endian systems"); } using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read)) { BinaryReader reader = new BinaryReader(fs); uint magic = reader.ReadUInt32(); if (magic != MAGIC) { throw new Exception("Not a compiled Web Assembly file."); } uint version = reader.ReadUInt32(); if (version > SUPPORTED_VERSION) { throw new Exception($"Unsupported version. Expected version <= {SUPPORTED_VERSION}, received {version}."); } int last_parsed_module = int.MinValue; /* Read in each module */ while (true) { int id = reader.PeekChar(); // EOF if (id == -1) { break; } if (strict_parse && id < last_parsed_module) { throw new Exception("File contains out of order sections."); } last_parsed_module = id; switch (id) { case (int)WebAssemblyModuleID.Custom: if (strict_parse && custom != null) { throw new Exception("File contains a duplicate custom section."); } custom = new CustomSection(reader); break; case (int)WebAssemblyModuleID.Type: if (strict_parse && type != null) { throw new Exception("File contains a duplicate type section."); } type = new TypeSection(reader); break; case (int)WebAssemblyModuleID.Import: if (strict_parse && import != null) { throw new Exception("File contains a duplicate import section."); } import = new ImportSection(reader); break; case (int)WebAssemblyModuleID.Function: if (strict_parse && function != null) { throw new Exception("File contains a duplicate function section."); } function = new FunctionSection(reader); break; case (int)WebAssemblyModuleID.Table: if (strict_parse && table != null) { throw new Exception("File contains a duplicate table section."); } table = new TableSection(reader); break; case (int)WebAssemblyModuleID.Memory: if (strict_parse && memory != null) { throw new Exception("File contains a duplicate memory section."); } memory = new MemorySection(reader); break; case (int)WebAssemblyModuleID.Global: if (strict_parse && global != null) { throw new Exception("File contains a duplicate global section."); } global = new GlobalSection(reader); break; case (int)WebAssemblyModuleID.Export: if (strict_parse && export != null) { throw new Exception("File contains a duplicate export section."); } export = new ExportSection(reader); break; case (int)WebAssemblyModuleID.Start: if (strict_parse && start != null) { throw new Exception("File contains a duplicate start section."); } start = new StartSection(reader); break; case (int)WebAssemblyModuleID.Element: if (strict_parse && element != null) { throw new Exception("File contains a duplicate element section."); } element = new ElementSection(reader); break; case (int)WebAssemblyModuleID.Code: if (strict_parse && code != null) { throw new Exception("File contains a duplicate code section."); } code = new CodeSection(reader); break; case (int)WebAssemblyModuleID.Data: if (strict_parse && data != null) { throw new Exception("File contains a duplicate data section."); } data = new DataSection(reader); break; // Error default: throw new Exception($"Unknown section {id}."); } } /* Additional validation */ // The lengths of vectors produced by the (possibly empty) function and code section must match up. if ((function != null && code == null) || (function == null && code != null)) { throw new Exception("File corrupt. Must include both function and code sections."); } if (function.types.Length != code.bodies.Length) { throw new Exception("File corrupt. Function and code sections do not match up."); } // TODO: I don't actually check if data overlaps // TODO: Validate everything in this list // https://webassembly.github.io/spec/core/valid/modules.html } }