1// Copyright 2019 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include 'src/builtins/builtins-regexp-gen.h'
6
7namespace regexp {
8
9// ES6 21.2.5.10.
10// ES #sec-get-regexp.prototype.source
11transitioning javascript builtin RegExpPrototypeSourceGetter(
12    js-implicit context: NativeContext, receiver: JSAny)(): JSAny {
13  typeswitch (receiver) {
14    case (receiver: JSRegExp): {
15      return receiver.source;
16    }
17    case (Object): {
18    }
19  }
20  if (!IsReceiverInitialRegExpPrototype(receiver)) {
21    const methodName: constexpr string = 'RegExp.prototype.source';
22    ThrowTypeError(MessageTemplate::kRegExpNonRegExp, methodName);
23  }
24  IncrementUseCounter(context, SmiConstant(kRegExpPrototypeSourceGetter));
25  return '(?:)';
26}
27}
28