Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Releases: CodeNothingCommunity/CodeNothing-Zero

v0.9.5

17 Aug 17:17

Choose a tag to compare

[v0.9.5] - 2025-08-18

Memoization Cache System

  • Implement complete memoization cache function, support automatic caching and reuse of function call results
  • Added memo { }; syntax block to support memoized function declarations globally, in namespaces, and within classes
  • Support memoization optimization of global functions, instance methods, and static methods

Performance Optimization

  • Added a tail recursion optimization module to automatically detect and optimize tail recursive function calls
  • Numeric type enhancement: Int overflow is automatically converted to Long type, and mixed type operations are supported
  • Virtual machine instruction-level optimization: multiple new bytecode instructions, including instruction fusion and constant comparison optimization
  • Added support for Long literal syntax (123L) to improve the accuracy of numerical parsing

OOP function improvement

  • Complete inheritance and polymorphism support, implementing inheritance chain method search mechanism
  • Added access permission control: Public, Protected, Private access levels
  • Improve constructor and static method support, and improve this/super context management
  • Added multiple OOP-related bytecode instructions to support complete object-oriented programming

Debugging and Monitoring

  • Added modular debugging system: independent options such as parser debugging and tail recursion debugging
  • New performance statistics features: memoized cache statistics, tail recursion optimization report
  • New command line options: --cn-memo-stats, --cn-tail-stats, --cn-no-memo
  • Added debug macro support, providing detailed execution tracing and performance analysis

Architecture Improvements

  • Parser enhancement: support for memo syntax parsing, improved numerical literal recognition
  • Virtual machine reconstruction: transparent integration of memoized cache and complete OOP instruction execution
  • Compiler optimization: automatic memoization of registers, tail call optimization detection, instruction fusion optimization
  • Added 2 core modules: memoization.rs, tail_recursion.rs

[v0.9.5] - 2025-08-18

记忆化缓存系统

  • 实现完整的记忆化缓存功能,支持函数调用结果的自动缓存和复用
  • 新增 memo { }; 语法块,支持全局、命名空间、类内部的记忆化函数声明
  • 支持全局函数、实例方法、静态方法的记忆化优化

性能优化

  • 新增尾递归优化模块,自动检测和优化尾递归函数调用
  • 数值类型增强:Int溢出自动转换为Long类型,支持混合类型运算
  • 虚拟机指令级优化:新增多条字节码指令,包括指令融合和常量比较优化
  • 新增Long字面量语法支持(123L),改进数值解析准确性

OOP功能完善

  • 完整的继承和多态支持,实现继承链方法查找机制
  • 新增访问权限控制:Public、Protected、Private访问级别
  • 完善构造函数和静态方法支持,改进this/super上下文管理
  • 新增多条OOP相关字节码指令,支持完整的面向对象编程

调试和监控

  • 新增模块化调试系统:解析器调试、尾递归调试等独立选项
  • 新增性能统计功能:记忆化缓存统计、尾递归优化报告
  • 新增命令行选项:--cn-memo-stats--cn-tail-stats--cn-no-memo
  • 新增调试宏支持,提供详细的执行跟踪和性能分析

架构改进

  • 解析器增强:支持memo语法解析、改进数值字面量识别
  • 虚拟机重构:记忆化缓存透明集成、完整OOP指令执行
  • 编译器优化:自动记忆化注册、尾调用优化检测、指令融合优化
  • 新增2个核心模块:memoization.rs、tail_recursion.rs

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.4...v0.9.5

v0.9.4 Pre5

16 Aug 12:48

Choose a tag to compare

[v0.9.4 Pre5] - 2025-08-16

VM debugging information control system

Debug parameter refactoring

  • New parameter: --cn-vm-tip specifically controls detailed debugging information of the VM execution process
  • Information separation: Separate VM debug information from the default output to provide a cleaner user experience
  • Precise Control: Users can selectively view the internal execution details of the VM

VM structure enhancement

  • New field: tip_mode: bool controls the display of VM debug information
  • New method: set_tip_mode() dynamically set the debug mode
  • Parameter passing: Correctly pass tip parameter to VM in execute_with_vm function

Major repair of VM condition judgment system

Core Problem Diagnosis

  • Problem found: The VM compiler has a serious bug when processing else if statements
  • Specific performance: Only process the first else branch, completely ignoring the conditional judgment of else if
  • Affected Scope: All recursive functions cannot be executed correctly in VM mode

Compiler fixes (src/vm/compiler.rs)

  • Issue before fix:
// Simplified handling of errors, only taking the first else branch
if let Some((_, else_body)) = else_branches.first() {
for stmt in else_body {
self.compile_statement(stmt)?;
}
}
  • Fixed logic:
// Correctly handle all else if and else branches
for (maybe_condition, else_body) in else_branches {
match maybe_condition {
Some(else_if_condition) => {
// Compile else if condition and branch body
self.compile_expression(else_if_condition)?;
// Generate the correct conditional jump instruction
},
None => {
// Process the final else branch
}
}
}

Improve the conditional jump logic

  • Jump address calculation: Correctly calculate the jump target address of each else if branch
  • Branch chain processing: Implement complete if-else if-else branch chain compilation
  • Unify the end jump: After all branches are executed, jump to the end of the if statement

Recursive function execution fix

Root cause analysis

  • Symptom: repeat_string("Ha", 3) returns "Ha" instead of "HaHaHa" in VM mode
  • Root cause: When times > 1, the VM mistakenly enters the times == 1 branch and returns directly without recursion
  • Impact: All recursive functions containing else if conditional judgments will not work properly

Fix verification

  • Test results before repair:
debug_repeat_simple(2) = case2 ❌ (should be case3)
debug_repeat_simple(3) = case2 ❌ (should be case3)
  • Test results after repair:
debug_repeat_simple(2) = case3 ✅ (correct)
debug_repeat_simple(3) = case3 ✅ (correct)

Functional integrity restored

  • Mathematical function: factorial(5) = 120
  • String function: repeat_string("Ha", 3) = "HaHaHa"
  • Combined call: repeat_string("*", add(3, 2)) = "*****"

Debug information hierarchical display

Default VM mode (--cn-vm)

  • Compilation Information: Displays function index allocation and compilation process
  • Hide execution details: Do not display detailed information about each function call and return
  • Clean output: Focus on program execution results

Verbose debugging mode (--cn-vm --cn-vm-tip)

  • Full execution trace: Shows the parameters and return values of each function call
  • Stack status monitoring: displays the changes in the VM stack
  • Instruction level debugging: shows the execution of each bytecode instruction

Technical implementation details

VM debugging control implementation

// VM structure enhancement
pub struct VM {
// ... other fields
tip_mode: bool, // Add debug mode control
}

impl VM {
pub fn set_tip_mode(&mut self, tip_mode: bool) {
self.tip_mode = tip_mode;
}

// Use tip_mode to control output at key execution points
if self.tip_mode {
println!("🔍 VM: Execute function call {} (index {}) number of parameters {}",
function_name, func_index, arg_count);
}
}

Conditional compilation fix implementation

//Fixed else if processing logic
let mut end_jumps = vec![end_jump_addr];

for (maybe_condition, else_body) in else_branches {
match maybe_condition {
Some(else_if_condition) => {
// Compile else if condition
self.compile_expression(else_if_condition)?;

// If the condition is false, jump to the next else if/else
self.emit(ByteCode::JumpIfFalse(0));
let next_else_jump = self.bytecode.len() - 1;

// Compile the else if branch
for stmt in else_body {
self.compile_statement(stmt)?;
}

// Jump to the end of the if statement
self.emit(ByteCode::Jump(0));
end_jumps.push(self.bytecode.len() - 1);

// Backfill the address of the next branch
let next_else_addr = self.bytecode.len() as u32;
if let ByteCode::JumpIfFalse(_) = &mut self.bytecode[next_else_jump] {
self.bytecode[next_else_jump] = ByteCode::JumpIfFalse(next_else_addr);
}
},
None => {
// Final else branch
for stmt in else_body {
self.compile_statement(stmt)?;
}
}
}
}

Key issues fixed

VM condition judgment system defects

  • Issue: VM compiler does not correctly handle else if statement chains
  • Impact: All functions containing complex conditional judgments cannot be executed correctly in VM mode
  • Fix: Implemented complete conditional branch compilation and jump logic

Recursive function execution failed

  • Problem: Recursive function terminates prematurely in VM mode without making recursive calls
  • Root cause: Incorrect conditional judgment causes the recursive termination condition to be mistakenly triggered
  • Fix: After fixing conditional compilation, recursive functions resume normal execution

Debug information is confusing

  • Issue: VM debugging information is mixed with program output, affecting user experience
  • Fix: Use --cn-vm-tip parameter to precisely control the display of debug information

Architecture Improvement Results

Improved VM execution reliability

  • Conditional Judgment: VM can now correctly handle complex conditional branch structures
  • Recursion support: Full support for compiling and executing recursive functions
  • Functional parity: VM mode and interpreter mode have exactly the same functionality

User experience optimization

  • Clean output: In default mode, only program results are displayed without redundant debugging information
  • Optional debugging: Control the display level of debugging information through parameters
  • Consistency: The output behavior of VM mode and interpreter mode is unified

Development and debugging convenience

  • Leveled debugging: Provides different levels of debugging information
  • Precise control: Developers can selectively view the internal state of the VM
  • Problem diagnosis: Detailed execution traces help locate problems

Test verification and improvement

Conditional judgment test

  • Simple Conditionals: Correct execution of if-else statements
  • Complex branching: Complete testing of if-else if-else chains
  • Nested conditions: Verification of multi-layer nested conditional statements

Recursive function test

  • Mathematical Recursion: Correct calculation of the factorial function
  • String Recursion: Correct implementation of string repetition functions
  • Combined call: Combination of recursive functions with other functions

VM debugging function test

  • Default mode: Verify correct hiding of debug information
  • Debug mode: Full display of verification details
  • Parameter combination: Correctness of using multiple parameter combinations

Forward compatibility guaranteed

Existing code compatibility

  • Syntax compatibility: All existing conditional statement syntaxes are fully compatible
  • Behavior consistency: The fixed VM behavior is completely consistent with the interpreter
  • Performance Improvement: Fixes while maintaining VM performance advantages

Debug interface stable

  • Parameter stability: --cn-vm-tip parameter interface remains stable
  • Output format: debug information format is forward compatible
  • Extensibility: Reserve space for future debugging function expansion

Repair verification completed

Final test results

  • VM debug information control: --cn-vm-tip parameter fully controls the debug information display✅
  • Conditional judgment fix: else if statement is executed correctly in VM mode✅
  • Recursive function recovery: All recursive functions work properly in VM mode✅
  • Functional equivalence: VM mode is fully consistent with interpreter mode✅

Test case verification

=== Complex Bytecode Testing ===
Mathematical function test:
add(10, 20) = 30 ✅
multiply(6, 7) = 42 ✅
factorial(5) = 120 ✅

String function test:
concat_with_separator('Hello', 'World', ' ') = Hello World ✅
repeat_string('Ha', 3) = HaHaHa ✅ (before fix: Ha)

Combined test:
repeat_string('*', add(3, 2)) = ***** ✅ (Before fix: *)
=== Testing Completed ===

Key repair points

  1. Compiler debug output control: All compiler debug information is now controlled using the show_tips field
  2. Conditional branch compilation logic: Completely rewrite the bytecode generation logic of else if statements
  3. Jump address calculation: Fixed the address calculation error of conditional jump and branch jump
  4. Recursive call recovery: After repair, recursive functions can correctly make multi-layer recursive calls

This fix resolves a core flaw in the VM system and ensures the full functionality and reliability of CodeNothing in VM mode.

[v0.9.4 Pre5] - 2025-08-16

VM调试信息控制系统

调试参数...

Read more

v0.9.4 Pre4

16 Aug 11:27

Choose a tag to compare

[v0.9.4 Pre4] - 2025-08-16

Enhanced Bytecode Compilation and Execution System

Bytecode File Compilation Feature (--cn-vm-build)

  • New Compilation Parameter: --cn-vm-build now supports compiling .cn source files into .comcn bytecode files
  • Complete compilation process: Source code parsing → AST generation → Bytecode compilation → Serialization storage
  • Library dependency recording: Automatically records library dependency information during compilation to ensure correct loading at runtime
  • Metadata preservation: Saves metadata such as compilation time, version information, and source file paths
  • Error handling: Provides detailed compilation error information and diagnostic hints

Bytecode File Execution System

  • Automatic Identification: Automatically detects the .comcn file format, no additional parameters required
  • VM Mode Execution: Executes bytecode using an efficient virtual machine to enhance runtime performance
  • Library Dependency Reloading: Automatically reloads library dependencies recorded at compile time at runtime
  • Full Compatibility: Supports all existing command-line parameters and features

Bytecode Execution Parameter Support

  • Time Measurement: The --cn-time parameter now fully supports bytecode execution mode
  • VM Debug Information: The --cn-vm-tip controls detailed display of VM execution process information
  • Return Value Display: --cn-return supports displaying the execution results of bytecode programs
  • Parameter Combination: Supports flexible use of multiple parameters

Bytecode Serialization System Reconstruction

Serialization Architecture Optimization

  • Separation of Duties: Clear separation between the runtime bytecode system and the serialization system
  • Dead Code Elimination: Remove duplicate bytecode definitions in bytecode_file.rs
  • Simplified Conversion Interface: Provide concise conversion interfaces through From/Into traits
  • Improved Maintainability: Avoid synchronization maintenance issues between two parallel systems

Serialization Format Specification

  • Core Instruction Set: SerializableBytecode contains only the necessary core instructions
  • Value Type Adaptation: SerializableValue handles serialization conversion for complex types
  • Function Information Preservation: SerializableCompiledFunction completely preserves function compilation information
  • Stable File Format: The .comcn file format is forward-compatible, supporting version migration

User Experience Optimization

Compilation Experience Improvement

  • Compilation Tips: --cn-vm-tip displays detailed compilation process information
  • Progress Feedback: Real-time display of compilation progress and status
  • File Information: Shows the size of the generated bytecode file and the number of functions
  • Library Dependency Display: Clearly shows library dependencies discovered during compilation

Enhanced Execution Experience

  • Silent Execution: By default, bytecode execution produces no unnecessary output, focusing solely on the program result
  • Detailed Mode: --cn-vm-tip provides complete VM execution information
  • Performance Monitoring: --cn-time precisely measures bytecode execution time
  • Consistency Guarantee: Bytecode mode and interpreter mode exhibit identical parameter behavior

Technical Implementation Details

Compiler Integration (src/main.rs)

  • Compilation Process: Integrates a complete bytecode compilation pipeline
  • File Handling: Automatically generates bytecode files with the .comcn extension
  • Error Propagation: Robust error handling and user feedback mechanisms
  • Parameter Parsing: Supports --cn-vm-build compilation parameter

VM Execution Engine (src/vm/vm.rs)

  • Bytecode Loading: Loads and verifies bytecode from .comcn files
  • Library Reload Mechanism: Reload library dependencies at runtime that were compiled at compile time
  • Execution Optimization: Efficient bytecode interpretation execution
  • Debug Support: Optional VM execution debug information

File Format Processing (src/vm/bytecode_file.rs)

  • Serialization Optimization: Efficient bytecode serialization and deserialization
  • Version Compatibility: Support for version management of bytecode file formats
  • Integrity Check: Integrity verification during file loading
  • Metadata Management: Rich support for file metadata

Performance and Compatibility

Performance Improvement

  • Bytecode Advantage: Significantly improved execution speed of compiled bytecode
  • Startup Optimization: Bypasses the source code parsing stage for quick startup and execution
  • Memory Efficiency: Optimized bytecode representation reduces memory usage
  • Cache Friendly: Improved locality of bytecode enhances cache hit rate

Backward Compatibility Guarantee

  • Source Code Compatibility: Existing .cn source files do not require modification
  • Parameter Compatibility: All existing command-line parameters are fully compatible
  • Library Compatibility: The existing library system seamlessly supports bytecode mode
  • Functional Equivalence: Bytecode mode and interpreter mode have identical functionality

Usage Examples

Compile bytecode files

# Compile source files to bytecode
cargo run test.cn --cn-vm-build

# Compilation with detailed information
cargo run test.cn --cn-vm-build --cn-vm-tip

Executing bytecode file

# Directly execute the bytecode file
cargo run test.comcn

# Execution with time measurement

cargo run test.comcn --cn-time

# Execution with VM details

cargo run test.comcn --cn-vm-tip --cn-time

Key issues to fix

Duplicate bytecode system

  • Issue: bytecode_file.rs duplicates the implementation of the bytecode system
  • Fix: Refactor the serialization system to eliminate duplicate definitions

Incomplete parameter support

  • Issue: Bytecode execution does not support parameters like --cn-time
  • Fix: Fully implement support for all parameters in bytecode mode

Inconsistent user experience

  • Issue: Behavioral differences between bytecode mode and interpreter mode
  • Fix: Unify the user interface and parameter behavior of both modes

Missing compilation tool

  • Issue: Lack of a tool to compile source code into bytecode
  • Fix: Implement the --cn-vm-build compilation feature

Architecture Improvement Results

Clear Module Responsibilities

  • Runtime System: Focuses on efficient bytecode execution
  • Serialization System: Focused on file format processing and conversion
  • Compilation System: Focused on source code to bytecode conversion
  • User Interface: Provides a unified command-line experience

Maintainable code structure

  • Single Responsibility: Each module focuses on core functionality
  • Clear Boundaries: Modules interact through simple interfaces
  • Easy to Extend: Reserved space for future feature extensions
  • Test-Friendly: Modular design facilitates unit testing

[v0.9.4 Pre4] - 2025-08-16

字节码编译与执行系统完善

字节码文件编译功能 (--cn-vm-build)

  • 新增编译参数--cn-vm-build 支持将 .cn 源文件编译为 .comcn 字节码文件
  • 完整编译流程:源码解析 → AST生成 → 字节码编译 → 序列化保存
  • 库依赖记录:自动记录编译时的库依赖信息,确保运行时正确加载
  • 元数据保存:保存编译时间、版本信息、源文件路径等元数据
  • 错误处理:提供详细的编译错误信息和诊断提示

字节码文件执行系统

  • 自动识别:自动检测 .comcn 文件格式,无需额外参数
  • VM模式执行:使用高效的虚拟机执行字节码,提升运行性能
  • 库依赖重载:运行时自动重新加载编译时记录的库依赖
  • 完整兼容性:支持所有现有的命令行参数和功能

字节码执行参数支持

  • 时间测量--cn-time 参数现在完全支持字节码执行模式
  • VM调试信息--cn-vm-tip 控制VM执行过程的详细信息显示
  • 返回值显示--cn-return 支持显示字节码程序的执行结果
  • 参数组合:支持多个参数的灵活组合使用

字节码序列化系统重构

序列化架构优化

  • 职责分离:运行时字节码系统与序列化系统清晰分离
  • 重复代码消除:移除 bytecode_file.rs 中的重复字节码定义
  • 转换接口简化:通过 From/Into trait 提供简洁的转换接口
  • 维护性提升:避免两套并行系统的同步维护问题

序列化格式规范

  • 核心指令集SerializableBytecode 只包含必要的核心指令
  • 值类型适配SerializableValue 处理复杂类型的序列化转换
  • 函数信息保存SerializableCompiledFunction 完整保存函数编译信息
  • 文件格式稳定.comcn 文件格式向前兼容,支持版本迁移

用户体验优化

编译体验改进

  • 编译提示--cn-vm-tip 显示详细的编译过程信息
  • 进度反馈:实时显示编译进度和状态
  • 文件信息:显示生成的字节码文件大小和函数数量
  • 库依赖展示:清晰显示编译时发现的库依赖

执行体验提升

  • 静默执行:默认情况下字节码执行无多余输出,专注程序结果
  • 详细模式--cn-vm-tip 提供完整的VM执行信息
  • 性能监控--cn-time 精确测量字节码执行时间
  • 一致性保证:字节码模式与解释器模式的参数行为完全一致

技术实现细节

编译器集成 (src/main.rs)

  • 编译流程:集成完整的字节码编译管道
  • 文件处理:自动生成 .comcn 扩展名的字节码文件
  • 错误传播:完善的错误处理和用户反馈机制
  • 参数解析:支持 --cn-vm-build 编译参数

VM执行引擎 (src/vm/vm.rs)

  • 字节码加载:从 .comcn 文件加载和验证字节码
  • 库重载机制:运行时重新加载编译时的库依赖
  • 执行优化:高效的字节码解释执行
  • 调试支持:可选的VM执行调试信息

文件格式处理 (src/vm/bytecode_file.rs)

  • 序列化优化:高效的字节码序列化和反序列化
  • 版本兼容:支持字节码文件格式的版本管理
  • 完整性检查:文件加载时的完整性验证
  • 元数据管理:丰富的文件元数据支持

性能与兼容性

执行性能提升

  • 字节码优势:编译后的字节码执行速度显著提升
  • 启动优化:跳过源码解析阶段,快速启动执行
  • 内存效率:优化的字节码表示减少内存占用
  • 缓存友好:字节码的局部性提升缓存命中率

向后兼容保证

  • 源码兼容:现有 .cn 源文件无需修改
  • 参数兼容:所有现有命令行参数完全兼容
  • 库兼容:现有库系统无缝支持字节码模式
  • 功能对等:字节码模式与解释器模式功能完全一致

使用示例

编译字节码文件

# 编译源文件为字节码
cargo run test.cn --cn-vm-build

# 带详细信息的编译
cargo run test.cn --cn-vm-build --cn-vm-tip

执行字节码文件

# 直接执行字节码文件
cargo run test.comcn

# 带时间测量的执行
cargo run test.comcn --cn-time

# 带VM详细信息的执行
cargo run test.comcn --cn-vm-tip --cn-time

修复的关键问题

字节码系统重复

  • 问题bytecode_file.rs 重复实现了字节码系统
  • 修复:重构序列化系统,消除重复定义

参数支持不完整

  • 问题:字节码执行不支持 --cn-time 等参数
  • 修复:完整实现所有参数在字节码模式下的支持

用户体验不一致

  • 问题:字节码模式与解释器模式的行为差异
  • 修复:统一两种模式的用户界面和参数行为

编译工具缺失

  • 问题:缺乏将源码编译为字节码的工具
    -...
Read more

v0.9.4 Pre3

16 Aug 07:51

Choose a tag to compare

[v0.9.4 Pre3] - 2025-08-16

Return to Core Design Principles

Remove Hardcoded Built-in Functions

  • Design Principle: CodeNothing's design philosophy is "No built-in functions, built-in functions are implemented as Libraries"
  • Remove hardcoded println function special handling logic in the compiler
  • Remove Print bytecode instruction handling in the VM
  • Remove special judgment logic for built-in functions during statement compilation

Unify library function call mechanism

  • All function calls (including println) must be imported through using lib <library>
  • Enforce the use of using lib <io>; using ns std; to enable println functionality
  • Ensure that both the VM and interpreter follow the same library import rules

VM bytecode system fixes

Compiler module fixes (src/vm/compiler.rs)

  • Remove the special handling branch for Expression::FunctionCall related to println
  • Remove the built-in function detection logic in Statement::FunctionCallStatement
  • Unify all function calls to be processed through the library system or namespace system
  • Improve error messages to prompt users to import the corresponding library

VM execution engine fixes (src/vm/vm.rs)

  • Remove the execution logic for the ByteCode::Print instruction
  • All output functions call std::println via the CallLibrary instruction
  • Ensure stack management consistency, remove special stack handling logic

Bytecode instruction set extension (src/vm/bytecode.rs)

  • The Print instruction is marked as unused (retaining backward compatibility)
  • New loop control instructions added: Jump, JumpIfFalse, JumpIfTrue
  • All output operations should use the CallLibrary instruction
  • Enhance the control flow instruction set to support complex program structures

Complete implementation of control flow statements

While loop support

  • Fully compile and execute while loops in VM
  • Add compile_while_loop method to handle loop body compilation
  • Support nested while loops and complex conditional expressions
  • Correctly handle variable scope within loops

For Loop Support

  • Implement traditional for loop: for (init; condition; increment)
  • Implement range-based for loop: for (item in collection)
  • Add loop control statements: break and continue
  • Supports multi-level nested for loop structures

Loop bytecode instructions

  • New bytecode instructions added:
    • Jump(u32) - Unconditional jump
  • JumpIfFalse(u32) - Conditional jump
    • JumpIfTrue(u32) - Conditional jump (retained)
  • Efficient bytecode generation for implementing loops
  • Optimizing jump instruction address calculation

Enhanced Array Type System

Type Inference Fixes

  • Fixed auto type array inference in VM compiler
  • Correctly handles []int array type syntax (not [int])
  • Fix type validation for array index access in type checker

Function parameter type specification

  • Fix type checking errors caused by auto type in function parameters
  • Require explicit type declaration for array parameters: arr : []int
  • Improve type safety and code readability

Stack Management System Optimization

Function Call Stack Fix

  • Fix stack imbalance issues after removing the Print instruction
  • Unify the stack cleanup logic for function call statements
  • Ensure the Pop instruction is executed correctly after all function calls

Memory Management Improvements

  • Optimize VM stack space usage
  • Fix potential stack overflow risks
  • Improve memory usage efficiency

Test verification improvement

Library import test

  • Create test_vm_with_library.cn to verify correct library import syntax
  • Test the complete process of using lib <io>; using ns std;
  • Verify the correct invocation of println through the library system

Array functionality test

  • Test the complete process of array creation, access, and modification
  • Verify the correctness of array type inference
  • Ensure consistency in array handling between the VM and interpreter

Loop control testing

  • While loop condition checking and loop body execution
  • For loop initialization, condition checking, and increment operation
  • Correct execution of nested loops and variable scope
  • Break and continue statement jump logic

Comprehensive Functional Testing

  • Basic variables and expression evaluation
  • Conditional statements and loop control
  • Array operations and function calls
  • Proper execution of namespace functions
  • Combined use of complex control flows

Enhanced architectural consistency

Adherence to design principles

  • Strictly adhere to the core design principle of "no built-in functions"
  • All functionalities are provided through the library system, maintaining the purity of the language
  • The compiler and VM do not contain any hard-coded function implementations

Integrity of the library system

  • VM is completely dependent on the library system for basic functionality
  • Consistency of the library loading mechanism at compile time and runtime
  • Support for dynamic library function discovery and mapping

Improved error handling

  • Provide clear library import error messages
  • Guide users on the correct use of using lib <library> syntax
  • Improve type error diagnostic information

Key issues fixed

Design principles violated

  • Issue: The compiler hardcodes the println function handling
  • Fix: Remove all hard-coded logic, enforce via library imports

Inconsistent stack management

  • Issue: Stack handling of the Print instruction is inconsistent with other instructions
  • Fix: Unify stack management logic for all function calls

Type System Flaws

  • Issue: There are problems with array type inference and syntax parsing
  • Fix: Improve array handling in the type checker and parser

Incomplete control flow support

  • Issue: The VM lacks complete support for while and for loops
  • Fix: Implement complete loop compilation and execution mechanisms

Insufficient Test Coverage

  • Issue: Lack of comprehensive testing for library import mechanisms and loop controls
  • Fix: Create dedicated test cases for library imports and loop controls

Technical Implementation Highlights

Pure Language Design

  • Achieved a truly "no built-in functions" language architecture
  • All features are modularized and organized through a library system
  • Lays the foundation for future standard library expansion

Unified Execution Model

  • VM and interpreter use the same library call interface
  • Eliminates functional differences between execution modes
  • Provides a consistent development experience

Efficient bytecode execution

  • Simplified instruction set improves execution efficiency
  • Optimized stack management reduces memory overhead
  • Supports complex nested function calls
  • Efficient loop jump instruction implementation
  • Optimized conditional branch execution path

Forward compatibility

Bytecode compatibility

  • Retain the Print instruction definition to avoid breaking existing bytecode
  • New bytecode generation no longer uses deprecated instructions
  • Smooth version migration path

API stability

  • The library interface remains backward compatible
  • The stability of the compiler API is guaranteed
  • Providing a stable foundation for ecosystem development

[v0.9.4 Pre3] - 2025-08-16

核心设计原则回归

移除硬编码内置函数

  • 设计原则:CodeNothing的设计宗旨是"没有内置函数,内置函数以Library实现"
  • 移除编译器中硬编码的println函数特殊处理逻辑
  • 移除VM中的Print字节码指令处理
  • 移除语句编译中对内置函数的特殊判断逻辑

统一库函数调用机制

  • 所有函数调用(包括println)必须通过using lib <library>导入
  • 强制使用using lib <io>; using ns std;来启用println功能
  • 确保VM和解释器都遵循相同的库导入规则

VM字节码系统修复

编译器模块修复 (src/vm/compiler.rs)

  • 移除Expression::FunctionCall中对println的特殊处理分支
  • 移除Statement::FunctionCallStatement中的内置函数检测逻辑
  • 统一所有函数调用通过库系统或命名空间系统处理
  • 改进错误信息,提示用户导入相应库

VM执行引擎修复 (src/vm/vm.rs)

  • 移除ByteCode::Print指令的执行逻辑
  • 所有输出功能通过CallLibrary指令调用std::println
  • 确保栈管理的一致性,移除特殊的栈处理逻辑

字节码指令集扩展 (src/vm/bytecode.rs)

  • Print指令标记为未使用(保留向后兼容性)
  • 新增循环控制指令:JumpJumpIfFalseJumpIfTrue
  • 所有输出操作统一使用CallLibrary指令
  • 完善控制流指令集,支持复杂程序结构

控制流语句完整实现

While循环支持

  • 实现VM中while循环的完整编译和执行
  • 添加compile_while_loop方法处理循环体编译
  • 支持嵌套while循环和复杂条件表达式
  • 正确处理循环中的变量作用域

For循环支持

  • 实现传统for循环:for (init; condition; increment)
  • 实现范围for循环:for (item in collection)
  • 添加循环控制语句:breakcontinue
  • 支持多层嵌套for循环结构

循环字节码指令

  • 新增字节码指令:
    • Jump(u32) - 无条件跳转
    • JumpIfFalse(u32) - 条件跳转
    • JumpIfTrue(u32) - 条件跳转(保留)
  • 实现循环的高效字节码生成
  • 优化跳转指令的地址计算

数组类型系统完善

类型推断修复

  • 修复VM编译器中对auto类型的数组推断
  • 正确处理[]int数组类型语法(而非[int]
  • 修复类型检查器中数组索引访问的类型验证

函数参数类型规范

  • 修复函数参数中auto类型导致的类型检查错误
  • 要求数组参数使用明确类型声明:arr : []int
  • 提高类型安全性和代码可读性

栈管理系统优化

函数调用栈修复

  • 修复Print指令移除后的栈平衡问题
  • 统一函数调用语句的栈清理逻辑
  • 确保所有函数调用后正确执行Pop指令

内存管理改进

  • 优化VM栈空间使用
  • 修复潜在的栈溢出风险
  • 提高内存使用效率

测试验证完善

库导入测试

  • 创建test_vm_with_library.cn验证正确的库导入语法
  • 测试using lib <io>; using ns std;的完整流程
  • 验证println通过库系统的正确调用

数组功能测试

  • 测试数组创建、访问、修改的完整流程
  • 验证数组类型推断的正确性
  • 确保VM和解释器的数组处理一致性

循环控制测试

  • While循环的条件判断和循环体执行
  • For循环的初始化、条件检查、递增操作
  • 嵌套循环的正确执行和变量作用域
  • Break和continue语句的跳转逻辑

综合功能测试

  • 基础变量和表达式计算
  • 条件语句和循环控制
  • 数组操作和函数调用
  • 命名空间函数的正确执行
  • 复杂控制流的组合使用

架构一致性提升

设计原则遵循

  • 严格遵循"没有内置函数"的核心设计原则
  • 所有功能通过库系统提供,保持语言的纯净性
  • 编译器和VM不包含任何硬编码的函数实现

库系统完整性

  • VM完全依赖库系统提供基础功能
  • 库加载机制在编译时和运行时的一致性
  • 支持动态库函数发现和映射

错误处理改进

  • 提供清晰的库导入错误提示
  • 指导用户正确使用using lib <library>语法
  • 改进类型错误的诊断信息

修复的关键问题

设计原则违背

  • 问题:编译器硬编码了println函数处理
  • 修复:移除所有硬编码逻辑,强制通过库导入

栈管理不一致

  • 问题Print指令的栈处理与其他指令不一致...
Read more

v0.9.4.Pre2

15 Aug 19:38

Choose a tag to compare

[v0.9.4 Pre2] - 2025-08-15

VM Namespace System Refactoring

Removal of Hardcoded Restrictions

  • Removed hardcoded handling of specific functions in the VM compiler
  • Remove the special handling logic for std::println in StaticMethodCall
  • Unify the processing flow for all static method calls

Multi-level namespace support

  • Implement recursive parsing of namespace paths: path.join("::")
  • Supports arbitrarily deep namespace nesting structures
  • Adds full compilation support for NamespacedFunctionCall expressions

Code namespace handling

  • Adds collect_namespaced_functions method to collect namespace functions defined in the program
  • Implement collect_namespace_functions to recursively traverse nested namespaces
  • Support unified processing of code namespaces defined by ns statements and library namespaces

Compiler module improvements

Function index system refactoring (src/vm/compiler.rs)

  • Add namespaced_functions: HashMap<String, Function> field to store namespaced functions
  • Modify assign_function_indices method to support namespaced function index assignment
  • Implement dynamic function index mapping to replace hardcoded lookups

Enhanced expression compilation

  • StaticMethodCall converted to a generic NamespacedFunctionCall for processing
  • NamespacedFunctionCall supports unified lookup for library functions and code functions
  • FunctionCall adds namespace prefix matching logic

Bytecode generation optimization

  • Function calls from library functions generate CallLibrary instructions
  • Function calls from code namespace generate Call instructions
  • Unified parameter compilation and instruction generation process

VM execution engine fixes

Refactoring the Function Lookup Mechanism (src/vm/vm.rs)

  • Remove hardcoded function index mapping (main=0, fibonacci=1, etc.)
  • Implement dynamic function lookup based on the function_indices mapping
  • Fix the function name resolution logic for the Call instruction

Bytecode Structure Extension (src/vm/bytecode.rs)

  • CompiledProgram adds function_indices: HashMap<String, u16> field
  • Compiler passes the complete function index map to VM runtime
  • Supports runtime lookup for namespace functions

Namespace Handling Unification

Library Namespace Integration

  • VM compiler reuses the library loading mechanism of the interpreter
  • Supports multi-level library namespaces: trig::sin, log::ln, constants::pi
  • Dynamic discovery and registration of namespace function mappings

Code namespace implementation

  • Supports nested namespace definitions: utils::string::concat, utils::math::double
  • Recursively collects all function definitions within a namespace
  • Generate the complete namespace path as a function identifier

Test Validation

Functional Test Coverage

  • Single-level library namespace call test
  • Multi-level namespace call test
  • Mixed namespace environment test
  • Recursive function call test in namespace

VM and interpreter consistency verification

  • Comparison of outputs for the same code under two execution modes
  • Consistency check of namespace function resolution results
  • Correctness verification of function call parameter passing and return values

Technical implementation details

Compilation-time Processing

  • Collect all namespace definitions during the program parsing phase
  • Assign a unique index to each function during the compilation phase
  • Generate a bytecode program containing complete mapping information

Runtime Execution

  • Function index mapping to function names is established when the VM loads
  • Target functions are quickly located via indices when function calls are made
  • A unified call interface is supported for library functions and code functions

Memory Management

  • Cloning and storage optimization for namespace functions
  • Efficient lookup implementation for function index mapping
  • Avoiding redundant storage of function definitions

Fixed Issues

  • Fixed the limitation where VM only supported hard-coded functions
  • Fixed the single-level limitation in namespace handling
  • Fixed the handling difference between StaticMethodCall and NamespacedFunctionCall
  • Fix reliability issues with VM function index lookup
  • Fix inconsistent handling between code namespace and library namespace

Architecture Improvements

Enhanced Uniformity

  • VM and interpreters use the same namespace for processing logic
  • The calling interfaces for library functions and code functions are unified
  • Eliminate functional differences between execution modes

Enhanced extensibility

  • Supports arbitrary levels of namespace nesting
  • Dynamic function registration and lookup mechanism
  • Lays the foundation for future module systems

Performance optimization

  • Index allocation at compile time reduces runtime overhead
  • O(1) complexity function lookup implementation
  • Avoiding performance loss from string matching

[v0.9.4 Pre2] - 2025-08-15

VM命名空间系统重构

移除硬编码限制

  • 移除VM编译器中对特定函数的硬编码处理
  • 移除StaticMethodCall中对std::println的特殊处理逻辑
  • 统一所有静态方法调用的处理流程

多层级命名空间支持

  • 实现命名空间路径的递归解析:path.join("::")
  • 支持任意深度的命名空间嵌套结构
  • 添加NamespacedFunctionCall表达式的完整编译支持

代码命名空间处理

  • 新增collect_namespaced_functions方法收集程序中定义的命名空间函数
  • 实现collect_namespace_functions递归遍历嵌套命名空间
  • 支持ns语句定义的代码命名空间与库命名空间的统一处理

编译器模块改进

函数索引系统重构 (src/vm/compiler.rs)

  • 添加namespaced_functions: HashMap<String, Function>字段存储命名空间函数
  • 修改assign_function_indices方法支持命名空间函数索引分配
  • 实现动态函数索引映射替代硬编码查找

表达式编译增强

  • StaticMethodCall转换为通用的NamespacedFunctionCall处理
  • NamespacedFunctionCall支持库函数和代码函数的统一查找
  • FunctionCall增加命名空间前缀匹配逻辑

字节码生成优化

  • 库函数调用生成CallLibrary指令
  • 代码命名空间函数调用生成Call指令
  • 统一的参数编译和指令生成流程

VM执行引擎修复

函数查找机制重构 (src/vm/vm.rs)

  • 移除硬编码的函数索引映射(main=0, fibonacci=1等)
  • 实现基于function_indices映射的动态函数查找
  • 修复Call指令的函数名解析逻辑

字节码结构扩展 (src/vm/bytecode.rs)

  • CompiledProgram添加function_indices: HashMap<String, u16>字段
  • 编译器传递完整的函数索引映射给VM运行时
  • 支持命名空间函数的运行时查找

命名空间处理统一化

库命名空间集成

  • VM编译器复用解释器的库加载机制
  • 支持多层级库命名空间:trig::sin, log::ln, constants::pi
  • 命名空间函数映射的动态发现和注册

代码命名空间实现

  • 支持嵌套命名空间定义:utils::string::concat, utils::math::double
  • 递归收集命名空间中的所有函数定义
  • 生成完整的命名空间路径作为函数标识符

测试验证

功能测试覆盖

  • 单层级库命名空间调用测试
  • 多层级代码命名空间调用测试
  • 混合命名空间环境测试
  • 递归函数在命名空间中的调用测试

VM与解释器一致性验证

  • 相同代码在两种执行模式下的输出对比
  • 命名空间函数解析结果的一致性检查
  • 函数调用参数传递和返回值的正确性验证

技术实现细节

编译时处理

  • 程序解析阶段收集所有命名空间定义
  • 编译阶段为每个函数分配唯一索引
  • 生成包含完整映射信息的字节码程序

运行时执行

  • VM加载时建立函数索引到函数名的映射
  • 函数调用时通过索引快速定位目标函数
  • 支持库函数和代码函数的统一调用接口

内存管理

  • 命名空间函数的克隆和存储优化
  • 函数索引映射的高效查找实现
  • 避免重复的函数定义存储

修复的问题

  • 修复VM只支持硬编码函数的限制
  • 修复命名空间处理中的单层级限制
  • 修复StaticMethodCallNamespacedFunctionCall的处理差异
  • 修复VM函数索引查找的可靠性问题
  • 修复代码命名空间与库命名空间的处理不一致

架构改进

统一性提升

  • VM和解释器使用相同的命名空间处理逻辑
  • 库函数和代码函数的调用接口统一
  • 消除执行模式间的功能差异

可扩展性增强

  • 支持任意层级的命名空间嵌套
  • 动态函数注册和查找机制
  • 为未来的模块系统奠定基础

性能优化

  • 编译时索引分配减少运行时开销
  • O(1)复杂度的函数查找实现
  • 避免字符串匹配的性能损耗

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.4...v0.9.4.Pre2

v0.9.4 Pre1 (0.9.400000000001)

15 Aug 12:54

Choose a tag to compare

Pre-release

[v0.9.4 Pre1] - 2025-08-15

Core Changes

VM Library Support System

  • Removed hardcoded function index limits, implemented dynamic function lookup mechanism
  • Full support for using lib <> statements
  • VM and interpreter now use the same library loading interface
  • VM functionality coverage has been significantly expanded

Bytecode instruction set extension

  • New commands:
    • CallLibrary(String, String, u8) - Library function call
    • Mul - Multiplication operation
    • Div - Division operation
  • Greater, GreaterEqual, Equal, NotEqual, Less - Comparison operators
  • Data structure changes:
    • CompiledProgram added imported_libraries field
    • Compiler added library management related fields

Compiler module changes (src/vm/compiler.rs)

  • Added parsing and handling logic for library import statements
  • Implemented dynamic function index allocation mechanism
  • Supported bytecode generation for library function calls
  • Improved error message for library loading failure

Execution engine module changes (src/vm/vm.rs)

  • Implemented execution logic for the CallLibrary instruction
  • Added dynamic function lookup based on function names
  • Implement arithmetic operation methods:
    • mul_values() - Multiplication operation
    • div_values() - Division operation (includes division by zero check)
    • Various comparison operation methods
  • Fixed stack management issues in recursive function calls

[v0.9.4 Pre1] - 2025-08-15

核心变更

VM库支持系统

  • 移除硬编码的函数索引限制,实现动态函数查找机制
  • 添加对using lib <>语句的完整支持
  • VM与解释器现在使用相同的库加载接口
  • VM功能覆盖范围显著扩展

字节码指令集扩展

  • 新增指令:
    • CallLibrary(String, String, u8) - 库函数调用
    • Mul - 乘法运算
    • Div - 除法运算
    • Greater, GreaterEqual, Equal, NotEqual, Less - 比较运算
  • 数据结构变更:
    • CompiledProgram增加imported_libraries字段
    • Compiler增加库管理相关字段

编译器模块变更 (src/vm/compiler.rs)

  • 添加库导入语句的解析和处理逻辑
  • 实现动态函数索引分配机制
  • 支持库函数调用的字节码生成
  • 改进库加载失败时的错误信息

执行引擎模块变更 (src/vm/vm.rs)

  • 实现CallLibrary指令的执行逻辑
  • 添加基于函数名的动态函数查找
  • 实现算术运算方法:
    • mul_values() - 乘法运算
    • div_values() - 除法运算(含除零检查)
    • 各类比较运算方法
  • 修复递归函数调用的栈管理问题

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.3...v0.9.4

v0.9.3

14 Aug 18:57

Choose a tag to compare

[v0.9.3] - 2025-08-19

Bytecode Virtual Machine System

  • Implemented a complete bytecode virtual machine architecture, including instruction set design, compiler frontend, and execution engine
  • Added new bytecode instruction set: LoadConst, LoadLocal, StoreLocal, Add, Sub, Call, Return, and other core instructions
  • A compiler that translates AST to bytecode, supporting bytecode compilation for expressions, statements, and functions
  • Building a stack-based virtual machine execution engine to provide an efficient bytecode execution environment

Command-line options

  • Add --cn-vm option: Execute the program using the bytecode virtual machine
  • Add --cn-vm-debug option: Enable virtual machine debug mode, display detailed execution trace

Performance Optimization

  • Bytecode virtual machine has higher execution efficiency compared to tree traversal interpreter
  • Optimized function call mechanism, supports correct execution of recursive functions
  • Improved string concatenation operations, supporting automatic conversion between strings and other types
  • Complete call stack management, correctly handling parameter passing and return values

Technical Implementation

  • Designed a complete bytecode instruction set, covering stack operations, arithmetic operations, comparison operations, control flow, etc
  • Implemented the compiler core structure, including constant pool management and local variable table
  • Built the stack-based virtual machine architecture, supporting instruction dispatch and execution
  • Added call frame management, properly handling function calls and recursion

[v0.9.3] - 2025-08-19

字节码虚拟机系统

  • 实现了完整的字节码虚拟机架构,包含指令集设计、编译器前端和执行引擎
  • 新增字节码指令集:LoadConst、LoadLocal、StoreLocal、Add、Sub、Call、Return等核心指令
  • 实现AST到字节码的编译器,支持表达式、语句、函数的字节码编译
  • 构建栈式虚拟机执行引擎,提供高效的字节码执行环境

命令行选项

  • 添加 --cn-vm 选项:使用字节码虚拟机执行程序
  • 添加 --cn-vm-debug 选项:启用虚拟机调试模式,显示详细的执行跟踪

性能优化

  • 字节码虚拟机相比树遍历解释器具有更高的执行效率
  • 优化了函数调用机制,支持递归函数的正确执行
  • 改进了字符串拼接操作,支持字符串与其他类型的自动转换
  • 完整的调用栈管理,正确处理参数传递和返回值

技术实现

  • 设计了完整的字节码指令集,涵盖栈操作、算术运算、比较操作、控制流等
  • 实现了编译器核心结构,包括常量池管理和局部变量表
  • 构建了栈式虚拟机架构,支持指令分发和执行
  • 添加了调用帧管理,正确处理函数调用和递归

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.2...v0.9.3

v0.9.2

14 Aug 11:30

Choose a tag to compare

[v0.9.2] - 2025-08-14

🎯 Major Breakthrough in Object-Oriented Programming

  • Complete Implementation of Field Assignment: Fully supports object field modification operations
    • Added object.field = value syntax support
  • Supports complex expressions as assignment values: student.score = old_score + 5
    • Supports multi-field consecutive assignment operations
    • Perfectly integrates into existing OOP systems
    • Verified through comprehensive testing, including mixed scenarios of method calls and field modifications

🏗️ AST and Parser Enhancements

  • Syntax Tree Extension: Added FieldAssignment statement type
    • Structure: FieldAssignment(Box<Expression>, String, Expression)
    • Supports full parsing of object expressions, field names, and assignment expressions
  • Intelligent Parser: Implement a look-ahead parsing mechanism
    • Automatically distinguish between field access (obj.field) and field assignment (obj.field = value)
    • Optimize parsing performance, reduce backtracking operations
    • Maintain the simplicity and consistency of the syntax

🚀 Execution Engine Optimization

  • Field Assignment Executor: Added handle_field_assignment method
    • Secure object field update mechanism
    • Supports field assignment of various data types
  • Proper execution result handling to avoid control flow errors
    • Efficient memory management and object state synchronization

🔧 Generic System Infrastructure

  • Generic Type Manager: A comprehensive generic support framework
  • GenericTypeManager type instance caching system
    • GenericTypeInstance and GenericInstanceMetadata metadata management
    • Supports instantiation of generic functions and generic classes
    • Type inference caching mechanism to improve compilation performance

🧠 Memory Management System Upgrade

  • Local Memory Manager: Added thread-local memory optimization
    • LocalMemoryManager High-performance memory pool
    • Intelligent memory allocation and recycling strategy
  • Memory fragmentation analysis and optimization
    • Support for batch memory operations, enhancing big data processing performance

🎨 Pattern Matching JIT Compilation

  • Pattern JIT Compiler: Experimental JIT optimization feature
  • PatternJitCompiler pattern compilation cache
    • Structured matching and guard condition optimization
    • Runtime performance statistics and analysis
    • Laying the foundation for future high-performance pattern matching

🔍 Lifecycle Analyzer

  • Variable Lifecycle Optimization: Intelligent memory safety analysis
    • VariableLifetimeAnalyzer compile-time safety checks
    • Scope analysis and variable usage pattern detection
  • Identification of optimization opportunities, including type check skipping and inlining access
    • Providing theoretical foundation for zero-cost abstractions

🏃‍♂️ Loop Memory Optimization

  • Loop Variable Manager: A dedicated loop optimization system
  • LoopVariableManager stack allocator
    • Loop invariant detection and optimization
    • Nested loop performance analysis
    • Hotspot identification and performance report generation

🧪 Comprehensive Testing and Validation

  • Field Assignment Test Suite:
    • ✅ Basic field assignment: person.name = "Bob"
    • ✅ Complex expression assignment: student.score = old_score + 3
  • ✅ Multi-field operations: Continuously modify multiple fields
    • ✅ Method integration: Perfect combination of field assignment and method calls
    • ✅ Type safety: Correct handling of various data types

📝 Code quality improvement

  • Architectural Optimization: Modular design further refined
    • Clear separation of responsibilities and interface design
    • Highly cohesive and loosely coupled component architecture
    • Scalable plugin-based functional modules
  • Error Handling: More robust error handling mechanisms
    • Detailed error information and debugging support
    • Graceful error recovery strategies
    • Developer-friendly error messages

🎉 Milestone Achievement

  • OOP Feature Completeness: CodeNothing now supports complete object-oriented programming
    • ✅ Class definition and instantiation
    • ✅ Field access and modification
  • ✅ Method definition and invocation
    • ✅ Constructor support
    • ✅ Inheritance and polymorphism (basic support)

[v0.9.2] - 2025-08-14

🎯 面向对象编程重大突破

  • 字段赋值功能完整实现:全面支持对象字段修改操作
    • 新增 object.field = value 语法支持
    • 支持复杂表达式作为赋值值:student.score = old_score + 5
    • 支持多字段连续赋值操作
    • 完美集成到现有的OOP系统中
    • 通过综合测试验证,包括方法调用和字段修改的混合场景

🏗️ AST 和解析器增强

  • 语法树扩展:新增 FieldAssignment 语句类型
    • 结构:FieldAssignment(Box<Expression>, String, Expression)
    • 支持对象表达式、字段名和赋值表达式的完整解析
  • 解析器智能化:实现前瞻解析机制
    • 自动区分字段访问 (obj.field) 和字段赋值 (obj.field = value)
    • 优化解析性能,减少回溯操作
    • 保持语法的简洁性和一致性

🚀 执行引擎优化

  • 字段赋值执行器:新增 handle_field_assignment 方法
    • 安全的对象字段更新机制
    • 支持各种数据类型的字段赋值
    • 正确的执行结果处理,避免控制流错误
    • 高效的内存管理和对象状态同步

🔧 泛型系统基础设施

  • 泛型类型管理器:完善的泛型支持框架
    • GenericTypeManager 类型实例缓存系统
    • GenericTypeInstanceGenericInstanceMetadata 元数据管理
    • 支持泛型函数和泛型类的实例化
    • 类型推断缓存机制,提升编译性能

🧠 内存管理系统升级

  • 本地内存管理器:新增线程本地内存优化
    • LocalMemoryManager 高性能内存池
    • 智能内存分配和回收策略
    • 内存碎片化分析和优化
    • 支持批量内存操作,提升大数据处理性能

🎨 模式匹配JIT编译

  • 模式JIT编译器:实验性JIT优化功能
    • PatternJitCompiler 模式编译缓存
    • 结构化匹配和守卫条件优化
    • 运行时性能统计和分析
    • 为未来的高性能模式匹配奠定基础

🔍 生命周期分析器

  • 变量生命周期优化:智能内存安全分析
    • VariableLifetimeAnalyzer 编译时安全检查
    • 作用域分析和变量使用模式检测
    • 优化机会识别,包括类型检查跳过和内联访问
    • 为零成本抽象提供理论基础

🏃‍♂️ 循环内存优化

  • 循环变量管理器:专门的循环优化系统
    • LoopVariableManager 栈分配器
    • 循环不变量检测和优化
    • 嵌套循环性能分析
    • 热点识别和性能报告生成

🧪 全面测试验证

  • 字段赋值测试套件
    • ✅ 基础字段赋值:person.name = "Bob"
    • ✅ 复杂表达式赋值:student.score = old_score + 3
    • ✅ 多字段操作:连续修改多个字段
    • ✅ 方法集成:字段赋值与方法调用的完美结合
    • ✅ 类型安全:各种数据类型的正确处理

📝 代码质量提升

  • 架构优化:模块化设计进一步完善
    • 清晰的职责分离和接口设计
    • 高内聚低耦合的组件架构
    • 可扩展的插件式功能模块
  • 错误处理:更加健壮的错误处理机制
    • 详细的错误信息和调试支持
    • 优雅的错误恢复策略
    • 开发者友好的错误提示

🎉 里程碑成就

  • OOP功能完整性:CodeNothing 现在支持完整的面向对象编程
    • ✅ 类定义和实例化
    • ✅ 字段访问和修改
    • ✅ 方法定义和调用
    • ✅ 构造函数支持
    • ✅ 继承和多态(基础支持)

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.1...v0.9.2

v0.9.1

13 Aug 20:56
cc44134

Choose a tag to compare

Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.0...v0.9.1

[v0.9.1] - 2025-08-14

🔧 Execution Control Optimization

  • Timeout Check Control: Added --cn-check-timeout command-line parameter
    • Timeout check is disabled by default, allowing the program to run indefinitely
  • The --cn-check-timeout parameter can enable a 30-second timeout limit
    • The issue where long-running programs were unexpectedly interrupted has been resolved
    • Backward compatibility is maintained; existing code does not require modification

🚀 Performance Optimization

  • Removal of operation count limit: Completely removed the operation count check mechanism
    • Resolved issues where complex programs were interrupted due to operation count limits
    • Enhanced the execution capability of loop-intensive programs
    • Retained the time-out check as an optional security mechanism

🏗️ Object-Oriented Programming Enhancement

  • Improved Class and Object System: Continue improving OOP features
    • Optimized method invocation mechanism
    • Enhanced object state management
  • Enhanced field access and assignment functionality
    • Improved constructor and destructor support

🛠️ Technical Implementation

  • Interpreter core improvements
  • Add timeout_enabled field to control timeout checking
    • New set_timeout_enabled() method
    • Create interpret_with_timeout() function to support timeout control
    • Modify check_timeout() method to only perform checks when enabled

Command Line Options

  • Add Execution Control Options
    • --cn-check-timeout: Enable timeout check (disabled by default)
    • Fully compatible with existing debug options
  • Supports combined use: --cn-check-timeout --cn-time

🧪 Testing and Validation

  • ✅ Default behavior: The program can run for a long time without being interrupted
  • ✅ Enabled timeout: The program correctly displays a timeout error after 30 seconds
  • ✅ Backward compatible: All existing code works normally
  • ✅ Stable performance: Performance is more stable after removing restrictions

[v0.9.1] - 2025-08-14

🔧 执行控制优化

  • 超时检查控制:新增 --cn-check-timeout 命令行参数
    • 默认情况下禁用超时检查,程序可以无限制运行
    • 使用 --cn-check-timeout 参数可启用30秒超时限制
    • 解决了长时间运行程序被意外中断的问题
    • 保持向后兼容性,现有代码无需修改

🚀 性能优化

  • 移除操作次数限制:完全移除了操作次数检查机制
    • 解决了复杂程序因操作次数限制而被中断的问题
    • 提升了循环密集型程序的执行能力
    • 保留时间超时检查作为可选的安全机制

🏗️ 面向对象编程增强

  • 类和对象系统完善:继续改进OOP功能
    • 优化了方法调用机制
    • 改进了对象状态管理
    • 增强了字段访问和赋值功能
    • 完善了构造函数和析构函数支持

🛠️ 技术实现

  • 解释器核心改进
    • 添加 timeout_enabled 字段控制超时检查
    • 新增 set_timeout_enabled() 方法
    • 创建 interpret_with_timeout() 函数支持超时控制
    • 修改 check_timeout() 方法,只在启用时进行检查

📝 命令行选项

  • 新增执行控制选项
    • --cn-check-timeout:启用超时检查(默认禁用)
    • 与现有调试选项完全兼容
    • 支持组合使用:--cn-check-timeout --cn-time

🧪 测试验证

  • ✅ 默认行为:程序可以长时间运行而不被中断
  • ✅ 启用超时:程序在30秒后正确显示超时错误
  • ✅ 向后兼容:所有现有代码正常工作
  • ✅ 性能稳定:移除限制后性能更加稳定

v0.9.0

13 Aug 15:20

Choose a tag to compare

[v0.9.0] - 2025-08-13

New Features

  • Added basic support for generic syntax, including parsing generic function definitions
  • Added /* */ multi-line comment syntax as an alias for /! !/
  • Implemented a heuristic parsing mechanism to handle grammatical ambiguity
  • Added context-aware symbol recognition

Improvements

  • Rewrote comment removal logic to improve string and comment processing precedence
  • Enhanced generic call detection in the expression parser
  • Optimized generic parameter handling in the function and class parsers
  • Improved parser error recovery

Bug Fixes

  • Fixed a conflict between the <> symbol and comparison operators in generic syntax
  • Addressed an issue with incorrect parsing of string literals in comments
  • Addressed an issue with incorrect handling of comment symbols within strings
  • Fixed an edge case in parsing multi-character operators
  • Addressed an issue with handling nested multi-line comments

Technical Details

  • Implemented the is_likely_generic_call() method in the expression parser.
  • Added the is_valid_type_name() and check_generic_context_after_closing_bracket() helper methods.
  • Refactored the remove_comments() function to enhance state management.
  • Implemented a fallback mechanism for saving/restoring parsing position.

[v0.9.0] - 2025-08-13

新增功能

  • 新增泛型语法基础支持,包括泛型函数定义解析
  • 添加 /* */ 多行注释语法作为 /! !/ 的别名
  • 实现试探性解析机制,用于处理语法歧义
  • 新增上下文感知的符号识别功能

功能改进

  • 重写注释移除逻辑,改进字符串和注释的处理优先级
  • 增强表达式解析器的泛型调用检测能力
  • 优化函数解析器和类解析器的泛型参数处理
  • 改进解析器的错误恢复机制

问题修复

  • 修复泛型语法中 <> 符号与比较操作符的冲突问题
  • 解决注释中字符串字面量被错误解析的问题
  • 修复字符串内注释符号被误处理的问题
  • 修复多字符操作符解析的边界情况
  • 解决嵌套多行注释的处理问题

技术细节

  • 在表达式解析器中实现 is_likely_generic_call() 方法
  • 添加 is_valid_type_name()check_generic_context_after_closing_bracket() 辅助方法
  • 重构 remove_comments() 函数,增强状态管理
  • 实现保存/恢复解析位置的回退机制

Full Changelog: CodeNothingCommunity/CodeNothing@v0.8.5...v0.9.0