| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2021-07-08 00:30:56 +01:00
										 |  |  |  * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org> | 
					
						
							| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <LibCrypto/BigInt/SignedBigInteger.h>
 | 
					
						
							| 
									
										
										
										
											2021-05-17 19:50:20 +02:00
										 |  |  | #include <LibJS/Heap/Cell.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class BigInt final : public Cell { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     BigInt(Crypto::SignedBigInteger); | 
					
						
							|  |  |  |     virtual ~BigInt(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const Crypto::SignedBigInteger& big_integer() const { return m_big_integer; } | 
					
						
							| 
									
										
										
										
											2021-06-29 17:51:52 +03:00
										 |  |  |     const String to_string() const { return String::formatted("{}n", m_big_integer.to_base(10)); } | 
					
						
							| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     virtual const char* class_name() const override { return "BigInt"; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Crypto::SignedBigInteger m_big_integer; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BigInt* js_bigint(Heap&, Crypto::SignedBigInteger); | 
					
						
							| 
									
										
										
										
											2021-08-03 00:14:48 +01:00
										 |  |  | BigInt* js_bigint(VM&, Crypto::SignedBigInteger); | 
					
						
							| 
									
										
										
										
											2021-07-08 00:30:56 +01:00
										 |  |  | BigInt* number_to_bigint(GlobalObject&, Value); | 
					
						
							| 
									
										
										
										
											2020-06-06 01:14:10 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |