AssemblyCraftCompiler 1.2.0__tar.gz → 2.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AssemblyCraftCompiler
3
- Version: 1.2.0
3
+ Version: 2.0.1
4
4
  Summary: The official Assembly Craft compiler
5
5
  Author-email: Orbinuity <orbinuity@ratgers.nl>
6
6
  License-Expression: BSD-3-Clause
@@ -18,7 +18,7 @@ Dynamic: license-file
18
18
 
19
19
  [![License](https://img.shields.io/github/license/Orbinuity/ASMCC)](https://orbinuity.nl/license)
20
20
  [![Last Commit](https://img.shields.io/github/last-commit/Orbinuity/ASMCC)](https://github.com/Orbinuity/ASMCC/commits)
21
- [![Version](https://img.shields.io/badge/Version-1.2.0-orange)](https://github.com/Orbinuity/ASMCC/releases/v1.2.0)
21
+ [![Version](https://img.shields.io/badge/Version-2.0.1-orange)](https://github.com/Orbinuity/ASMCC/releases/v2.0.1)
22
22
  [![Made By](https://img.shields.io/badge/Made%20by-Orbinuity-teal)](https://orbinuity.nl/)
23
23
  [![Read the docs](https://img.shields.io/badge/Read%20the%20docs-red)](https://help.orbinuity.nl/doc?project=ASMCC)
24
24
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AssemblyCraftCompiler
3
- Version: 1.2.0
3
+ Version: 2.0.1
4
4
  Summary: The official Assembly Craft compiler
5
5
  Author-email: Orbinuity <orbinuity@ratgers.nl>
6
6
  License-Expression: BSD-3-Clause
@@ -18,7 +18,7 @@ Dynamic: license-file
18
18
 
19
19
  [![License](https://img.shields.io/github/license/Orbinuity/ASMCC)](https://orbinuity.nl/license)
20
20
  [![Last Commit](https://img.shields.io/github/last-commit/Orbinuity/ASMCC)](https://github.com/Orbinuity/ASMCC/commits)
21
- [![Version](https://img.shields.io/badge/Version-1.2.0-orange)](https://github.com/Orbinuity/ASMCC/releases/v1.2.0)
21
+ [![Version](https://img.shields.io/badge/Version-2.0.1-orange)](https://github.com/Orbinuity/ASMCC/releases/v2.0.1)
22
22
  [![Made By](https://img.shields.io/badge/Made%20by-Orbinuity-teal)](https://orbinuity.nl/)
23
23
  [![Read the docs](https://img.shields.io/badge/Read%20the%20docs-red)](https://help.orbinuity.nl/doc?project=ASMCC)
24
24
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![License](https://img.shields.io/github/license/Orbinuity/ASMCC)](https://orbinuity.nl/license)
4
4
  [![Last Commit](https://img.shields.io/github/last-commit/Orbinuity/ASMCC)](https://github.com/Orbinuity/ASMCC/commits)
5
- [![Version](https://img.shields.io/badge/Version-1.2.0-orange)](https://github.com/Orbinuity/ASMCC/releases/v1.2.0)
5
+ [![Version](https://img.shields.io/badge/Version-2.0.1-orange)](https://github.com/Orbinuity/ASMCC/releases/v2.0.1)
6
6
  [![Made By](https://img.shields.io/badge/Made%20by-Orbinuity-teal)](https://orbinuity.nl/)
7
7
  [![Read the docs](https://img.shields.io/badge/Read%20the%20docs-red)](https://help.orbinuity.nl/doc?project=ASMCC)
8
8
 
@@ -1,4 +1,4 @@
1
- __version__ = "1.2.0"
1
+ __version__ = "2.0.1"
2
2
  import struct
3
3
  import re
4
4
 
@@ -6,7 +6,7 @@ class AssemblyCraftCompilerError(Exception):
6
6
  pass
7
7
 
8
8
  class AssemblyCraftCompiler:
9
- MAGIC_HEADER = (b"ACX"+__version__.split(".")[0].encode())
9
+ MAGIC_HEADER = (b"ACX" + __version__.split(".")[0].encode())
10
10
 
11
11
  ALLOC_SIZES = {
12
12
  'ds': 16,
@@ -114,7 +114,22 @@ class AssemblyCraftCompiler:
114
114
  f"Line {line_num}: Duplicate variable definition '{var_name}'."
115
115
  )
116
116
 
117
- alloc_len = self.ALLOC_SIZES[size_type]
117
+ # Check if values_str is a single integer specifying buffer allocation size (e.g. 'disk_buffer dm 512')
118
+ single_num_match = re.fullmatch(r'^(\d+|0x[0-9a-fA-F]+)$', values_str.strip())
119
+ if single_num_match:
120
+ val = int(single_num_match.group(1), 0)
121
+ if size_type == 'dm' or val > 255:
122
+ alloc_len = val
123
+ padded_data = bytes(alloc_len)
124
+ self.variables[var_name] = {
125
+ 'id': var_id,
126
+ 'size_type': size_type,
127
+ 'alloc_len': alloc_len,
128
+ 'data': padded_data
129
+ }
130
+ var_id += 1
131
+ continue
132
+
118
133
  raw_bytes = bytearray()
119
134
  tokens = re.findall(r'"([^"]*)"|(\d+|0x[0-9a-fA-F]+)', values_str)
120
135
 
@@ -134,18 +149,19 @@ class AssemblyCraftCompiler:
134
149
  ) from e
135
150
  elif num_val:
136
151
  val = int(num_val, 0)
137
- if not (0 <= val <= 255):
138
- raise AssemblyCraftCompilerError(
139
- f"Line {line_num}: Byte literal {val} out of range (0-255) in '{var_name}'."
140
- )
141
- raw_bytes.append(val)
142
-
143
- if len(raw_bytes) > alloc_len:
144
- raise AssemblyCraftCompilerError(
145
- f"Line {line_num}: Initializer size ({len(raw_bytes)} bytes) exceeds allocated "
146
- f"capacity for '{size_type}' ({alloc_len} bytes) in variable '{var_name}'."
147
- )
148
-
152
+ if size_type == 'db':
153
+ if not (0 <= val <= 255):
154
+ raise AssemblyCraftCompilerError(
155
+ f"Line {line_num}: Byte literal {val} out of range (0-255) in '{var_name}'."
156
+ )
157
+ raw_bytes.append(val)
158
+ elif size_type == 'ds':
159
+ raw_bytes.extend(struct.pack("<H", val & 0xFFFF))
160
+ elif size_type == 'dm':
161
+ raw_bytes.extend(struct.pack("<I", val & 0xFFFFFFFF))
162
+
163
+ min_alloc = self.ALLOC_SIZES[size_type]
164
+ alloc_len = max(len(raw_bytes), min_alloc)
149
165
  padded_data = bytes(raw_bytes).ljust(alloc_len, b'\x00')
150
166
 
151
167
  self.variables[var_name] = {
@@ -223,7 +239,7 @@ class AssemblyCraftCompiler:
223
239
  key_table = bytearray()
224
240
  data_payload = bytearray()
225
241
 
226
- base_offset = 10 + (len(self.variables) * 22)
242
+ base_offset = 10 + (len(self.variables) * 25)
227
243
  current_data_offset = base_offset
228
244
 
229
245
  for var_name, info in self.variables.items():
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "AssemblyCraftCompiler"
7
- version = "1.2.0"
7
+ version = "2.0.1"
8
8
  authors = [
9
9
  { name="Orbinuity", email="orbinuity@ratgers.nl" },
10
10
  ]