Skip to content

Commit b6cc04e

Browse files
committedDec 4, 2019
jvm.h e object.h
1 parent a8cd6ad commit b6cc04e

File tree

6 files changed

+86
-22
lines changed

6 files changed

+86
-22
lines changed
 

‎Project.dev

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ ObjectOutput=
1919
LogOutput=
2020
LogOutputEnabled=0
2121
OverrideOutput=0
22-
OverrideOutputName=Project1.exe
22+
OverrideOutputName=Project.exe
2323
HostApplication=
2424
UseCustomMakefile=1
25-
CustomMakefile=classreader\Makefile
26-
CommandLine=
25+
CustomMakefile=MakefileWin
26+
CommandLine=Harmonic
2727
Folders=
2828
IncludeVersionInfo=0
2929
SupportXPThemes=0
3030
CompilerSet=0
31-
CompilerSettings=1000000000000000001000000
31+
CompilerSettings=0000000000000000000000000
3232
UnitCount=19
3333

3434
[VersionInfo]

‎Project.layout

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[Editors]
2-
Order=9,2
2+
Order=
33
Focused=2
44
[Editor_2]
55
CursorCol=17

‎constant_info.h

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* @file constant_info.h
3+
* @brief Constants definitions
4+
* File containing the definitions for each type of constant
5+
* and the structures with the information of the .class file main components.
6+
*
7+
*/
8+
19
#pragma once
210
#include <stdint.h>
311
#include <stdio.h>
@@ -22,6 +30,11 @@
2230
assert(ptr); \
2331
assert(fp); \
2432

33+
/**
34+
* @brief Info of type class.
35+
*
36+
* Structure that stores specific information about a constant of type Class (id 7)
37+
*/
2538
/* id 7 */
2639
typedef struct {
2740
uint16_t name_index;

‎jvm.h

+32-16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* @file jvm.h
3+
* @brief Interpreter
4+
* File containing the main implementation of the interpreter.
5+
*
6+
*/
17
#pragma once
28

39
#include <stdio.h>
@@ -14,31 +20,41 @@
1420
#define MAXHEAP 256
1521
#define MAXSTATICS 256
1622

23+
/**
24+
* @brief Static attribute.
25+
*
26+
* Structure to store a static attribute of a class.
27+
*/
1728
typedef struct Static {
18-
char *class;
19-
char *name;
20-
char *type;
21-
ObjectField value;
29+
char *class; /**< Class name */
30+
char *name; /**< Attribute name */
31+
char *type; /**< Attribute type name */
32+
ObjectField value; /**< Attribute value */
2233
} Static;
2334

35+
/**
36+
* @brief Interpreter structure.
37+
*
38+
* Structure that stores the information utilized by the JVM interpreter and defines it.
39+
*/
2440
typedef struct JVM {
25-
uint32_t pc;
26-
Frame *frames[MAX_FRAMES];
27-
int32_t frame_index; /* top of frame stack index */
41+
uint32_t pc; /**< Program counter */
42+
Frame *frames[MAX_FRAMES]; /**< Pointer to frame stack */
43+
int32_t frame_index; /**< Top index of frame stack */
2844
/* uint8_t *heap; */
29-
MethodArea *method_area;
45+
MethodArea *method_area; /**< Pointer to method area */
3046
/* NativeMethodArea nma; */
31-
int32_t current_class_index;
47+
int32_t current_class_index;
3248
int32_t current_method_index;
33-
bool jmp;
34-
bool ret;
35-
uint64_t retval;
49+
bool jmp; /**< If will ocurr a jump */
50+
bool ret; /**< If will return */
51+
uint64_t retval; /**< Value that will be returned */
3652

37-
void *heap[MAXHEAP];
38-
int32_t heap_index;
53+
void *heap[MAXHEAP]; /**< Pointer to heap area */
54+
int32_t heap_index; /**< Top index of heap */
3955

40-
Static *statics[MAXSTATICS];
41-
int32_t static_index;
56+
Static *statics[MAXSTATICS]; /**< Pointer to static objects stack*/
57+
int32_t static_index; /**< Top index of static stack*/
4258
} JVM;
4359

4460
/**

‎main.c

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@
44
#include "classfile.h"
55
#include "jvm.h"
66

7+
/** \mainpage JVM implementation - 2019/2 - G6
8+
*
9+
* \section intro_sec Introduction
10+
*
11+
* This is the introduction.
12+
*
13+
* \section install_sec How to execute:
14+
*
15+
* \subsection step1 Step 1: Make
16+
*
17+
* \section students_sec Students
18+
*
19+
* \subsection name1 Giordano S. Monteiro
20+
* \subsection name2 Breno
21+
* \subsection name3 Filipi
22+
* \subsection name4 Igor Bispo
23+
*
24+
*/
25+
726
int main(int argc, char *argv[]) {
827
if (argc != 2 && argc != 3) {
928
printf("Usage: %s [class file] [i/le]\n", argv[0]);

‎object.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
/**
2+
* @file object.h
3+
* @brief Object definitions
4+
* File containing the definitions necessary to create a object.
5+
*
6+
*/
17
#pragma once
28

39
#include <stdint.h>
410

11+
/**
12+
* @brief Field or Attribute of an Object.
13+
*
14+
* Union to store generically attributes values.
15+
*/
516
typedef union {
617
uint8_t boolfield;
718
int8_t bytefield;
@@ -14,7 +25,12 @@ typedef union {
1425
void *ptrfield;
1526
} ObjectField;
1627

28+
/**
29+
* @brief Object.
30+
*
31+
* Structure to store a object from a class.
32+
*/
1733
typedef struct Object {
1834
int size;
19-
ObjectField *fields;
35+
ObjectField *fields; /**<Attributes */
2036
} Object;

0 commit comments

Comments
 (0)
Please sign in to comment.