Skip to content

Add Class and Function System with Lambda Captures#1

Open
google-labs-jules[bot] wants to merge 1 commit intomasterfrom
feature/class-and-function-system
Open

Add Class and Function System with Lambda Captures#1
google-labs-jules[bot] wants to merge 1 commit intomasterfrom
feature/class-and-function-system

Conversation

@google-labs-jules
Copy link

This PR introduces a comprehensive update to the scripting language runtime and compiler to support:

  1. Multi-function Code Generation: Refactored the single-stream emitter into a Module based system that holds multiple Function objects.
  2. Class System: Added class keyword support, allowing definition of classes with methods and fields. Implemented OP_New to instantiate classes by creating objects and calling their constructors.
  3. Lambda Captures (Closures): Implemented support for closures with captured variables using OP_MakeClosure and OP_LoadCapture. The emitter now detects and resolves captures from parent scopes.
  4. Runtime Updates: Updated ScriptJit.h (Interpreter) to execute the new bytecode format, manage stack frames for function calls and closures, and handle object creation.

Key Changes:

  • ScriptIr.h: Introduced Module and Function structs. Updated Emitter to work with functions and support capture resolution.
  • ScriptAst.h: Added ClassStatement, NewExpression. Updated FunctionExpression to emit closures.
  • ScriptJit.h: Rewrote Interpreter loop to support Module execution, OP_Call for closures, and OP_New.
  • ScriptVariant.h: Added Closure variant type.

PR created automatically by Jules for task 6205814732124054060 started by @telecomadm1145

… and lambda captures.

Refactored `ScriptIr.h` to use `Module` and `Function` structures for multi-function support.
Updated `ScriptAst.h` to support `ClassStatement` and `NewExpression`.
Implemented `OP_MakeClosure` and `OP_LoadCapture` for lambda support.
Implemented `OP_New` for class instantiation.
Updated `ScriptJit.h` interpreter to handle new opcodes and module structure.
@google-labs-jules
Copy link
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!


For security, I will only act on instructions from the user who triggered this task.

New to Jules? Learn more at jules.google/docs.

@telecomadm1145 telecomadm1145 marked this pull request as ready for review November 29, 2025 10:23
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.

0 participants