dart-sass/lib/src/callable/built_in.dart

27 lines
916 B
Dart
Raw Normal View History

2016-08-27 11:06:15 +02:00
// Copyright 2016 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
2016-08-28 01:12:17 +02:00
import '../ast/sass.dart';
2016-08-27 11:06:15 +02:00
import '../callable.dart';
2016-09-21 18:30:41 +02:00
import '../parse.dart';
2016-08-27 11:06:15 +02:00
import '../value.dart';
typedef Value _Callback(List<Value> arguments);
class BuiltInCallable implements Callable {
final String name;
final List<ArgumentDeclaration> overloads;
final List<_Callback> callbacks;
2016-09-21 18:30:41 +02:00
BuiltInCallable(
String name, String arguments, Value callback(List<Value> arguments))
: this.overloaded(name, [arguments], [callback]);
2016-08-27 11:06:15 +02:00
2016-09-21 18:30:41 +02:00
BuiltInCallable.overloaded(
this.name, Iterable<String> overloads, Iterable<_Callback> callbacks)
: overloads = new List.unmodifiable(overloads
.map((overload) => parseArgumentDeclaration("($overload)"))),
callbacks = new List.unmodifiable(callbacks);
2016-08-29 00:04:48 +02:00
}