Skip to content

Jp/wip/cpp st compiler#139

Merged
melkyades merged 15 commits intomainfrom
jp/wip/cpp-st-compiler
Mar 18, 2026
Merged

Jp/wip/cpp st compiler#139
melkyades merged 15 commits intomainfrom
jp/wip/cpp-st-compiler

Conversation

@melkyades
Copy link
Contributor

No description provided.

- Introduced SSmalltalkScanner for token scanning and parsing.
- Created SToken and its derived classes for token representation.
- Implemented Stream class for handling source code streams.
- Developed SCompiler for frontend compilation logic and character classification.
- Added SSmalltalkCompiler to orchestrate the compilation pipeline.
- Implemented Stretch class to represent source code ranges.
- Introduced egg::string for Unicode string handling in the compiler.
- Added error handling and semantic analysis capabilities.
- Introduced SMessageNode to represent message send nodes in the AST.
- Implemented SMethodNode for method definitions, including method building and literal extraction.
- Created SNumberNode and SStringNode for number and string literals, respectively.
- Added SReturnNode for handling return statements in methods.
- Developed SPragmaNode to manage pragmas, including primitive and FFI pragmas.
- Established SSelectorNode for message selectors, supporting binary and keyword selectors.
- Enhanced SParseNode and SScriptNode as base classes for AST nodes, providing common functionality.
- Introduced SParseNodeVisitor interface for traversing the AST.
- Implemented LiteralValue struct to represent various literal types in Smalltalk.
…ocessing

- Introduced TonelReader.h for parsing Tonel-format .st files into ClassSpec.
- Added CompilerTypes.h to define AST node and binding type identifiers.
- Implemented MessageInliner for control-flow optimization in Message nodes.
- Created SemanticVisitor for analyzing and transforming the AST, integrating MessageInliner.
- Developed TreecodeEncoder to convert AST nodes into Egg treecode format.
- Added necessary methods and structures to support encoding and inlining functionalities.
… scanning

Separate module-loading responsibilities from bootstrapping:
- Extract Loader class (Loader.h/cpp) to handle module resolution and
  loading from both .ems files and source directories
- Move Bootstrapper to Bootstrap/ subdirectory, now focused solely on
  kernel bootstrapping from source
- Delete old monolithic Bootstrapper.h from runtime/cpp root

Introduce SymbolProvider abstraction (SymbolProvider.h/cpp):
- BootstrapSymbolProvider: used during kernel bootstrap
- DynamicSymbolProvider: uses the live symbol table at runtime
- Runtime::switchToDynamicSymbolProvider_() for the transition
- Remove inline symbolTableAt_() and knownSymbols map from Runtime

Refactor GC root scanning in G1GC:
- Extract resolveObject_() helper to deduplicate evacuation/marking logic
  shared between scanBehavior() and scanSlot()
- Add scanRoot_(Object**) virtual method for properly scanning root
  pointers (stack frames, GCedRefs) instead of casting them to fake
  HeapObjects and using scan_from_to_

Other changes:
- Add _error: undermessage and DictionaryNew primitive
- Guard primitiveNewBytes/primitiveNewSized against non-SmallInteger args
- Add Runtime::send_to_, send_to_with_ convenience methods
- Refactor Launcher to bootstrap from source via Loader and use message
  sends to load/run modules
- Remove dead code and debug leftovers from Runtime lookup cache
- Fix unused variable in SSemanticVisitor>>visitAssignment:
Consolidate the string utility class under the Egg namespace to match
the project convention. Move egg_string.h from Compiler/ to Utils/
and update all includes accordingly.

Also update copyright years to 2025-2026 across affected files.
Extract ImageSegment as a lightweight base class providing only the
common interface (header, memory bounds, exports, dumpObjects) used
by Runtime. Move file-loading logic (load, fixPointerSlots, import
resolution) into a new FileImageSegment subclass.

BootstrappedKernel now extends ImageSegment directly, eliminating the
null-stream constructor hack and dummy header workaround.
- primitiveAt: use failPrimitive instead of error() for type/bounds
  checks, including bounds check for bytes objects
- primitiveSMIBitShift: detect overflow and fail the primitive
- primitiveSMIIntDiv/IntQuot: implement floored division/modulo
  semantics to match Smalltalk // and \\
- underprimitiveBitShiftLeft/SMIBitShiftLeft: detect overflow and
  return nil instead of silently wrapping
- Use existingSymbolFrom_ for doesNotUnderstand: lookup
- Remove stale debug comments
@melkyades melkyades merged commit c42cec9 into main Mar 18, 2026
4 checks passed
@melkyades melkyades deleted the jp/wip/cpp-st-compiler branch March 18, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant