OpenCores
URL https://opencores.org/ocsvn/raptor64/raptor64/trunk

Subversion Repositories raptor64

[/] [raptor64/] [trunk/] [software/] [c64/] [source/] [Symbol.c] - Blame information for rev 37

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 37 robfinch
// ============================================================================
2
// (C) 2012 Robert Finch
3
// All Rights Reserved.
4
// robfinch<remove>@opencores.org
5
//
6
// C64 - Raptor64 'C' derived language compiler
7
//  - 64 bit CPU
8
//
9
// This source file is free software: you can redistribute it and/or modify 
10
// it under the terms of the GNU Lesser General Public License as published 
11
// by the Free Software Foundation, either version 3 of the License, or     
12
// (at your option) any later version.                                      
13
//                                                                          
14
// This source file is distributed in the hope that it will be useful,      
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            
17
// GNU General Public License for more details.                             
18
//                                                                          
19
// You should have received a copy of the GNU General Public License        
20
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    
21
//                                                                          
22
// ============================================================================
23
//
24
#include <stdio.h>
25
#include <string.h>
26
#include "c.h"
27
#include "expr.h"
28
#include "Statement.h"
29
#include "gen.h"
30
#include "cglbdec.h"
31
 
32
static unsigned __int8 hashadd(char *nm)
33
{
34
        unsigned __int8 hsh;
35
 
36
        for(hsh=0;*nm;nm++)
37
                hsh += *nm;
38
        return hsh;
39
}
40
 
41
SYM *search(char *na,TABLE *tbl)
42
{
43
        SYM *thead;
44
        if (tbl==&gsyms[0])
45
                thead = gsyms[hashadd(na)].head;
46
        else
47
                thead = tbl->head;
48
        while( thead != NULL) {
49
                if (thead->name != NULL)
50
                        if(strcmp(thead->name,na) == 0)
51
                                return thead;
52
        thead = thead->next;
53
    }
54
    return NULL;
55
}
56
 
57
SYM *gsearch(char *na)
58
{
59
        SYM *sp;
60
 
61
        if((sp = search(na,&lsyms)) == NULL)
62
        sp = search(na,&gsyms[0]);
63
    return sp;
64
}
65
 
66
void insert(SYM* sp, TABLE *table)
67
{
68
        if (table==&gsyms[0])
69
                table = &gsyms[hashadd(sp->name)];
70
        if( search(sp->name,table) == NULL) {
71
        if( table->head == NULL)
72
            table->head = table->tail = sp;
73
        else {
74
            table->tail->next = sp;
75
            table->tail = sp;
76
        }
77
        sp->next = NULL;
78
    }
79
    else
80
        error(ERR_DUPSYM);
81
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.