Skip to content

Commit

Permalink
Merge pull request #150 from nbrown/m0-prototype-c-hello-world
Browse files Browse the repository at this point in the history
M0 prototype c hello world
  • Loading branch information
leto committed Aug 9, 2011
2 parents 24bd618 + 04a055e commit b2bf853
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/m0/c/include/m0_ops.h
Expand Up @@ -33,6 +33,10 @@ enum M0_OPS {
M0_SET_IMM,
M0_DEREF,
M0_SET_REF,
M0_SET_BYTE,
M0_GET_BYTE,
M0_SET_WORD,
M0_GET_WORD,
M0_CSYM,
M0_CCALL_ARG,
M0_CCALL_RET,
Expand All @@ -41,8 +45,8 @@ enum M0_OPS {
M0_PRINT_I,
M0_PRINT_N,
M0_EXIT
};

};
int
run_ops( M0_Interp *interp, M0_CallFrame *cf );

Expand Down
19 changes: 16 additions & 3 deletions src/m0/c/m0_mob.c
Expand Up @@ -169,9 +169,12 @@ add_chunk( M0_Interp *interp, const char *name, unsigned long chunk_id,
chunk->id = chunk_id;
chunk->name = name;
chunk->name_length = name_length;
chunk->next = NULL;

if (!interp->first_chunk)
if (!interp->first_chunk) {
interp->first_chunk = chunk;
interp->last_chunk = chunk;
}
else {
interp->last_chunk->next = chunk;
interp->last_chunk = chunk;
Expand Down Expand Up @@ -217,8 +220,18 @@ parse_mob_constants_segment( M0_Interp *interp, FILE *stream ) {

for (i = 0; i < const_count; i++) {
const unsigned long length = read_long_from_stream( stream );
const char *constant =
(const char *)read_from_stream( stream, length );
const char *constant = NULL;
if (length <= 8) {
constant = read_from_stream( stream, length );
} else {
int string_len = read_long_from_stream(stream);
int encoding = read_long_from_stream(stream);
if (encoding == 0) {
// TODO
} else {
constant = read_from_stream(stream, string_len);
}
}

if (constant)
segment->consts[i] = constant;
Expand Down

0 comments on commit b2bf853

Please sign in to comment.