This repository was archived by the owner on Aug 18, 2025. It is now read-only.
Releases: CodeNothingCommunity/CodeNothing-Zero
Releases · CodeNothingCommunity/CodeNothing-Zero
v0.9.5
[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
[v0.9.4 Pre5] - 2025-08-16
VM debugging information control system
Debug parameter refactoring
- New parameter:
--cn-vm-tipspecifically 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: boolcontrols the display of VM debug information - New method:
set_tip_mode()dynamically set the debug mode - Parameter passing: Correctly pass
tipparameter to VM inexecute_with_vmfunction
Major repair of VM condition judgment system
Core Problem Diagnosis
- Problem found: The VM compiler has a serious bug when processing
else ifstatements - Specific performance: Only process the first
elsebranch, completely ignoring the conditional judgment ofelse 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 ifbranch - Branch chain processing: Implement complete
if-else if-elsebranch 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 thetimes == 1branch and returns directly without recursion - Impact: All recursive functions containing
else ifconditional 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 ifstatement 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-tipparameter 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-elsestatements - Complex branching: Complete testing of
if-else if-elsechains - 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-tipparameter 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-tipparameter fully controls the debug information display✅ - Conditional judgment fix:
else ifstatement 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
- Compiler debug output control: All compiler debug information is now controlled using the
show_tipsfield - Conditional branch compilation logic: Completely rewrite the bytecode generation logic of
else ifstatements - Jump address calculation: Fixed the address calculation error of conditional jump and branch jump
- 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调试信息控制系统
调试参数...
v0.9.4 Pre4
[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-buildnow supports compiling.cnsource files into.comcnbytecode 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
.comcnfile 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-timeparameter now fully supports bytecode execution mode - VM Debug Information: The
--cn-vm-tipcontrols detailed display of VM execution process information - Return Value Display:
--cn-returnsupports 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/Intotraits - Improved Maintainability: Avoid synchronization maintenance issues between two parallel systems
Serialization Format Specification
- Core Instruction Set:
SerializableBytecodecontains only the necessary core instructions - Value Type Adaptation:
SerializableValuehandles serialization conversion for complex types - Function Information Preservation:
SerializableCompiledFunctioncompletely preserves function compilation information - Stable File Format: The
.comcnfile format is forward-compatible, supporting version migration
User Experience Optimization
Compilation Experience Improvement
- Compilation Tips:
--cn-vm-tipdisplays 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-tipprovides complete VM execution information - Performance Monitoring:
--cn-timeprecisely 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
.comcnextension - Error Propagation: Robust error handling and user feedback mechanisms
- Parameter Parsing: Supports
--cn-vm-buildcompilation parameter
VM Execution Engine (src/vm/vm.rs)
- Bytecode Loading: Loads and verifies bytecode from
.comcnfiles - 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
.cnsource 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-tipExecuting 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-timeKey issues to fix
Duplicate bytecode system
- Issue:
bytecode_file.rsduplicates 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-buildcompilation 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/Intotrait 提供简洁的转换接口 - 维护性提升:避免两套并行系统的同步维护问题
序列化格式规范
- 核心指令集:
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等参数 - 修复:完整实现所有参数在字节码模式下的支持
用户体验不一致
- 问题:字节码模式与解释器模式的行为差异
- 修复:统一两种模式的用户界面和参数行为
编译工具缺失
- 问题:缺乏将源码编译为字节码的工具
-...
v0.9.4 Pre3
[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
printlnfunction special handling logic in the compiler - Remove
Printbytecode 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 throughusing lib <library> - Enforce the use of
using lib <io>; using ns std;to enableprintlnfunctionality - 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::FunctionCallrelated toprintln - 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::Printinstruction - All output functions call
std::printlnvia theCallLibraryinstruction - Ensure stack management consistency, remove special stack handling logic
Bytecode instruction set extension (src/vm/bytecode.rs)
- The
Printinstruction is marked as unused (retaining backward compatibility) - New loop control instructions added:
Jump,JumpIfFalse,JumpIfTrue - All output operations should use the
CallLibraryinstruction - Enhance the control flow instruction set to support complex program structures
Complete implementation of control flow statements
While loop support
- Fully compile and execute
whileloops in VM - Add
compile_while_loopmethod to handle loop body compilation - Support nested
whileloops 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:
breakandcontinue - Supports multi-level nested for loop structures
Loop bytecode instructions
- New bytecode instructions added:
Jump(u32)- Unconditional jump
JumpIfFalse(u32)- Conditional jumpJumpIfTrue(u32)- Conditional jump (retained)
- Efficient bytecode generation for implementing loops
- Optimizing jump instruction address calculation
Enhanced Array Type System
Type Inference Fixes
- Fixed
autotype array inference in VM compiler - Correctly handles
[]intarray type syntax (not[int]) - Fix type validation for array index access in type checker
Function parameter type specification
- Fix type checking errors caused by
autotype 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
Printinstruction - Unify the stack cleanup logic for function call statements
- Ensure the
Popinstruction 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.cnto verify correct library import syntax - Test the complete process of
using lib <io>; using ns std; - Verify the correct invocation of
printlnthrough 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
printlnfunction handling - Fix: Remove all hard-coded logic, enforce via library imports
Inconsistent stack management
- Issue: Stack handling of the
Printinstruction 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
Printinstruction 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指令标记为未使用(保留向后兼容性)- 新增循环控制指令:
Jump、JumpIfFalse、JumpIfTrue - 所有输出操作统一使用
CallLibrary指令 - 完善控制流指令集,支持复杂程序结构
控制流语句完整实现
While循环支持
- 实现VM中
while循环的完整编译和执行 - 添加
compile_while_loop方法处理循环体编译 - 支持嵌套while循环和复杂条件表达式
- 正确处理循环中的变量作用域
For循环支持
- 实现传统for循环:
for (init; condition; increment) - 实现范围for循环:
for (item in collection) - 添加循环控制语句:
break和continue - 支持多层嵌套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指令的栈处理与其他指令不一致...
v0.9.4.Pre2
[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::printlninStaticMethodCall - 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
NamespacedFunctionCallexpressions
Code namespace handling
- Adds
collect_namespaced_functionsmethod to collect namespace functions defined in the program - Implement
collect_namespace_functionsto recursively traverse nested namespaces - Support unified processing of code namespaces defined by
nsstatements 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_indicesmethod to support namespaced function index assignment - Implement dynamic function index mapping to replace hardcoded lookups
Enhanced expression compilation
StaticMethodCallconverted to a genericNamespacedFunctionCallfor processingNamespacedFunctionCallsupports unified lookup for library functions and code functionsFunctionCalladds namespace prefix matching logic
Bytecode generation optimization
- Function calls from library functions generate
CallLibraryinstructions - Function calls from code namespace generate
Callinstructions - 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_indicesmapping - Fix the function name resolution logic for the
Callinstruction
Bytecode Structure Extension (src/vm/bytecode.rs)
CompiledProgramaddsfunction_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
StaticMethodCallandNamespacedFunctionCall - 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只支持硬编码函数的限制
- 修复命名空间处理中的单层级限制
- 修复
StaticMethodCall和NamespacedFunctionCall的处理差异 - 修复VM函数索引查找的可靠性问题
- 修复代码命名空间与库命名空间的处理不一致
架构改进
统一性提升
- VM和解释器使用相同的命名空间处理逻辑
- 库函数和代码函数的调用接口统一
- 消除执行模式间的功能差异
可扩展性增强
- 支持任意层级的命名空间嵌套
- 动态函数注册和查找机制
- 为未来的模块系统奠定基础
性能优化
- 编译时索引分配减少运行时开销
- O(1)复杂度的函数查找实现
- 避免字符串匹配的性能损耗
Full Changelog: CodeNothingCommunity/CodeNothing@v0.9.4...v0.9.4.Pre2
v0.9.4 Pre1 (0.9.400000000001)
[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 callMul- Multiplication operationDiv- Division operation
Greater,GreaterEqual,Equal,NotEqual,Less- Comparison operators- Data structure changes:
CompiledProgramaddedimported_librariesfieldCompileradded 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
CallLibraryinstruction - Added dynamic function lookup based on function names
- Implement arithmetic operation methods:
mul_values()- Multiplication operationdiv_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
[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-vmoption: Execute the program using the bytecode virtual machine - Add
--cn-vm-debugoption: 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
[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 = valuesyntax support
- Added
- 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
FieldAssignmentstatement type- Structure:
FieldAssignment(Box<Expression>, String, Expression) - Supports full parsing of object expressions, field names, and assignment expressions
- Structure:
- 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
- Automatically distinguish between field access (
🚀 Execution Engine Optimization
- Field Assignment Executor: Added
handle_field_assignmentmethod- 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
GenericTypeManagertype instance caching systemGenericTypeInstanceandGenericInstanceMetadatametadata 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
LocalMemoryManagerHigh-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
PatternJitCompilerpattern 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
VariableLifetimeAnalyzercompile-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
LoopVariableManagerstack 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
- ✅ Basic field assignment:
- ✅ 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类型实例缓存系统GenericTypeInstance和GenericInstanceMetadata元数据管理- 支持泛型函数和泛型类的实例化
- 类型推断缓存机制,提升编译性能
🧠 内存管理系统升级
- 本地内存管理器:新增线程本地内存优化
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
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-timeoutcommand-line parameter- Timeout check is disabled by default, allowing the program to run indefinitely
- The
--cn-check-timeoutparameter 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_enabledfield 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
- New
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
[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()andcheck_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