acme/src/typesystem.c

54 lines
1.1 KiB
C

// ACME - a crossassembler for producing 6502/65c02/65816 code.
// Copyright (C) 1998-2014 Marco Baye
// Have a look at "acme.c" for further info
//
// Type system stuff
#include "typesystem.h"
#include "config.h"
#include "alu.h"
#include "global.h"
static int in_address_block = FALSE;
static int in_address_statement = FALSE;
// Functions
int typesystem_says_address(void)
{
return in_address_block | in_address_statement;
}
void typesystem_force_address_block(void)
{
int buffer = in_address_block;
in_address_block = TRUE;
Parse_optional_block();
in_address_block = buffer;
}
void typesystem_force_address_statement(int value)
{
in_address_statement = value;
}
void typesystem_want_imm(struct result_t *result)
{
if (!warn_on_type_mismatch)
return;
if (!(result->flags & MVALUE_DEFINED))
return;
if (result->addr_refs != 0)
Throw_warning("Wrong type - expected integer.");
}
void typesystem_want_addr(struct result_t *result)
{
if (!warn_on_type_mismatch)
return;
if (!(result->flags & MVALUE_DEFINED))
return;
if (result->addr_refs != 1)
Throw_warning("Wrong type - expected address.");
}