| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 11 |
* Licensed to the Apache Software Foundation (ASF) under one or more |
| 12 |
* contributor license agreements. See the NOTICE file distributed |
| 13 |
* with this work for additional information regarding copyright |
| 14 |
* ownership. The ASF licenses this file to you under the Apache |
| 15 |
* License, Version 2.0 (the "License"); you may not use this file |
| 16 |
* except in compliance with the License. You may obtain a copy of |
| 17 |
* the License at http://www.apache.org/licenses/LICENSE-2.0 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#pragma once |
| 21 |
|
| 22 |
// Version 2: data type of the return value for publics |
| 23 |
// Version 3: new opcodes |
| 24 |
// Version 4: new opcodes |
| 25 |
// Version 5: bug (entry of STATIC-variables in the init code) |
| 26 |
// Version 6: new opcodes and bug (construct globals, without ending the BASIC) |
| 27 |
// Version 7: correction concerning the WITH-Parsing |
| 28 |
// Version 8: correction concerning the IF-Parsing |
| 29 |
// Version 9: end init code with LEAVE, too, if no SUB/FUNCTION follows |
| 30 |
// Version A: #36374 at DIM AS NEW... construct variable too |
| 31 |
// Version B: #40689 reorganized static |
| 32 |
// Version C: #41606 bug at static |
| 33 |
// Version D: #42678 bug at RTL-function spc |
| 34 |
// Version E: #56204 DCREATE, to also construct arrays at DIM AS NEW |
| 35 |
// Version F: #57844 introduction of SvNumberformat::StringToDouble |
| 36 |
// Version 10: #29955 generate for-loop-level in Statement-PCodes |
| 37 |
// Version 11: #29955 force anew compilation because of build-inconsistences |
| 38 |
// Version 12: aoo#64377 increase code size that basic can handle |
| 39 |
// tdf#75973 support user defined types B_USERTYPES in password protected macros |
| 40 |
// Version 13: tdf#94617 store methods nStart information greater than sal_Int16 limit |
| 41 |
// tdf#57113 store UTF-16 strings after legacy 1-byte-encoded strings in pool (no |
| 42 |
// version number bump for backward compatibility; relies on magic number) |
| 43 |
// tdf#142460: properly handle boolean values in string pool (no |
| 44 |
// version number bump for backward compatibility; relies on |
| 45 |
// new integer type suffix 'b') |
| 46 |
// tdf#168569: support date values in string pool (no version number bump |
| 47 |
// for backward compatibility; relies on new type suffix 'd') |
| 48 |
// |
| 49 |
|
| 50 |
#define B_IMG_VERSION_12 0x00000012 |
| 51 |
#define B_IMG_VERSION_13 0x00000013 |
| 52 |
|
| 53 |
// The file contains either a module- or a library-record. |
| 54 |
// Those records contain further records. Every record's got |
| 55 |
// the following header: |
| 56 |
|
| 57 |
// sal_uInt16 identifier |
| 58 |
// sal_uInt32 the record's length without the header |
| 59 |
// sal_uInt16 number of sub-elements |
| 60 |
|
| 61 |
// all the file-offsets in records are relative to the module's start! |
| 62 |
|
| 63 |
enum class FileOffset { |
| 64 |
Library = 0x4C42, // BL Library Record |
| 65 |
Module = 0x4D42, // BM Module Record |
| 66 |
Name = 0x4E4D, // MN module name |
| 67 |
Comment = 0x434D, // MC comment |
| 68 |
Source = 0x4353, // SC source code |
| 69 |
PCode = 0x4350, // PC p-code |
| 70 |
OldPublics = 0x7550, // Pu publics |
| 71 |
Publics = 0x5550, // PU publics |
| 72 |
PoolDir = 0x4450, // PD symbol pool directory |
| 73 |
SymPool = 0x5953, // SY symbol pool |
| 74 |
StringPool = 0x5453, // ST symbol pool |
| 75 |
LineRanges = 0x524C, // LR line ranges for publics |
| 76 |
ModEnd = 0x454D, // ME module end |
| 77 |
SbxObjects = 0x5853, // SX SBX objects |
| 78 |
ExtSource = 0x5345, // ES extended source |
| 79 |
UserTypes = 0x4369, // UT user defined types |
| 80 |
|
| 81 |
LastValue = UserTypes |
| 82 |
}; |
| 83 |
|
| 84 |
|
| 85 |
// A library record contains only module records |
| 86 |
// sal_uInt16 identifier BL |
| 87 |
// sal_uInt32 the record's length |
| 88 |
// sal_uInt16 number of modules |
| 89 |
|
| 90 |
// A module-record contains all the other record types |
| 91 |
// sal_uInt16 identifier BM |
| 92 |
// sal_uInt32 the record's length |
| 93 |
// sal_uInt16 1 |
| 94 |
// Data: |
| 95 |
// sal_uInt32 version number |
| 96 |
// sal_uInt32 character set |
| 97 |
// sal_uInt32 starting address initialisation code |
| 98 |
// sal_uInt32 starting address sub main |
| 99 |
// sal_uInt32 reserved |
| 100 |
// sal_uInt32 reserved |
| 101 |
|
| 102 |
// module name, comment and source code: |
| 103 |
// sal_uInt16 identifier MN, MC or SC |
| 104 |
// sal_uInt32 the record's length |
| 105 |
// sal_uInt16 1 |
| 106 |
// Data: |
| 107 |
// string instance |
| 108 |
|
| 109 |
// P-Code: |
| 110 |
// sal_uInt16 identifier PC |
| 111 |
// sal_uInt32 the record's length |
| 112 |
// sal_uInt16 1 |
| 113 |
// Data: |
| 114 |
// the P-Code as bytesack |
| 115 |
|
| 116 |
// All symbols and strings are kept in a string-pool. |
| 117 |
// References to these strings are in this pool in the form of an index. |
| 118 |
|
| 119 |
// List of all publics: |
| 120 |
// sal_uInt16 identifier PU or Pu |
| 121 |
// sal_uInt32 the record's length |
| 122 |
// sal_uInt16 number of publics |
| 123 |
// Data for every public-entry: |
| 124 |
// sal_uInt16 string index |
| 125 |
// sal_uInt32 starting address in the p-code-image (sal_uInt16 for old publics) |
| 126 |
// sal_uInt16 data type of the return value (from version 2) |
| 127 |
|
| 128 |
// Register of the symbol tables: |
| 129 |
// sal_uInt16 identifier SP |
| 130 |
// sal_uInt32 the record's length |
| 131 |
// sal_uInt16 number of symbol tables |
| 132 |
// Data for every symbol table: |
| 133 |
// sal_uInt16 stringindex of the name |
| 134 |
// sal_uInt16 number of symbols |
| 135 |
// sal_uInt16 scope identifier |
| 136 |
|
| 137 |
// symbol table: |
| 138 |
// sal_uInt16 identifier SY |
| 139 |
// sal_uInt32 the record's length |
| 140 |
// sal_uInt16 number of symbols |
| 141 |
// Data: |
| 142 |
// sal_uInt16 stringindex of the name |
| 143 |
// sal_uInt16 number of symbols |
| 144 |
// Data for every symbol: |
| 145 |
// sal_uInt16 stringindex of the name |
| 146 |
// sal_uInt16 data type |
| 147 |
// sal_uInt16 length for STRING*n-symbols (0x8000: STATIC variable) |
| 148 |
|
| 149 |
// Stringpool: |
| 150 |
// sal_uInt16 identifier ST |
| 151 |
// sal_uInt32 the record's length |
| 152 |
// sal_uInt16 number of strings |
| 153 |
// Data for every string: |
| 154 |
// sal_uInt32 Offset in the block of all strings |
| 155 |
// the block of all strings (ASCIIZ) follows then |
| 156 |
|
| 157 |
// line ranges: |
| 158 |
// sal_uInt16 identifier LR |
| 159 |
// sal_uInt32 the record's length |
| 160 |
// sal_uInt16 number of strings |
| 161 |
// Data for every public: |
| 162 |
// sal_uInt16 1st line (Sub XXX) |
| 163 |
// sal_uInt16 2nd line (End Sub) |
| 164 |
|
| 165 |
// SBX-objects: |
| 166 |
// sal_uInt16 number of objects |
| 167 |
// ... object data |
| 168 |
|
| 169 |
// user defined types B_USERTYPES : |
| 170 |
// sal_uInt16 identifier UT |
| 171 |
// sal_uInt32 the record's length |
| 172 |
// sal_uInt16 number of types |
| 173 |
// Data for every user defined type: |
| 174 |
// string instance type name |
| 175 |
// sal_Int16 number of type members |
| 176 |
// Data for every type member: |
| 177 |
// string name |
| 178 |
// sal_Int16 type |
| 179 |
// sal_uInt32 flags |
| 180 |
// sal_Int16 hasObjects (0/1) |
| 181 |
// If hasObjects |
| 182 |
// If member type is nested type |
| 183 |
// string nested type name |
| 184 |
// Else (array declaration) |
| 185 |
// sal_Int16 isFixedSize (0/1) |
| 186 |
// sal_Int32 number of dimensions |
| 187 |
// Data for every dimension: |
| 188 |
// sal_Int32 lower bound |
| 189 |
// sal_Int32 upper bound |
| 190 |
|
| 191 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |