Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
gcc-python-plugin/gcc-python-function.c at master · frederik-h/gcc-python-plugin · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
frederik-h
/
gcc-python-plugin
Public
forked from
davidmalcolm/gcc-python-plugin
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
gcc-python-plugin
/
gcc-python-function.c
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
189 lines (158 loc) · 5.12 KB
master
Breadcrumbs
gcc-python-plugin
/
gcc-python-function.c
Copy path
Top
File metadata and controls
Code
Blame
189 lines (158 loc) · 5.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*
Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>
Copyright 2011, 2012 Red Hat, Inc.
This 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 3 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, see
<http://www.gnu.org/licenses/>.
*/
#include
<Python.h>
#include
"gcc-python.h"
#include
"gcc-python-wrappers.h"
/*
"struct function" is declared in function.h, c.f.:
struct GTY(()) function {
... snip ...
};
*/
#include
"function.h"
#include
"gcc-c-api/gcc-function.h"
PyObject
*
PyGccFunction_repr
(
struct
PyGccFunction
*
self
)
{
const
char
*
name
=
NULL
;
PyObject
*
result
=
NULL
;
tree
decl
;
assert
(
self
->
fun
.
inner
);
decl
=
self
->
fun
.
inner
->
decl
;
if
(
DECL_NAME
(
decl
)) {
name
=
IDENTIFIER_POINTER
(
DECL_NAME
(
decl
));
}
else
{
name
=
"(unnamed)"
;
}
if
(!
name
) {
goto
error
;
}
result
=
PyGccString_FromFormat
(
"gcc.Function('%s')"
,
name
);
return
result
;
error
:
Py_XDECREF
(
result
);
return
NULL
;
}
long
PyGccFunction_hash
(
struct
PyGccFunction
*
self
)
{
return
(
long
)
self
->
fun
.
inner
;
}
PyObject
*
PyGccFunction_richcompare
(
PyObject
*
o1
,
PyObject
*
o2
,
int
op
)
{
struct
PyGccFunction
*
functionobj1
;
struct
PyGccFunction
*
functionobj2
;
int
cond
;
PyObject
*
result_obj
;
if
(!
PyObject_TypeCheck
(
o1
, (
PyTypeObject
*
)
&
PyGccFunction_TypeObj
)) {
result_obj
=
Py_NotImplemented
;
goto
out
;
}
if
(!
PyObject_TypeCheck
(
o2
, (
PyTypeObject
*
)
&
PyGccFunction_TypeObj
)) {
result_obj
=
Py_NotImplemented
;
goto
out
;
}
functionobj1
=
(
struct
PyGccFunction
*
)
o1
;
functionobj2
=
(
struct
PyGccFunction
*
)
o2
;
switch
(
op
) {
case
Py_EQ
:
cond
=
(
functionobj1
->
fun
.
inner
==
functionobj2
->
fun
.
inner
);
break
;
case
Py_NE
:
cond
=
(
functionobj1
->
fun
.
inner
!=
functionobj2
->
fun
.
inner
);
break
;
default
:
result_obj
=
Py_NotImplemented
;
goto
out
;
}
result_obj
=
cond
?
Py_True
:
Py_False
;
out
:
Py_INCREF
(
result_obj
);
return
result_obj
;
}
PyObject
*
PyGccFunction_New
(
gcc_function
func
)
{
struct
PyGccFunction
*
obj
;
if
(!
func
.
inner
) {
Py_RETURN_NONE
;
}
#if
0
printf
(
"PyGccFunction_New(%p)\n"
,
fun
);
printf
(
"struct eh_status *eh: %p\n"
,
fun
->
eh
);
printf
(
"struct control_flow_graph *cfg: %p\n"
,
fun
->
cfg
);
printf
(
"struct gimple_seq_d *gimple_body: %p\n"
,
fun
->
gimple_body
);
printf
(
"struct gimple_df *gimple_df: %p\n"
,
fun
->
gimple_df
);
printf
(
"struct loops *x_current_loops: %p\n"
,
fun
->
x_current_loops
);
printf
(
"struct stack_usage *su: %p\n"
,
fun
->
su
);
#if
0
printf
(
"htab_t GTY((skip)) value_histogram\n"
);
printf
(
"tree decl: %p;\n"
,
fun
->
decl
);
printf
(
"tree static_chain_decl;\n"
);
printf
(
"tree nonlocal_goto_save_area;\n"
);
printf
(
"VEC(tree,gc) *local_decls: local_decls;\n"
);
printf
(
"struct machine_function * GTY ((maybe_undef)) machine;\n"
);
printf
(
"struct language_function * language;\n"
);
printf
(
"htab_t GTY ((param_is (union tree_node))) used_types_hash;\n"
);
printf
(
"int last_stmt_uid;\n"
);
printf
(
"int funcdef_no;\n"
);
printf
(
"location_t function_start_locus;\n"
);
printf
(
"location_t function_end_locus;\n"
);
printf
(
"unsigned int curr_properties;\n"
);
printf
(
"unsigned int last_verified;\n"
);
printf
(
"const char * GTY((skip)) cannot_be_copied_reason;\n"
);
printf
(
"unsigned int va_list_gpr_size : 8;\n"
);
printf
(
"unsigned int va_list_fpr_size : 8;\n"
);
printf
(
"unsigned int calls_setjmp : 1;\n"
);
printf
(
"unsigned int calls_alloca : 1;\n"
);
printf
(
"unsigned int has_nonlocal_label : 1;\n"
);
printf
(
"unsigned int cannot_be_copied_set : 1;\n"
);
printf
(
"unsigned int stdarg : 1;\n"
);
printf
(
"unsigned int dont_save_pending_sizes_p : 1;\n"
);
printf
(
"unsigned int after_inlining : 1;\n"
);
printf
(
"unsigned int always_inline_functions_inlined : 1;\n"
);
printf
(
"unsigned int can_throw_non_call_exceptions : 1;\n"
);
printf
(
"unsigned int returns_struct : 1;\n"
);
printf
(
"unsigned int returns_pcc_struct : 1;\n"
);
printf
(
"unsigned int after_tree_profile : 1;\n"
);
printf
(
"unsigned int has_local_explicit_reg_vars : 1;\n"
);
printf
(
"unsigned int is_thunk : 1;\n"
);
#endif
#endif
obj
=
PyGccWrapper_New
(
struct
PyGccFunction
,
&
PyGccFunction_TypeObj
);
if
(!
obj
) {
goto
error
;
}
obj
->
fun
=
func
;
return
(
PyObject
*
)
obj
;
error
:
return
NULL
;
}
void
PyGcc_WrtpMarkForPyGccFunction
(
PyGccFunction
*
wrapper
)
{
/* Mark the underlying object (recursing into its fields): */
gcc_function_mark_in_use
(
wrapper
->
fun
);
}
/*
PEP-7
Local variables:
c-basic-offset: 4
indent-tabs-mode: nil
End:
*/
You can’t perform that action at this time.