@@ -8,8 +8,8 @@ import '../value.dart';
88import 'dispatcher.dart' ;
99import 'embedded_sass.pb.dart' as proto;
1010import 'embedded_sass.pb.dart' hide Value, ListSeparator, CalculationOperator;
11- import 'function_registry.dart' ;
1211import 'host_callable.dart' ;
12+ import 'opaque_registry.dart' ;
1313import 'utils.dart' ;
1414
1515/// A class that converts Sass [Value] objects into [Value] protobufs.
@@ -21,7 +21,10 @@ final class Protofier {
2121 final Dispatcher _dispatcher;
2222
2323 /// 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;
2528
2629 /// Any argument lists transitively contained in [value] .
2730 ///
@@ -35,7 +38,10 @@ final class Protofier {
3538 ///
3639 /// The [functions] tracks the IDs of first-class functions so that the host
3740 /// 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);
3945
4046 /// Converts [value] to its protocol buffer representation.
4147 proto.Value protofy (Value value) {
@@ -84,7 +90,10 @@ final class Protofier {
8490 case SassCalculation ():
8591 result.calculation = _protofyCalculation (value);
8692 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));
8897 case sassTrue:
8998 result.singleton = SingletonValue .TRUE ;
9099 case sassFalse:
@@ -238,9 +247,15 @@ final class Protofier {
238247
239248 case Value_Value .hostFunction:
240249 return SassFunction (hostCallable (
241- _dispatcher, _functions, value.hostFunction.signature,
250+ _dispatcher, _functions, _mixins, value.hostFunction.signature,
242251 id: value.hostFunction.id));
243252
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+
244259 case Value_Value .calculation:
245260 return _deprotofyCalculation (value.calculation);
246261
0 commit comments