Generate bytecode while parsing

This commit is contained in:
Ilmir Usmanov
2014-07-22 20:49:51 +04:00
parent 9a0b54313d
commit efb7009cfb
16 changed files with 1882 additions and 3281 deletions
+2 -2
View File
@@ -69,9 +69,9 @@ jerry_Exit( jerry_Status_t code) /**< status code */
case ERR_GENERAL:
__printf("ERR_GENERAL\n");
break;
default:
__printf( "Return code is zero");
}
jerry_AssertFail( "Return code is zero", __FILE__, __LINE__);
}
#endif /* !JERRY_NDEBUG */
File diff suppressed because it is too large Load Diff
-28
View File
@@ -1,28 +0,0 @@
/* Copyright 2014 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PRETTY_PRINTER_H
#define PRETTY_PRINTER_H
#include "lexer.h"
#include "parser.h"
void pp_reset (void);
void pp_finish (void);
void pp_token (token);
void pp_keyword (keyword);
void pp_statement (statement);
#endif
+2
View File
@@ -22,4 +22,6 @@ void serializer_init (void);
void serializer_dump_data (const void *, size_t);
void serializer_rewrite_data (const int8_t, const void *, size_t);
#endif // SERIALIZER_H
+24 -2
View File
@@ -15,17 +15,39 @@
#include "serializer.h"
#include "jerry-libc.h"
#include "opcodes.h"
FILE *dump;
#define OPCODE_STR(op) \
#op,
static char* massive[] = {
OP_LIST (OPCODE_STR)
""
};
void
serializer_init (void)
{
}
static int opcode_counter = 0;
void
serializer_dump_data (const void *data, size_t size)
{
size_t i;
for (i = 0; i < size; i++)
__putchar (((char *) data)[i]);
__printf ("%03d: %20s ", opcode_counter++, massive[(int)((char*)data)[0]]);
for (i = 1; i < size; i++)
__printf ("%4d ", ((char*)data)[i]);
__printf ("\n");
}
void
serializer_rewrite_data (const int8_t offset __unused, const void *data __unused, size_t size __unused)
{
TODO (implement);
}