<commit_before>#include "print.h"
#include "general.h"


static void print(Runtime *runtime
	            , Object *context
	            , Object *object){
	if(!object){
		printf("NULL");
		return;
	}

	switch(BuiltIn_protoId(object)){
	case BUILTIN_STRING:
		printf("%s", (char*) Object_getDataDeep(object, "__data"));
		break;
	case BUILTIN_NUMBER:
		printf("%f", *((double*) Object_getDataDeep(object, "__data")));
		break;
	case BUILTIN_ATOM:
		{
			char *field = ImpAtom_getRaw(object);
			Object *mapping = Object_getDeep(context, field);
			print(runtime, context, mapping);
		}
		break;
	default:
		// TODO
		break;
	}
}


static Object *ImpPrinter_activate_internal(Runtime *runtime
	                             , Object *context
	                             , Object *caller
	                             , int argc
	                             , Object **argv){
	// TODO: search for specially-defined tostring method
	// Object *special = Object_getDeep(subs[0], "_toString");
	// if(special){
	// }
	for(int i = 0; i < argc; i++){
		print(runtime, context, argv[i]);
		if(argc > 1 && i < argc - 1){
			printf(" ");
		}
	}
	printf("\n");
	return NULL;
}

void ImpPrinter_init(Object *self){
	BuiltIn_setId(self, BUILTIN_PRINTER);<commit_msg>fixed atom printing bug<commit_after>#include "print.h"
#include "general.h"
#include "atom.h"


static void print(Runtime *runtime
	            , Object *context
	            , Object *object){
	if(!object){
		printf("NULL");
		return;
	}

	switch(BuiltIn_protoId(object)){
	case BUILTIN_ATOM:
		print(runtime, context, Object_getDeep(context, ImpAtom_getRaw(object)));
		break;
	case BUILTIN_STRING:
		printf("%s", (char*) Object_getDataDeep(object, "__data"));
		break;
	case BUILTIN_NUMBER:
		printf("%f", *((double*) Object_getDataDeep(object, "__data")));
		break;
	default:
		// TODO
		break;
	}
}


static Object *ImpPrinter_activate_internal(Runtime *runtime
	                             , Object *context
	                             , Object *caller
	                             , int argc
	                             , Object **argv){
	// TODO: search for specially-defined tostring method
	// Object *special = Object_getDeep(subs[0], "_toString");
	// if(special){
	// }
	for(int i = 0; i < argc; i++){
		print(runtime, context, argv[i]);
		if(argc > 1 && i < argc - 1){
			printf(" ");
		}
	}
	printf("\n");
	return NULL;
}

void ImpPrinter_init(Object *self){
	BuiltIn_setId(self, BUILTIN_PRINTER);
{'fraction_non_alphanumeric': 0.14557217953902143, 'fraction_numerical': 0.003234937323089365, 'mean_word_length': 2.6597633136094676, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7008452', 'n_tokens_mistral': 865, 'n_tokens_neox': 813, 'n_words': 182}