@@ -17,19 +17,22 @@ class BuiltInModule<T extends AsyncCallable> implements Module<T> {
17
17
final Uri url;
18
18
final Map <String , T > functions;
19
19
final Map <String , T > mixins;
20
+ final Map <String , Value > variables;
20
21
21
22
List <Module <T >> get upstream => const [];
22
- Map <String , Value > get variables => const {};
23
23
Map <String , AstNode > get variableNodes => const {};
24
24
Extender get extender => Extender .empty;
25
25
CssStylesheet get css => CssStylesheet .empty (url: url);
26
26
bool get transitivelyContainsCss => false ;
27
27
bool get transitivelyContainsExtensions => false ;
28
28
29
- BuiltInModule (String name, {Iterable <T > functions, Iterable <T > mixins})
29
+ BuiltInModule (String name,
30
+ {Iterable <T > functions, Iterable <T > mixins, Map <String , Value > variables})
30
31
: url = Uri (scheme: "sass" , path: name),
31
32
functions = _callableMap (functions),
32
- mixins = _callableMap (mixins);
33
+ mixins = _callableMap (mixins),
34
+ variables =
35
+ variables == null ? const {} : UnmodifiableMapView (variables);
33
36
34
37
/// Returns a map from [callables] ' names to their values.
35
38
static Map <String , T > _callableMap <T extends AsyncCallable >(
@@ -40,7 +43,10 @@ class BuiltInModule<T extends AsyncCallable> implements Module<T> {
40
43
{for (var callable in callables) callable.name: callable}));
41
44
42
45
void setVariable (String name, Value value, AstNode nodeWithSpan) {
43
- throw SassScriptException ("Undefined variable." );
46
+ if (! variables.containsKey (name)) {
47
+ throw SassScriptException ("Undefined variable." );
48
+ }
49
+ throw SassScriptException ("Cannot modify built-in variable." );
44
50
}
45
51
46
52
Module <T > cloneCss () => this ;
0 commit comments