-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathoverload.h
99 lines (78 loc) · 2.44 KB
/
overload.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/* -*- c -*- */
/*
* overload.h
*
* MathMap
*
* Copyright (C) 1997-2007 Mark Probst
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __OVERLOAD_H__
#define __OVERLOAD_H__
#include "tuples.h"
#include "builtins.h"
#include "macros.h"
#define MAX_FUNCTION_LENGTH 63
#define MAX_BINDING_LENGTH 63
typedef struct _binding_t
{
int is_bound;
int value;
struct _binding_t *next;
} binding_t;
typedef struct _named_binding_t
{
char name[MAX_BINDING_LENGTH + 1];
binding_t *binding;
struct _named_binding_t *next;
} named_binding_t;
typedef struct _overload_arg_t
{
binding_t *tag;
binding_t *length;
struct _overload_arg_t *next;
} overload_arg_t;
#define OVERLOAD_BUILTIN 1
#define OVERLOAD_MACRO 2
typedef struct _overload_entry_t
{
char name[MAX_FUNCTION_LENGTH + 1];
int type;
overload_arg_t *result;
overload_arg_t *args;
int num_args;
union
{
generator_function_t builtin_generator;
macro_function_t macro;
} v;
struct _overload_entry_t *next;
} overload_entry_t;
typedef struct _function_arg_info_t
{
tuple_info_t info;
struct _function_arg_info_t *next;
} function_arg_info_t;
binding_t* new_free_variable_binding (void);
binding_t* new_constant_binding (int value);
overload_arg_t* new_overload_argument (binding_t *tag, binding_t *length, overload_arg_t *next);
void clear_bindings (void);
binding_t* free_binding_with_name (const char *name);
void register_overloaded_builtin (const char *name, const char *argstring, generator_function_t gen);
void register_overloaded_macro (const char *name, const char *argstring, macro_function_t func);
overload_entry_t* resolve_function_call (const char *name, function_arg_info_t *args, tuple_info_t *result);
int exists_overload_entry_with_name (char *name);
#endif