Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make the plunge so that names of the internal PMCs are Lorito_Str's

  • Loading branch information...
commit 0208700346164e03221a5fa9de5ae2e066301de6 1 parent ad6297f
@atrodo authored
View
10 internal_pmc.c
@@ -81,13 +81,13 @@ lorito_box_str_new(Lorito_Interp *interp, Lorito_Str *str)
}
Lorito_File *
-lorito_file_new(Lorito_Interp *interp, const char *name)
+lorito_file_new(Lorito_Interp *interp, Lorito_Str *name)
{
Lorito_File *result = (Lorito_File *) malloc(sizeof(Lorito_File));
result->pmc.size = 0;
result->pmc.internal_type = FILE_BLOCK;
- result->name = strdup(name);
+ result->name = name;
result->codeseg_count = 0;
result->constseg_count = 0;
@@ -100,7 +100,7 @@ lorito_file_new(Lorito_Interp *interp, const char *name)
}
Lorito_Codeseg *
-lorito_code_block_new(Lorito_Interp *interp, char *name, int length, Lorito_Opcode *code)
+lorito_code_block_new(Lorito_Interp *interp, Lorito_Str *name, int length, Lorito_Opcode *code)
{
Lorito_Codeseg *result = (Lorito_Codeseg *) malloc(sizeof(Lorito_Codeseg));
@@ -116,7 +116,7 @@ lorito_code_block_new(Lorito_Interp *interp, char *name, int length, Lorito_Opco
}
Lorito_Constseg *
-lorito_const_block_new(Lorito_Interp *interp, char *name, int length, void *data)
+lorito_const_block_new(Lorito_Interp *interp, Lorito_Str *name, int length, void *data)
{
Lorito_Constseg *result = (Lorito_Constseg *) malloc(sizeof(Lorito_Constseg));
@@ -132,7 +132,7 @@ lorito_const_block_new(Lorito_Interp *interp, char *name, int length, void *data
}
Lorito_Datadefseg *
-lorito_datadef_block_new(Lorito_Interp *interp, char *name, int length)
+lorito_datadef_block_new(Lorito_Interp *interp, Lorito_Str *name, int length)
{
void *data = (void *) malloc(sizeof(Lorito_Opcode) * length);
Lorito_Datadefseg *result = (Lorito_Datadefseg *) malloc(sizeof(Lorito_Datadefseg));
View
8 internal_pmc.h
@@ -30,16 +30,16 @@ Lorito_PMC *
lorito_box_str_new(Lorito_Interp *interp, Lorito_Str *str);
Lorito_File *
-lorito_file_new(Lorito_Interp *interp, const char *name);
+lorito_file_new(Lorito_Interp *interp, Lorito_Str *name);
Lorito_Codeseg *
-lorito_code_block_new(Lorito_Interp *interp, char *name, int length, Lorito_Opcode *code);
+lorito_code_block_new(Lorito_Interp *interp, Lorito_Str *name, int length, Lorito_Opcode *code);
Lorito_Constseg *
-lorito_const_block_new(Lorito_Interp *interp, char *name, int length, void *data);
+lorito_const_block_new(Lorito_Interp *interp, Lorito_Str *name, int length, void *data);
Lorito_Datadefseg *
-lorito_datadef_block_new(Lorito_Interp *interp, char *name, int length);
+lorito_datadef_block_new(Lorito_Interp *interp, Lorito_Str *name, int length);
Lorito_Ctx *
lorito_ctx_new(Lorito_Interp *interp, Lorito_Ctx *next_ctx, Lorito_PMC *codeseg);
View
4 internal_pmc/context.c
@@ -50,7 +50,7 @@ lorito_internal_pmc_context_get_dataseg(Lorito_Interp *interp, Lorito_Ctx *ctx)
}
else
{
- name = lorito_string(interp, 0, self_ctx->current_constseg->name);
+ name = self_ctx->current_constseg->name;
}
Lorito_File *file = self_ctx->current_file;
@@ -58,7 +58,7 @@ lorito_internal_pmc_context_get_dataseg(Lorito_Interp *interp, Lorito_Ctx *ctx)
int i;
for (i = 0; i < file->datadefseg_count; i++)
{
- if (lorito_string(interp, 0, file->datadefsegs[i]->name) == name)
+ if (file->datadefsegs[i]->name == name)
{
lorito_push_arg(interp, ctx, PMC file->datadefsegs[i]);
break;
View
12 loader.c
@@ -17,6 +17,8 @@
// 0b0010: Main, This segement is an entry point
#include "lorito.h"
+#include "pmc.h"
+#include "interp.h"
#include "internal_pmc.h"
#include "loader.h"
#include <stdio.h>
@@ -96,7 +98,7 @@ loadbc(Lorito_Interp *interp, const char* filename)
lorito_pmc_init(interp, (Lorito_PMC *) file);
*/
- Lorito_File *file = lorito_file_new(interp, filename);
+ Lorito_File *file = lorito_file_new(interp, lorito_string(interp, 0, filename));
interp->files[fileid] = file;
file->fileid = fileid;
@@ -137,7 +139,7 @@ loadbc(Lorito_Interp *interp, const char* filename)
if (interp->files == NULL)
abort();
- Lorito_Codeseg *codeseg = lorito_code_block_new(interp, name, length, op);
+ Lorito_Codeseg *codeseg = lorito_code_block_new(interp, lorito_string(interp, 0, name), length, op);
file->codesegs[file->codeseg_count] = codeseg;
file->codeseg_count++;
@@ -174,7 +176,7 @@ loadbc(Lorito_Interp *interp, const char* filename)
if (interp->files == NULL)
abort();
- Lorito_Constseg *constseg = lorito_const_block_new(interp, name, length, data);
+ Lorito_Constseg *constseg = lorito_const_block_new(interp, lorito_string(interp, 0, name), length, data);
constseg->fileid = fileid;
constseg->file = file;
@@ -206,7 +208,7 @@ loadbc(Lorito_Interp *interp, const char* filename)
if (file->datadefsegs == NULL)
abort();
- Lorito_Datadefseg *datadefseg = lorito_datadef_block_new(interp, name, length);
+ Lorito_Datadefseg *datadefseg = lorito_datadef_block_new(interp, lorito_string(interp, 0, name), length);
datadefseg->fileid = fileid;
datadefseg->file = file;
@@ -228,7 +230,7 @@ loadbc(Lorito_Interp *interp, const char* filename)
{
if ((file->codesegs[i]->flags & SEG_FLAG_init) == SEG_FLAG_init)
{
- interp->ctx = lorito_ctx_new(interp, interp->ctx, (Lorito_PMC *) file->codesegs[i]);
+ interp->ctx = lorito_ctx_new(interp, (Lorito_Ctx *) null, (Lorito_PMC *) file->codesegs[i]);
core_exec(interp);
}
}
View
8 lorito.h
@@ -173,7 +173,7 @@ struct lorito_file_t
{
struct lorito_pmc_t pmc;
int fileid;
- char* name;
+ struct lorito_str_t *name;
int codeseg_count;
struct lorito_codeseg_t** codesegs;
int constseg_count;
@@ -190,7 +190,7 @@ struct lorito_codeseg_t
struct lorito_file_t *file;
int segid;
int flags;
- char* name;
+ struct lorito_str_t *name;
// In opcodes
int length;
struct lorito_opcode_t* op;
@@ -204,7 +204,7 @@ struct lorito_constseg_t
struct lorito_file_t *file;
int segid;
int flags;
- char* name;
+ struct lorito_str_t *name;
// In bytes
int length;
void* data;
@@ -218,7 +218,7 @@ struct lorito_datadefseg_t
struct lorito_file_t *file;
int segid;
int flags;
- char* name;
+ struct lorito_str_t *name;
// In bytes
int length;
void* data;
Please sign in to comment.
Something went wrong with that request. Please try again.