Skip to content

Commit 9062741

Browse files
committed
Doc header classfile + OperandsFrame
1 parent 1b3781b commit 9062741

File tree

2 files changed

+122
-10
lines changed

2 files changed

+122
-10
lines changed

Diff for: classfile.h

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/**
2+
* @file classfile.h
3+
* @brief Leitor / Exibidor
4+
* File containing the definition of a classfile, structure created from the data
5+
* read from a .class file, and functions with the purpose of reading from the file (read),
6+
* display the classfile created (print), retrieve of values from a created constant pool (get),
7+
* and free the memory allocated at the end of the programs execution.
8+
*
9+
*/
10+
111
#pragma once
212
#include <stdio.h>
313
#include <stdint.h>

Diff for: frame.h

+112-10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @file frame.h
3+
* @brief Frame
4+
* File containing the definition of a frame structure and functions to realize
5+
* operations to change it.
6+
*
7+
*/
8+
19
#pragma once
210

311
#include <stdio.h>
@@ -6,43 +14,137 @@
614
#include <assert.h>
715
#include "classfile.h"
816

17+
/**
18+
* @brief Frame structure.
19+
*
20+
* Structure that stores the information that defines and is utilized by a frame from a JVM.
21+
*/
922
typedef struct Frame {
10-
void *jvm; /* pointer to respective jvm reference */
11-
uint32_t n_locals; /* computed at compile time */
12-
uint64_t *locals; /* array of local variables */
13-
uint32_t n_operands; /* computed at compile time */
14-
uint64_t *operands; /* stack of operands */
15-
uint32_t i; /* top of stack index */
16-
cp_info *cp; /* reference to constant pool of class */
17-
uint32_t pc; /* jvm's pc upon method call */
18-
int32_t class_index; /* class index in method area */
19-
int32_t method_index; /* method index in class */
23+
void *jvm; /**< pointer to respective jvm reference */
24+
uint32_t n_locals; /**< computed at compile time */
25+
uint64_t *locals; /**< array of local variables */
26+
uint32_t n_operands; /**< computed at compile time */
27+
uint64_t *operands; /**< stack of operands */
28+
uint32_t i; /**< top of stack index */
29+
cp_info *cp; /**< reference to constant pool of class */
30+
uint32_t pc; /**< jvm's pc upon method call */
31+
int32_t class_index; /**< class index in method area */
32+
int32_t method_index; /**< method index in class */
2033
} Frame;
2134

35+
/**
36+
* Initializes a frame pointed by a jvm
37+
*/
2238
void init_frame(Frame *f, void *jvm, uint32_t n_locals, uint32_t n_operands, cp_info *cp,
2339
int32_t class_index, int32_t method_index);
40+
41+
/**
42+
* Deinitializes frame memory area pointed to by jvm pointer.
43+
* Notably, locals, operands, and auxiliary structures are freed
44+
* @param f non-null pointer to a frame struct to be deinitialized
45+
*/
2446
void deinit_frame(Frame *f);
2547

48+
/**
49+
* Push an integer to the top of the frame operand stack.
50+
* @param operand integer operand to be added to the stack.
51+
* @param f pointer to the current frame.
52+
*/
2653
void push_stack(Frame *f, uint64_t operand);
54+
55+
/**
56+
* Pop an integer of the top of the frame operand stack.
57+
* @param f pointer to the current frame.
58+
*/
2759
uint64_t pop_stack(Frame *f);
60+
61+
/**
62+
* Return de value of an integer of the top of the frame operand stack.
63+
* @param f pointer to the current frame.
64+
*/
2865
uint64_t peek_stack(Frame *f);
2966

67+
68+
/**
69+
* Push a double to the top of the frame operand stack.
70+
* @param operand double operand to be added to the stack.
71+
* @param f pointer to the current frame.
72+
*/
3073
void push_stack_double(Frame *f, double d);
74+
75+
/**
76+
* Pop a double of the top of the frame operand stack.
77+
* @param f pointer to the current frame.
78+
*/
3179
double pop_stack_double(Frame *f);
3280

81+
82+
/**
83+
* Push a long to the top of the frame operand stack.
84+
* @param operand long operand to be added to the stack.
85+
* @param f pointer to the current frame.
86+
*/
3387
void push_stack_long(Frame *f, int64_t x);
88+
89+
/**
90+
* Pop a long of the top of the frame operand stack.
91+
* @param f pointer to the current frame.
92+
*/
3493
int64_t pop_stack_long(Frame *f);
3594

95+
96+
/**
97+
* Push a float to the top of the frame operand stack.
98+
* @param operand float operand to be added to the stack.
99+
* @param f pointer to the current frame.
100+
*/
36101
void push_stack_float(Frame *f, float x);
102+
103+
/**
104+
* Pop a float of the top of the frame operand stack.
105+
* @param f pointer to the current frame.
106+
*/
37107
float pop_stack_float(Frame *f);
38108

109+
/**
110+
* Push a 32 bits integer to the top of the frame operand stack.
111+
* @param operand integer operand to be added to the stack.
112+
* @param f pointer to the current frame.
113+
*/
39114
void push_stack_int(Frame *f, int32_t x);
115+
116+
/**
117+
* Pop a 32 bits integer of the top of the frame operand stack.
118+
* @param f pointer to the current frame.
119+
*/
40120
int32_t pop_stack_int(Frame *f);
41121

122+
123+
/**
124+
* Push a void pointer to the top of the frame operand stack.
125+
* @param operand pointer operand to be added to the stack.
126+
* @param f pointer to the current frame.
127+
*/
42128
void push_stack_pointer(Frame *f, void *ptr);
129+
130+
/**
131+
* Pop a void pointer of the top of the frame operand stack.
132+
* @param f pointer to the current frame.
133+
*/
43134
void *pop_stack_pointer(Frame *f);
44135

136+
137+
/**
138+
* Push a byte to the top of the frame operand stack.
139+
* @param operand byte operand to be added to the stack.
140+
* @param f pointer to the current frame.
141+
*/
45142
void push_stack_byte(Frame *f, int8_t x);
143+
144+
/**
145+
* Pop a byte of the top of the frame operand stack.
146+
* @param f pointer to the current frame.
147+
*/
46148
int8_t pop_stack_byte(Frame *f);
47149

48150
void frame_set_local(Frame *f, uint32_t index, uint64_t value);

0 commit comments

Comments
 (0)