cppbltin.c

来自「CC386 is a general-purpose 32-bit C comp」· C语言 代码 · 共 107 行

C
107
字号
/* 
Copyright 1994-2003 Free Software Foundation, Inc.

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., 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.  

This program is derived from the cc68k complier by 
Matthew Brandt (mattb@walkingdog.net) 

You may contact the author of this derivative at:

mailto::camille@bluegrass.net

or by snail mail at:

David Lindauer
850 Washburn Ave Apt 99
Louisville, KY 40222
 */
/* Handles name mangling
 */
#include <stdio.h>
#include <malloc.h>
#include <ctype.h>
#include <string.h>
#include "lists.h"
#include "expr.h"
#include "c.h"
#include "ccerr.h"

extern int prm_cplusplus;
extern short *interjectptr;
extern TABLE *gsyms;
extern TABLE *tagtable;
extern int sys_inc;

SYM *dynamic_cast_func;
SYM *catch_cleanup_func;
SYM *typeinfo_class;
SYM *get_typeinfo_func;
SYM *throw_func;
SYM *rethrow_func;
SYM *global_vararray_func;

static short *cppbuiltin = L"void * operator new(unsigned size); " 
    L"void * operator new[](unsigned size); " 
    L"void   operator delete  (void *); " 
	L"void   operator delete[](void *); "
    L"void * _dynamic_cast(void *, void *, void *); " 
    L"void   _CatchCleanup(); " 
    L"void * __GetTypeInfo(void *block, void *instance); " 
    L"void _ThrowException(void *,void *,void*); " 
	L"void _RethrowException(); ";

static short *cbuiltin = L"void * __vararray_alloc(int); ";

void installCPPBuiltins(void)
{
    sys_inc = TRUE; // don't put in list file
    if (prm_cplusplus)
    {
        interjectptr = cppbuiltin;
        getch();
        getsym();
        dodecl(sc_global);
        interjectptr = 0;
        dynamic_cast_func = search("__dynamic_cast", gsyms);
        if (dynamic_cast_func)
            dynamic_cast_func = dynamic_cast_func->tp->lst.head;

        catch_cleanup_func = search("__CatchCleanup", gsyms);
        if (catch_cleanup_func)
            catch_cleanup_func = catch_cleanup_func->tp->lst.head;
        throw_func = search("__ThrowException", gsyms);
        if (throw_func)
            throw_func = throw_func->tp->lst.head;
        rethrow_func = search("__RethrowException", gsyms);
        if (rethrow_func)
            rethrow_func = rethrow_func->tp->lst.head;
        get_typeinfo_func = search("___GetTypeInfo", gsyms);
        if (get_typeinfo_func)
            get_typeinfo_func = get_typeinfo_func->tp->lst.head;
    }
    // builtins for C language
    interjectptr = cbuiltin;
    getch();
    getsym();
    dodecl(sc_global);
    interjectptr = 0;
    global_vararray_func = search("___vararray_alloc", gsyms);
    if (prm_cplusplus && global_vararray_func)
        global_vararray_func = global_vararray_func->tp->lst.head;
    sys_inc = FALSE;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?