Alien-LibJIT

 view release on metacpan or  search on metacpan

libjit/dpas/dpas-builtin.c  view on Meta::CPAN

/*
 * dpas-builtin.c - Handling for Dynamic Pascal builtins.
 *
 * Copyright (C) 2004  Southern Storm Software, Pty Ltd.
 *
 * This file is part of the libjit library.
 *
 * The libjit library is free software: you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * The libjit library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with the libjit library.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#include "dpas-internal.h"
#include <stdio.h>
#include <stdlib.h>

/*
 * Functions for writing values to stdout.
 */
static void dpas_write_ln(void)
{
	putc('\n', stdout);
}
static void dpas_write_int(jit_int value)
{
	printf("%ld", (long)value);
}
static void dpas_write_uint(jit_uint value)
{
	printf("%lu", (unsigned long)value);
}
static void dpas_write_long(jit_long value)
{
	jit_constant_t val;
	char *name;
	val.type = jit_type_long;
	val.un.long_value = value;
	name = dpas_constant_name(&val);
	fputs(name, stdout);
	jit_free(name);
}
static void dpas_write_ulong(jit_ulong value)
{
	jit_constant_t val;
	char *name;
	val.type = jit_type_ulong;
	val.un.ulong_value = value;
	name = dpas_constant_name(&val);
	fputs(name, stdout);
	jit_free(name);
}
static void dpas_write_nfloat(jit_nfloat value)
{
	printf("%g", (double)value);
}
static void dpas_write_string(char *value)
{
	if(value)
	{
		fputs(value, stdout);
	}
	else
	{
		fputs("(null)", stdout);
	}
}

/*
 * Call a native builtin function.
 */



( run in 1.133 second using v1.01-cache-2.11-cpan-df04353d9ac )