3 * Copyright (C) 2006-2008, The Perl Foundation.
6 /* .NET CLI Method Metadata PMC */
9 #include "parrot/extend.h"
10 #include "tableinfo.h"
11 #include "structures.h"
14 pmclass DotNetMethodMetadata dynpmc group dotnet {
16 /* Instance initialization. We need a custom DOD marking and destroy. */
19 PObj_custom_mark_SET(SELF);
20 PObj_active_destroy_SET(SELF);
24 /* Get string vtable function; returns the name of the method. */
27 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
29 /* Handle cases where we've an invalid PMC. */
30 if (!m || !m->str_name)
31 real_exception(INTERP, NULL, E_StandardError,
32 "Invalid DotNetMethodMetadata PMC");
38 /* Garbage Collection mark routine. */
41 /* Tell the GC about stuff we're holding on to. */
42 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
46 pobject_lives(INTERP, (PObj*)m->parent);
48 pobject_lives(INTERP, (PObj*)m->str_name);
50 pobject_lives(INTERP, (PObj*)m->params);
52 pobject_lives(INTERP, (PObj*)m->bytecode);
60 /* Cleanup any memory we're using. */
61 if (PMC_struct_val(SELF)) {
62 mem_sys_free(PMC_struct_val(SELF));
63 PMC_struct_val(SELF) = NULL;
68 /* Get flags of the method. */
69 METHOD INTVAL get_flags()
71 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
74 /* Handle cases where we've an invalid PMC. */
76 real_exception(INTERP, NULL, E_StandardError,
77 "Invalid DotNetMethodMetadata PMC");
79 result = (INTVAL)m->flags;
80 RETURN(INTVAL result);
84 /* Get implementation flags of the method. */
85 METHOD INTVAL get_impl_flags()
87 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
90 /* Handle cases where we've an invalid PMC. */
92 real_exception(INTERP, NULL, E_StandardError,
93 "Invalid DotNetMethodMetadata PMC");
95 result = (INTVAL)m->implFlags;
96 RETURN(INTVAL result);
100 /* Get the position of the blob holding the signature for the method. */
101 METHOD INTVAL get_signature()
103 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
106 /* Handle cases where we've an invalid PMC. */
108 real_exception(INTERP, NULL, E_StandardError,
109 "Invalid DotNetMethodMetadata PMC");
111 result = (INTVAL)m->signature;
112 RETURN(INTVAL result);
116 /* Get bytecode PMC for the method. */
117 METHOD PMC* get_bytecode()
119 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
122 /* Handle cases where we've an invalid PMC. */
123 if (!m || m->bytecode == NULL)
124 real_exception(INTERP, NULL, E_StandardError,
125 "Invalid DotNetMethodMetadata PMC");
127 result = m->bytecode;
132 /* Get parameters PMC array for the method. */
133 METHOD PMC* get_params()
135 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
138 /* Handle cases where we've an invalid PMC. */
139 if (!m || !m->params)
140 real_exception(INTERP, NULL, E_StandardError,
141 "Invalid DotNetMethodMetadata PMC");
148 /* Get the class meta-data PMC for the method. */
149 METHOD PMC* get_class()
151 dotnet_method *m = (dotnet_method *)PMC_struct_val(SELF);
154 /* Handle cases where we've an invalid PMC. */
155 if (!m || !m->parent)
156 real_exception(INTERP, NULL, E_StandardError,
157 "Invalid DotNetMethodMetadata PMC");
167 * c-file-style: "parrot"
169 * vim: expandtab shiftwidth=4: