@@ -8,8 +8,8 @@ import '../value.dart';
8
8
import 'dispatcher.dart' ;
9
9
import 'embedded_sass.pb.dart' as proto;
10
10
import 'embedded_sass.pb.dart' hide Value, ListSeparator, CalculationOperator;
11
- import 'function_registry.dart' ;
12
11
import 'host_callable.dart' ;
12
+ import 'opaque_registry.dart' ;
13
13
import 'utils.dart' ;
14
14
15
15
/// A class that converts Sass [Value] objects into [Value] protobufs.
@@ -21,7 +21,10 @@ final class Protofier {
21
21
final Dispatcher _dispatcher;
22
22
23
23
/// The IDs of first-class functions.
24
- final FunctionRegistry _functions;
24
+ final OpaqueRegistry <SassFunction > _functions;
25
+
26
+ /// The IDs of first-class mixins.
27
+ final OpaqueRegistry <SassMixin > _mixins;
25
28
26
29
/// Any argument lists transitively contained in [value] .
27
30
///
@@ -35,7 +38,10 @@ final class Protofier {
35
38
///
36
39
/// The [functions] tracks the IDs of first-class functions so that the host
37
40
/// can pass them back to the compiler.
38
- Protofier (this ._dispatcher, this ._functions);
41
+ ///
42
+ /// Similarly, the [mixins] tracks the IDs of first-class mixins so that the
43
+ /// host can pass them back to the compiler.
44
+ Protofier (this ._dispatcher, this ._functions, this ._mixins);
39
45
40
46
/// Converts [value] to its protocol buffer representation.
41
47
proto.Value protofy (Value value) {
@@ -84,7 +90,10 @@ final class Protofier {
84
90
case SassCalculation ():
85
91
result.calculation = _protofyCalculation (value);
86
92
case SassFunction ():
87
- result.compilerFunction = _functions.protofy (value);
93
+ result.compilerFunction =
94
+ Value_CompilerFunction (id: _functions.getId (value));
95
+ case SassMixin ():
96
+ result.compilerMixin = Value_CompilerMixin (id: _mixins.getId (value));
88
97
case sassTrue:
89
98
result.singleton = SingletonValue .TRUE ;
90
99
case sassFalse:
@@ -238,9 +247,15 @@ final class Protofier {
238
247
239
248
case Value_Value .hostFunction:
240
249
return SassFunction (hostCallable (
241
- _dispatcher, _functions, value.hostFunction.signature,
250
+ _dispatcher, _functions, _mixins, value.hostFunction.signature,
242
251
id: value.hostFunction.id));
243
252
253
+ case Value_Value .compilerMixin:
254
+ var id = value.compilerMixin.id;
255
+ if (_mixins[id] case var mixin ? ) return mixin ;
256
+ throw paramsError (
257
+ "CompilerMixin.id $id doesn't match any known mixins" );
258
+
244
259
case Value_Value .calculation:
245
260
return _deprotofyCalculation (value.calculation);
246
261
0 commit comments