Skip to content

Migration/runtime package#13

Merged
jpksh90 merged 11 commits into
mainfrom
migration/runtime-package
Nov 9, 2025
Merged

Migration/runtime package#13
jpksh90 merged 11 commits into
mainfrom
migration/runtime-package

Conversation

@jpksh90

@jpksh90 jpksh90 commented Nov 9, 2025

Copy link
Copy Markdown
Owner

Refactored the whole code base.

Copilot AI review requested due to automatic review settings November 9, 2025 14:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the compiler architecture by introducing a new HLIR (High-Level Intermediate Representation) system with functional error handling using Result types. The old slang.slast package is replaced with slang.hlir, the interpreter is moved to a dedicated slang.runtime package, and a Transform-based pipeline is introduced for composable compiler phases.

Key Changes:

  • Introduced Result/Transform types for functional error handling and composable compiler pipelines
  • Migrated AST definitions from slang.slast to slang.hlir with renamed types (CompilationUnit → ProgramUnit)
  • Extracted interpreter logic into slang.runtime package with separate Value, State, and ControlFlow types
  • Renamed packages: slang.visualizer → slang.ui, Error → CompilerError

Reviewed Changes

Copilot reviewed 30 out of 54 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/kotlin/util/Util.kt New utility defining Result type and Transform interface for functional composition
src/main/kotlin/slang/runtime/* New runtime package with Interpreter, Value types, State, and ControlFlow
src/main/kotlin/slang/parser/Parser.kt New parser classes with Transform interface implementation
src/main/kotlin/slang/hlir/Ast.kt Renamed AST definitions (CompilationUnit → ProgramUnit, moved from slang.slast)
src/main/kotlin/slang/hlir/AstBuilder.kt Updated AST builder with new type names and helper functions
src/main/kotlin/slang/common/CodeInfo.kt New source location tracking (replaces LineColumn/SourceCodeInfo)
src/test/kotlin/*Tests.kt Updated tests to use new HLIR API and Result types
src/main/kotlin/slang/ui/*.kt Package rename from slang.visualizer to slang.ui
src/main/kotlin/slang/repl/Repl.kt Simplified REPL using new Transform pipeline
src/main/kotlin/Main.kt Updated to use new parser API (renamed class SlangcCLI → SlangCLI)
Files not reviewed (16)
  • .idea/.gitignore: Language not supported
  • .idea/.name: Language not supported
  • .idea/ANTLRv4ToolGrammarProperties.xml: Language not supported
  • .idea/codeStyles/Project.xml: Language not supported
  • .idea/codeStyles/codeStyleConfig.xml: Language not supported
  • .idea/copilot.data.migration.agent.xml: Language not supported
  • .idea/copilot.data.migration.ask.xml: Language not supported
  • .idea/copilot.data.migration.ask2agent.xml: Language not supported
  • .idea/copilot.data.migration.edit.xml: Language not supported
  • .idea/google-java-format.xml: Language not supported
  • .idea/gradle.xml: Language not supported
  • .idea/kotlinc.xml: Language not supported
  • .idea/misc.xml: Language not supported
  • .idea/sonarlint.xml: Language not supported
  • .idea/uiDesigner.xml: Language not supported
  • .idea/vcs.xml: Language not supported
Comments suppressed due to low confidence (2)

src/main/kotlin/slang/hlir/AstBuilder.kt:351

  • Misspelled class name 'ParseTree2HlirTrasnformer' should be 'ParseTree2HlirTransformer' (missing 'n' in 'Transformer').
    src/main/kotlin/slang/ui/AstVisualizer.kt:30
  • Missing space before function call 'string2hlir' - should be 'val ast = string2hlir(input)'.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/kotlin/util/Util.kt Outdated
/**
* Compose two transforms: first apply `this`, if it yields Ok then apply [next], otherwise propagate Err.
*/
fun <A, B, C> Transform<A, B,>.andThen(next: Transform<B, C>): Transform<A, C> = Transform { input ->

Copilot AI Nov 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra comma after type parameter 'B' should be removed.

Copilot uses AI. Check for mistakes.
Comment on lines +342 to +344
is ControlFlow.Normal -> when (flow) {
else -> flow.value
}

Copilot AI Nov 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant when expression with only 'else' branch. Should directly access 'flow.value' without the when block.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread src/test/java/Test.java Outdated
@@ -0,0 +1,5 @@
class Test {

Copilot AI Nov 9, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused class: Test is not referenced within this codebase. If not used as an external API it should be removed.

Copilot uses AI. Check for mistakes.

Copilot AI commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

@jpksh90 I've opened a new pull request, #14, to work on those changes. Once the pull request is ready, I'll request review from you.

- Introduce  with Value, State, ControlFlow, RuntimeUtils, Interpreter\n- Replace monolithic REPL/interpreter with thin  and compatibility  wrapper\n- Update compilation rule discovery to use \n- Fix AST builder/visitor issues and small bugs discovered during migration\n\nThis migration centralizes runtime concepts and simplifies future refactors.
@jpksh90 jpksh90 force-pushed the migration/runtime-package branch from 4b17cfe to 368d5df Compare November 9, 2025 14:52
@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2025

Copy link
Copy Markdown

@jpksh90

jpksh90 commented Nov 9, 2025

Copy link
Copy Markdown
Owner Author

@copilot Review this PR and suggest what can I improve?

Copilot AI commented Nov 9, 2025

Copy link
Copy Markdown
Contributor

@jpksh90 I've opened a new pull request, #15, to work on those changes. Once the pull request is ready, I'll request review from you.

@jpksh90 jpksh90 self-assigned this Nov 9, 2025
@jpksh90 jpksh90 merged commit 1592a56 into main Nov 9, 2025
1 of 3 checks passed
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.

3 participants