| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  | #include <AK/LogStream.h>
 | 
					
						
							|  |  |  | #include <AK/String.h>
 | 
					
						
							|  |  |  | #include <LibJS/GlobalObject.h>
 | 
					
						
							|  |  |  | #include <LibJS/Heap.h>
 | 
					
						
							|  |  |  | #include <LibJS/Interpreter.h>
 | 
					
						
							|  |  |  | #include <LibJS/NativeFunction.h>
 | 
					
						
							|  |  |  | #include <LibJS/Value.h>
 | 
					
						
							|  |  |  | #include <stdio.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace JS { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-13 11:06:32 +01:00
										 |  |  | GlobalObject::GlobalObject() | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-03-15 20:51:36 +01:00
										 |  |  |     put_native_function("print", [](Object*, Vector<Value> arguments) -> Value { | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  |         for (auto& argument : arguments) | 
					
						
							| 
									
										
										
										
											2020-03-13 10:08:52 +01:00
										 |  |  |             printf("%s ", argument.to_string().characters()); | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  |         return js_undefined(); | 
					
						
							| 
									
										
										
										
											2020-03-13 11:06:32 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-03-15 20:51:36 +01:00
										 |  |  |     put_native_function("gc", [](Object* this_object, Vector<Value>) -> Value { | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  |         dbg() << "Forced garbage collection requested!"; | 
					
						
							| 
									
										
										
										
											2020-03-15 20:51:36 +01:00
										 |  |  |         this_object->heap().collect_garbage(); | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  |         return js_undefined(); | 
					
						
							| 
									
										
										
										
											2020-03-13 11:06:32 +01:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2020-03-12 20:11:35 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GlobalObject::~GlobalObject() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |