kumi 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +28 -44
- data/README.md +188 -108
- data/docs/AST.md +8 -1
- data/docs/FUNCTIONS.md +52 -8
- data/docs/compiler_design_principles.md +86 -0
- data/docs/features/README.md +22 -2
- data/docs/features/hierarchical-broadcasting.md +349 -0
- data/docs/features/javascript-transpiler.md +148 -0
- data/docs/features/performance.md +1 -3
- data/docs/features/s-expression-printer.md +77 -0
- data/docs/schema_metadata.md +7 -7
- data/examples/game_of_life.rb +2 -4
- data/lib/kumi/analyzer.rb +0 -2
- data/lib/kumi/compiler.rb +6 -275
- data/lib/kumi/core/analyzer/passes/broadcast_detector.rb +600 -42
- data/lib/kumi/core/analyzer/passes/input_collector.rb +4 -2
- data/lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb +27 -0
- data/lib/kumi/core/analyzer/passes/type_checker.rb +6 -2
- data/lib/kumi/core/analyzer/passes/unsat_detector.rb +90 -46
- data/lib/kumi/core/cascade_executor_builder.rb +132 -0
- data/lib/kumi/core/compiler/expression_compiler.rb +146 -0
- data/lib/kumi/core/compiler/function_invoker.rb +55 -0
- data/lib/kumi/core/compiler/path_traversal_compiler.rb +158 -0
- data/lib/kumi/core/compiler/reference_compiler.rb +46 -0
- data/lib/kumi/core/compiler_base.rb +137 -0
- data/lib/kumi/core/explain.rb +2 -2
- data/lib/kumi/core/function_registry/collection_functions.rb +86 -3
- data/lib/kumi/core/function_registry/function_builder.rb +5 -3
- data/lib/kumi/core/function_registry/logical_functions.rb +171 -1
- data/lib/kumi/core/function_registry/stat_functions.rb +156 -0
- data/lib/kumi/core/function_registry.rb +32 -10
- data/lib/kumi/core/nested_structure_utils.rb +78 -0
- data/lib/kumi/core/ruby_parser/dsl_cascade_builder.rb +2 -2
- data/lib/kumi/core/ruby_parser/input_builder.rb +61 -8
- data/lib/kumi/core/schema_instance.rb +4 -0
- data/lib/kumi/core/vectorized_function_builder.rb +88 -0
- data/lib/kumi/errors.rb +2 -0
- data/lib/kumi/js/compiler.rb +878 -0
- data/lib/kumi/js/function_registry.rb +333 -0
- data/lib/kumi/js.rb +23 -0
- data/lib/kumi/registry.rb +61 -1
- data/lib/kumi/schema.rb +1 -1
- data/lib/kumi/support/s_expression_printer.rb +162 -0
- data/lib/kumi/syntax/array_expression.rb +6 -6
- data/lib/kumi/syntax/call_expression.rb +4 -4
- data/lib/kumi/syntax/cascade_expression.rb +4 -4
- data/lib/kumi/syntax/case_expression.rb +4 -4
- data/lib/kumi/syntax/declaration_reference.rb +4 -4
- data/lib/kumi/syntax/hash_expression.rb +4 -4
- data/lib/kumi/syntax/input_declaration.rb +6 -5
- data/lib/kumi/syntax/input_element_reference.rb +5 -5
- data/lib/kumi/syntax/input_reference.rb +5 -5
- data/lib/kumi/syntax/literal.rb +4 -4
- data/lib/kumi/syntax/node.rb +34 -34
- data/lib/kumi/syntax/root.rb +6 -6
- data/lib/kumi/syntax/trait_declaration.rb +4 -4
- data/lib/kumi/syntax/value_declaration.rb +4 -4
- data/lib/kumi/version.rb +1 -1
- data/lib/kumi.rb +1 -1
- data/scripts/analyze_broadcast_methods.rb +68 -0
- data/scripts/analyze_cascade_methods.rb +74 -0
- data/scripts/check_broadcasting_coverage.rb +51 -0
- data/scripts/find_dead_code.rb +114 -0
- metadata +22 -4
- data/docs/features/array-broadcasting.md +0 -170
- data/lib/kumi/cli.rb +0 -449
- data/lib/kumi/core/vectorization_metadata.rb +0 -110
@@ -1,110 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Kumi
|
4
|
-
module Core
|
5
|
-
# Metadata system for vectorization detection and handling
|
6
|
-
module VectorizationMetadata
|
7
|
-
# Tracks which declarations are arrays with children (vectorizable)
|
8
|
-
class ArrayDeclarationTracker
|
9
|
-
def initialize
|
10
|
-
@array_declarations = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
def register_array(name, children)
|
14
|
-
@array_declarations[name] = children.map(&:name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def array_declaration?(name)
|
18
|
-
@array_declarations.key?(name)
|
19
|
-
end
|
20
|
-
|
21
|
-
def array_children(name)
|
22
|
-
@array_declarations[name] || []
|
23
|
-
end
|
24
|
-
|
25
|
-
def all_arrays
|
26
|
-
@array_declarations.keys
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Detects vectorized operations in expressions
|
31
|
-
class VectorizationDetector
|
32
|
-
def initialize(array_tracker)
|
33
|
-
@array_tracker = array_tracker
|
34
|
-
end
|
35
|
-
|
36
|
-
# Check if an expression should be vectorized
|
37
|
-
def vectorized_expression?(expression)
|
38
|
-
case expression
|
39
|
-
when Kumi::Syntax::CallExpression
|
40
|
-
vectorized_call?(expression)
|
41
|
-
when Kumi::Syntax::InputElementReference
|
42
|
-
vectorized_element_reference?(expression)
|
43
|
-
else
|
44
|
-
false
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
# Check if a function call should be treated as a reducer
|
49
|
-
def reducer_function?(fn_name, args)
|
50
|
-
REDUCER_FUNCTIONS.include?(fn_name) &&
|
51
|
-
args.any? { |arg| vectorized_expression?(arg) }
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
REDUCER_FUNCTIONS = %i[sum min max size length first last].freeze
|
57
|
-
|
58
|
-
def vectorized_call?(call_expr)
|
59
|
-
# Arithmetic operations between array elements are vectorized
|
60
|
-
ARITHMETIC_OPERATIONS.include?(call_expr.fn_name) &&
|
61
|
-
call_expr.args.any? { |arg| vectorized_expression?(arg) }
|
62
|
-
end
|
63
|
-
|
64
|
-
def vectorized_element_reference?(elem_ref)
|
65
|
-
return false unless elem_ref.path.size >= 2
|
66
|
-
|
67
|
-
array_name, _field_name = elem_ref.path
|
68
|
-
@array_tracker.array_declaration?(array_name)
|
69
|
-
end
|
70
|
-
|
71
|
-
ARITHMETIC_OPERATIONS = %i[add subtract multiply divide modulo power].freeze
|
72
|
-
end
|
73
|
-
|
74
|
-
# Metadata about how values should be computed
|
75
|
-
class ComputationMetadata
|
76
|
-
attr_reader :vectorized_values, :reducer_values, :scalar_values
|
77
|
-
|
78
|
-
def initialize
|
79
|
-
@vectorized_values = Set.new
|
80
|
-
@reducer_values = Set.new
|
81
|
-
@scalar_values = Set.new
|
82
|
-
end
|
83
|
-
|
84
|
-
def mark_vectorized(name)
|
85
|
-
@vectorized_values.add(name)
|
86
|
-
end
|
87
|
-
|
88
|
-
def mark_reducer(name)
|
89
|
-
@reducer_values.add(name)
|
90
|
-
end
|
91
|
-
|
92
|
-
def mark_scalar(name)
|
93
|
-
@scalar_values.add(name)
|
94
|
-
end
|
95
|
-
|
96
|
-
def vectorized?(name)
|
97
|
-
@vectorized_values.include?(name)
|
98
|
-
end
|
99
|
-
|
100
|
-
def reducer?(name)
|
101
|
-
@reducer_values.include?(name)
|
102
|
-
end
|
103
|
-
|
104
|
-
def scalar?(name)
|
105
|
-
@scalar_values.include?(name)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|