Forráskód Böngészése

Force update jerryscript submodule

BernardXiong 8 éve
szülő
commit
f0058f9d95
4 módosított fájl, 352 hozzáadás és 342 törlés
  1. 29 3
      SConscript
  2. 1 1
      jerryscript
  3. 283 283
      rtthread-port/jerry_main.c
  4. 39 55
      rtthread-port/port.c

+ 29 - 3
SConscript

@@ -9,6 +9,7 @@ jerry_core_dir = cwd + '/jerryscript/jerry-core'
 SOURCE_CORE_API             = Glob(jerry_core_dir + '/*.c')
 SOURCE_CORE_ECMA_BASE       = Glob(jerry_core_dir + '/ecma/base/*.c')
 SOURCE_CORE_ECMA_BUILTINS   = Glob(jerry_core_dir + '/ecma/builtin-objects/*.c')
+SOURCE_CORE_ECMA_BUILTINS_TYPEDARRAY   = Glob(jerry_core_dir + '/ecma/builtin-objects/typedarray/*.c')
 SOURCE_CORE_ECMA_OPERATIONS = Glob(jerry_core_dir + '/ecma/operations/*.c')
 SOURCE_CORE_JCONTEXT        = Glob(jerry_core_dir + '/jcontext/*.c')
 SOURCE_CORE_JMEM            = Glob(jerry_core_dir + '/jmem/*.c')
@@ -17,6 +18,10 @@ SOURCE_CORE_LIT             = Glob(jerry_core_dir + '/lit/*.c')
 SOURCE_CORE_PARSER_JS       = Glob(jerry_core_dir + '/parser/js/*.c')
 SOURCE_CORE_PARSER_REGEXP   = Glob(jerry_core_dir + '/parser/regexp/*.c')
 SOURCE_CORE_VM              = Glob(jerry_core_dir + '/vm/*.c')
+SOURCE_CORE_DEBUG           = Glob(jerry_core_dir + '/debugger/*.c')
+SOURCE_CORE_APE             = Glob(jerry_core_dir + '/api/*.c')
+
+SOURCE_CORE_PORT            = Glob(cwd + '/rtthread-port/*.c')
 
 jerry_core = SOURCE_CORE_API
 jerry_core += SOURCE_CORE_ECMA_BASE
@@ -29,14 +34,30 @@ jerry_core += SOURCE_CORE_LIT
 jerry_core += SOURCE_CORE_PARSER_JS
 jerry_core += SOURCE_CORE_PARSER_REGEXP
 jerry_core += SOURCE_CORE_VM
+jerry_core += SOURCE_CORE_DEBUG
+jerry_core += SOURCE_CORE_APE
+jerry_core += SOURCE_CORE_ECMA_BUILTINS_TYPEDARRAY
+jerry_core += SOURCE_CORE_PORT
+
+jerry_ext_dir = cwd + '/jerryscript/jerry-ext'
+
+SOURCE_EXT_ARG              = Glob(jerry_ext_dir + '/arg/*.c')
+SOURCE_EXT_HANDLER          = Glob(jerry_ext_dir + '/handler/*.c')
+SOURCE_EXT_INCLUDE          = Glob(jerry_ext_dir + '/include/*.c')
+SOURCE_EXT_MODULE           = Glob(jerry_ext_dir + '/module/*.c')
 
-src = Glob('./rtthread-port/*.c')
+jerry_ext = SOURCE_EXT_ARG + SOURCE_EXT_HANDLER + SOURCE_EXT_INCLUDE + SOURCE_EXT_MODULE
+
+src = []
 src += jerry_core
 
+src += jerry_ext
+
 path = [cwd]
 path += [jerry_core_dir]
 path += [jerry_core_dir + '/ecma/base']
 path += [jerry_core_dir + '/ecma/builtin-objects']
+path += [jerry_core_dir + '/ecma/builtin-objects/typedarray']
 path += [jerry_core_dir + '/ecma/operations']
 path += [jerry_core_dir + '/jcontext']
 path += [jerry_core_dir + '/jmem']
@@ -45,9 +66,14 @@ path += [jerry_core_dir + '/lit']
 path += [jerry_core_dir + '/parser/js']
 path += [jerry_core_dir + '/parser/regexp']
 path += [jerry_core_dir + '/vm']
+path += [jerry_core_dir + '/include']
+path += [jerry_core_dir + '/debugger']
+path += [jerry_core_dir + '/api']
 
-#remove other no use files
-#SrcRemove(src, '*.c')
+path += [jerry_ext_dir + '/arg']
+path += [jerry_ext_dir + '/handler']
+path += [jerry_ext_dir + '/include']
+path += [jerry_ext_dir + '/module']
 
 LOCAL_CCFLAGS = " -std=c99"
 LOCAL_CPPDEFINES = ['JERRY_JS_PARSER']

+ 1 - 1
jerryscript

@@ -1 +1 @@
-Subproject commit 445ca1d6de3da2d7242a492e639156e58bef66ad
+Subproject commit 40d05cdca2014ce69cca28c4d130b43d755c947a

+ 283 - 283
rtthread-port/jerry_main.c

@@ -17,8 +17,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "jerry-api.h"
-#include "jerry-port.h"
+#include <jerryscript.h>
+#include <jerryscript-port.h>
 
 #include <rtthread.h>
 #include <finsh.h>
@@ -41,126 +41,126 @@
  */
 static char* read_sources(const char *script_file_names[], int files_count, size_t *out_source_size_p)
 {
-	int i;
-	char* source_buffer = NULL;
-	char *source_buffer_tail = NULL;
-	size_t total_length = 0;
-	FILE *file = NULL;
-
-	for (i = 0; i < files_count; i++)
-	{
-		const char *script_file_name = script_file_names[i];
-
-		file = fopen(script_file_name, "r");
-		if (file == NULL) {
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to fopen [%s]\n",
-					script_file_name);
-			return NULL;
-		}
-
-		int fseek_status = fseek(file, 0, SEEK_END);
-		if (fseek_status != 0)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-					"Failed to fseek fseek_status(%d)\n", fseek_status);
-			fclose(file);
-			return NULL;
-		}
-
-		long script_len = ftell(file);
-		if (script_len < 0)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-					"Failed to ftell script_len(%ld)\n", script_len);
-			fclose(file);
-			break;
-		}
-
-		total_length += (size_t) script_len;
-
-		fclose(file);
-		file = NULL;
-	}
-
-	if (total_length <= 0)
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR, "There's nothing to read\n");
-		return NULL;
-	}
-
-	source_buffer = (char*) rt_malloc(total_length);
-
-	if (source_buffer == NULL)
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Out of memory error\n");
-		return NULL;
-	}
-
-	memset(source_buffer, 0, sizeof(char) * total_length);
-	source_buffer_tail = source_buffer;
-
-	for (i = 0; i < files_count; i++)
-	{
-		const char *script_file_name = script_file_names[i];
-		file = fopen(script_file_name, "r");
-
-		if (file == NULL)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to fopen [%s]\n",
-					script_file_name);
-			break;
-		}
-
-		int fseek_status = fseek(file, 0, SEEK_END);
-		if (fseek_status != 0)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-					"Failed to fseek fseek_status(%d)\n", fseek_status);
-			break;
-		}
-
-		long script_len = ftell(file);
-		if (script_len < 0)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-					"Failed to ftell script_len(%ld)\n", script_len);
-			break;
-		}
-
-		rewind(file);
-
-		const size_t current_source_size = (size_t) script_len;
-		size_t bytes_read = fread(source_buffer_tail, 1, current_source_size,
-				file);
-		if (bytes_read < current_source_size)
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-					"Failed to fread bytes_read(%d)\n", bytes_read);
-			break;
-		}
-
-		fclose(file);
-		file = NULL;
-
-		source_buffer_tail += current_source_size;
-	}
-
-	if (file != NULL)
-	{
-		fclose(file);
-	}
-
-	if (i < files_count)
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to read script N%d\n",
-				i + 1);
-		rt_free(source_buffer);
-		return NULL;
-	}
-
-	*out_source_size_p = (size_t) total_length;
-
-	return source_buffer;
+    int i;
+    char* source_buffer = NULL;
+    char *source_buffer_tail = NULL;
+    size_t total_length = 0;
+    FILE *file = NULL;
+
+    for (i = 0; i < files_count; i++)
+    {
+        const char *script_file_name = script_file_names[i];
+
+        file = fopen(script_file_name, "r");
+        if (file == NULL) {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to fopen [%s]\n",
+                    script_file_name);
+            return NULL;
+        }
+
+        int fseek_status = fseek(file, 0, SEEK_END);
+        if (fseek_status != 0)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                    "Failed to fseek fseek_status(%d)\n", fseek_status);
+            fclose(file);
+            return NULL;
+        }
+
+        long script_len = ftell(file);
+        if (script_len < 0)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                    "Failed to ftell script_len(%ld)\n", script_len);
+            fclose(file);
+            break;
+        }
+
+        total_length += (size_t) script_len;
+
+        fclose(file);
+        file = NULL;
+    }
+
+    if (total_length <= 0)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR, "There's nothing to read\n");
+        return NULL;
+    }
+
+    source_buffer = (char*) rt_malloc(total_length);
+
+    if (source_buffer == NULL)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Out of memory error\n");
+        return NULL;
+    }
+
+    memset(source_buffer, 0, sizeof(char) * total_length);
+    source_buffer_tail = source_buffer;
+
+    for (i = 0; i < files_count; i++)
+    {
+        const char *script_file_name = script_file_names[i];
+        file = fopen(script_file_name, "r");
+
+        if (file == NULL)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to fopen [%s]\n",
+                    script_file_name);
+            break;
+        }
+
+        int fseek_status = fseek(file, 0, SEEK_END);
+        if (fseek_status != 0)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                    "Failed to fseek fseek_status(%d)\n", fseek_status);
+            break;
+        }
+
+        long script_len = ftell(file);
+        if (script_len < 0)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                    "Failed to ftell script_len(%ld)\n", script_len);
+            break;
+        }
+
+        rewind(file);
+
+        const size_t current_source_size = (size_t) script_len;
+        size_t bytes_read = fread(source_buffer_tail, 1, current_source_size,
+                file);
+        if (bytes_read < current_source_size)
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                    "Failed to fread bytes_read(%d)\n", bytes_read);
+            break;
+        }
+
+        fclose(file);
+        file = NULL;
+
+        source_buffer_tail += current_source_size;
+    }
+
+    if (file != NULL)
+    {
+        fclose(file);
+    }
+
+    if (i < files_count)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Failed to read script N%d\n",
+                i + 1);
+        rt_free(source_buffer);
+        return NULL;
+    }
+
+    *out_source_size_p = (size_t) total_length;
+
+    return source_buffer;
 } /* read_sources */
 
 /**
@@ -175,206 +175,206 @@ static jerry_log_level_t jerry_log_level = JERRY_LOG_LEVEL_ERROR;
  */
 int jerry_main(int argc, char *argv[])
 {
-	if (argc > JERRY_MAX_COMMAND_LINE_ARGS)
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-				"Too many command line arguments. Current maximum is %d\n",
-				JERRY_MAX_COMMAND_LINE_ARGS);
-
-		return JERRY_STANDALONE_EXIT_CODE_FAIL;
-	}
-
-	const char *file_names[JERRY_MAX_COMMAND_LINE_ARGS];
-	int i;
-	int files_counter = 0;
-
-	jerry_init_flag_t flags = JERRY_INIT_EMPTY;
-
-	for (i = 1; i < argc; i++)
-	{
-		if (!strcmp("--mem-stats", argv[i]))
-		{
-			flags |= JERRY_INIT_MEM_STATS;
-		}
-		else if (!strcmp("--mem-stats-separate", argv[i]))
-		{
-			flags |= JERRY_INIT_MEM_STATS_SEPARATE;
-		}
-		else if (!strcmp("--show-opcodes", argv[i]))
-		{
-			flags |= JERRY_INIT_SHOW_OPCODES | JERRY_INIT_SHOW_REGEXP_OPCODES;
-		}
-		else if (!strcmp("--log-level", argv[i]))
-		{
-			if (++i < argc && strlen(argv[i]) == 1 && argv[i][0] >= '0'
-					&& argv[i][0] <= '3')
-			{
-				jerry_log_level = argv[i][0] - '0';
-			}
-			else
-			{
-				jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-						"Error: wrong format or invalid argument\n");
-				return JERRY_STANDALONE_EXIT_CODE_FAIL;
-			}
-		}
-		else
-		{
-			file_names[files_counter++] = argv[i];
-		}
-	}
-
-	if (files_counter == 0)
-	{
-		jerry_port_console("No input files, running a hello world demo:\n");
-		char *source_p =
-				"var a = 3.5; print('Hello world ' + (a + 1.5) + ' times from JerryScript')";
-
-		jerry_run_simple((jerry_char_t *) source_p, strlen(source_p), flags);
-		return 0;
-	}
-
-	size_t source_size;
-	char *source_p = read_sources(file_names, files_counter, &source_size);
-
-	if (source_p == NULL)
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-				"JERRY_STANDALONE_EXIT_CODE_FAIL\n");
-		return JERRY_STANDALONE_EXIT_CODE_FAIL;
-	}
-
-	bool success = jerry_run_simple((jerry_char_t *) source_p, source_size, flags);
-
-	rt_free(source_p);
-
-	if (!success)
-	{
-		return JERRY_STANDALONE_EXIT_CODE_FAIL;
-	}
-	return JERRY_STANDALONE_EXIT_CODE_OK;
+    if (argc > JERRY_MAX_COMMAND_LINE_ARGS)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                "Too many command line arguments. Current maximum is %d\n",
+                JERRY_MAX_COMMAND_LINE_ARGS);
+
+        return JERRY_STANDALONE_EXIT_CODE_FAIL;
+    }
+
+    const char *file_names[JERRY_MAX_COMMAND_LINE_ARGS];
+    int i;
+    int files_counter = 0;
+
+    jerry_init_flag_t flags = JERRY_INIT_EMPTY;
+
+    for (i = 1; i < argc; i++)
+    {
+        if (!strcmp("--mem-stats", argv[i]))
+        {
+            flags |= JERRY_INIT_MEM_STATS;
+        }
+        else if (!strcmp("--mem-stats-separate", argv[i]))
+        {
+            flags |= JERRY_INIT_MEM_STATS_SEPARATE;
+        }
+        else if (!strcmp("--show-opcodes", argv[i]))
+        {
+            flags |= JERRY_INIT_SHOW_OPCODES | JERRY_INIT_SHOW_REGEXP_OPCODES;
+        }
+        else if (!strcmp("--log-level", argv[i]))
+        {
+            if (++i < argc && strlen(argv[i]) == 1 && argv[i][0] >= '0'
+                    && argv[i][0] <= '3')
+            {
+                jerry_log_level = argv[i][0] - '0';
+            }
+            else
+            {
+                jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                        "Error: wrong format or invalid argument\n");
+                return JERRY_STANDALONE_EXIT_CODE_FAIL;
+            }
+        }
+        else
+        {
+            file_names[files_counter++] = argv[i];
+        }
+    }
+
+    if (files_counter == 0)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR, "No input files, running a hello world demo:\n");
+        char *source_p =
+                "var a = 3.5; print('Hello world ' + (a + 1.5) + ' times from JerryScript')";
+
+        jerry_run_simple((jerry_char_t *) source_p, strlen(source_p), flags);
+        return 0;
+    }
+
+    size_t source_size;
+    char *source_p = read_sources(file_names, files_counter, &source_size);
+
+    if (source_p == NULL)
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                "JERRY_STANDALONE_EXIT_CODE_FAIL\n");
+        return JERRY_STANDALONE_EXIT_CODE_FAIL;
+    }
+
+    bool success = jerry_run_simple((jerry_char_t *) source_p, source_size, flags);
+
+    rt_free(source_p);
+
+    if (!success)
+    {
+        return JERRY_STANDALONE_EXIT_CODE_FAIL;
+    }
+    return JERRY_STANDALONE_EXIT_CODE_OK;
 } /* main */
 MSH_CMD_EXPORT(jerry_main, jerryScript Demo);
 
 /* JerryScript CMD Line Interpreter */
 #define DECLARE_HANDLER(NAME) \
-	static jerry_value_t \
-	NAME ## _handler (const jerry_value_t func_value, \
-						const jerry_value_t this_value, \
-						const jerry_value_t args[], \
-						const jerry_length_t args_cnt )
+    static jerry_value_t \
+    NAME ## _handler (const jerry_value_t func_value, \
+                        const jerry_value_t this_value, \
+                        const jerry_value_t args[], \
+                        const jerry_length_t args_cnt )
 
 #define REGISTER_HANDLER(NAME) \
-	register_native_function ( # NAME, NAME ## _handler)
+    register_native_function ( # NAME, NAME ## _handler)
 
 DECLARE_HANDLER(assert)
 {
-	if (args_cnt == 1 && jerry_value_is_boolean(args[0]) && jerry_get_boolean_value(args[0]))
-	{
-		jerry_port_log(JERRY_LOG_LEVEL_DEBUG, ">> Jerry assert true\r\n");
-		return jerry_create_boolean(true);
-	}
+    if (args_cnt == 1 && jerry_value_is_boolean(args[0]) && jerry_get_boolean_value(args[0]))
+    {
+        jerry_port_log(JERRY_LOG_LEVEL_DEBUG, ">> Jerry assert true\r\n");
+        return jerry_create_boolean(true);
+    }
 
-	jerry_port_log(JERRY_LOG_LEVEL_ERROR, "ERROR: Script assertion failed\n");
+    jerry_port_log(JERRY_LOG_LEVEL_ERROR, "ERROR: Script assertion failed\n");
 
-	return jerry_create_boolean(false);
+    return jerry_create_boolean(false);
 }
 
 static bool register_native_function(const char* name, jerry_external_handler_t handler)
 {
-	jerry_value_t global_object_val = jerry_get_global_object();
-	jerry_value_t reg_function = jerry_create_external_function(handler);
-
-	bool is_ok = true;
-
-	if (!(jerry_value_is_function(reg_function) && jerry_value_is_constructor(reg_function)))
-	{
-		is_ok = false;
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-				"Error: create_external_function failed !!!\r\n");
-		jerry_release_value(global_object_val);
-		jerry_release_value(reg_function);
-		return is_ok;
-	}
-
-	if (jerry_value_has_error_flag(reg_function))
-	{
-		is_ok = false;
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-				"Error: create_external_function has error flag! \n\r");
-		jerry_release_value(global_object_val);
-		jerry_release_value(reg_function);
-		return is_ok;
-	}
-
-	jerry_value_t jerry_name = jerry_create_string((jerry_char_t *) name);
-
-	jerry_value_t set_result = jerry_set_property(global_object_val, jerry_name, reg_function);
-
-	if (jerry_value_has_error_flag(set_result))
-	{
-		is_ok = false;
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR,
-				"Error: register_native_function failed: [%s]\r\n", name);
-	}
-
-	jerry_release_value(jerry_name);
-	jerry_release_value(global_object_val);
-	jerry_release_value(reg_function);
-	jerry_release_value(set_result);
-
-	return is_ok;
+    jerry_value_t global_object_val = jerry_get_global_object();
+    jerry_value_t reg_function = jerry_create_external_function(handler);
+
+    bool is_ok = true;
+
+    if (!(jerry_value_is_function(reg_function) && jerry_value_is_constructor(reg_function)))
+    {
+        is_ok = false;
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                "Error: create_external_function failed !!!\r\n");
+        jerry_release_value(global_object_val);
+        jerry_release_value(reg_function);
+        return is_ok;
+    }
+
+    if (jerry_value_has_error_flag(reg_function))
+    {
+        is_ok = false;
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                "Error: create_external_function has error flag! \n\r");
+        jerry_release_value(global_object_val);
+        jerry_release_value(reg_function);
+        return is_ok;
+    }
+
+    jerry_value_t jerry_name = jerry_create_string((jerry_char_t *) name);
+
+    jerry_value_t set_result = jerry_set_property(global_object_val, jerry_name, reg_function);
+
+    if (jerry_value_has_error_flag(set_result))
+    {
+        is_ok = false;
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR,
+                "Error: register_native_function failed: [%s]\r\n", name);
+    }
+
+    jerry_release_value(jerry_name);
+    jerry_release_value(global_object_val);
+    jerry_release_value(reg_function);
+    jerry_release_value(set_result);
+
+    return is_ok;
 }
 
 void js_register_functions(void)
 {
-	REGISTER_HANDLER(assert);
+    REGISTER_HANDLER(assert);
 }
 
 static void _jerry_thread(void* parameter)
 {
-	char *source_p;
-	size_t source_size;
+    char *source_p;
+    size_t source_size;
 
-	jerry_init(JERRY_INIT_EMPTY);
-	js_register_functions();
+    jerry_init(JERRY_INIT_EMPTY);
+    js_register_functions();
 
-	while (1)
-	{
+    while (1)
+    {
 #if 0
-		jerry_value_t ret_val = jerry_eval((jerry_char_t *) source_p, source_size, false);
+        jerry_value_t ret_val = jerry_eval((jerry_char_t *) source_p, source_size, false);
 
-		if (jerry_value_has_error_flag(ret_val))
-		{
-			jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: jerry_eval failed!\r\n");
-		}
+        if (jerry_value_has_error_flag(ret_val))
+        {
+            jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: jerry_eval failed!\r\n");
+        }
 
-		jerry_release_value(ret_val);
+        jerry_release_value(ret_val);
 #else
-		jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: Jerryscript CMD Line Interpreter Not Implementation\r\n");
-		rt_thread_delay(RT_TICK_PER_SECOND);
+        jerry_port_log(JERRY_LOG_LEVEL_ERROR, "Error: Jerryscript CMD Line Interpreter Not Implementation\r\n");
+        rt_thread_delay(RT_TICK_PER_SECOND);
 #endif
 
-	}
+    }
 }
 
 int js_run(int argc, char *argv[])
 {
-	rt_thread_t thread;
+    rt_thread_t thread;
 
-	thread = rt_thread_create("jsth", _jerry_thread, RT_NULL, 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
+    thread = rt_thread_create("jsth", _jerry_thread, RT_NULL, 2048, RT_THREAD_PRIORITY_MAX / 3, 20);
 
-	if (thread != RT_NULL)
-	{
-		rt_thread_startup(thread);
+    if (thread != RT_NULL)
+    {
+        rt_thread_startup(thread);
 
-		return 0;
-	}
-	else
-	{
-		rt_kprintf("JerryScript Thread Create Failure\n");
-		return -1;
-	}
+        return 0;
+    }
+    else
+    {
+        rt_kprintf("JerryScript Thread Create Failure\n");
+        return -1;
+    }
 }
 // MSH_CMD_EXPORT(js_run, JerryScript Cmd Interpreter);
 

+ 39 - 55
rtthread-port/port.c

@@ -1,7 +1,25 @@
-#include "jerry-port.h"
-
+/* Copyright JS Foundation and other contributors, http://js.foundation
+ *
+ * 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.
+ */
+#include <rthw.h>
+#include <string.h>
 #include <rtthread.h>
 
+#include "jerryscript.h"
+#include "jerryscript-port.h"
+#include "jerryscript-core.h"
+
 /**
  * Signal the port that jerry experienced a fatal failure from which it cannot
  * recover.
@@ -17,49 +35,15 @@ void jerry_port_fatal (jerry_fatal_code_t code)
 {
     rt_kprintf("jerryScritp fatal...\n");
     rt_hw_interrupt_disable();
-	while (1);
+    while (1);
 }
 
 /*
  *  I/O Port API
  */
-#define RT_JS_CONSOLEBUF_SIZE	128
+#define RT_JS_CONSOLEBUF_SIZE   128
 static char rt_log_buf[RT_JS_CONSOLEBUF_SIZE];
 
-/**
- * Print a string to the console. The function should implement a printf-like
- * interface, where the first argument specifies a format string on how to
- * stringify the rest of the parameter list.
- *
- * This function is only called with strings coming from the executed ECMAScript
- * wanting to print something as the result of its normal operation.
- *
- * It should be the port that decides what a "console" is.
- *
- * Example: a libc-based port may implement this with vprintf().
- */
-void jerry_port_console (const char *format, ...)
-{
-	va_list args;
-	rt_size_t length;
-
-	va_start(args, format);
-	/* the return value of vsnprintf is the number of bytes that would be
-	 * written to buffer had if the size of the buffer been sufficiently
-	 * large excluding the terminating null byte. If the output string
-	 * would be larger than the rt_log_buf, we have to adjust the output
-	 * length. */
-	length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, format, args);
-	if (length > RT_CONSOLEBUF_SIZE - 1)
-		length = RT_CONSOLEBUF_SIZE - 1;
-#ifdef RT_USING_DEVICE
-	rt_kprintf("%s", rt_log_buf);
-#else
-	rt_hw_console_output(rt_log_buf);
-#endif
-	va_end(args);
-}
-
 /**
  * Display or log a debug/error message. The function should implement a printf-like
  * interface, where the first argument specifies the log level
@@ -78,24 +62,24 @@ void jerry_port_console (const char *format, ...)
  */
 void jerry_port_log (jerry_log_level_t level, const char *format, ...)
 {
-	va_list args;
-	rt_size_t length;
+    va_list args;
+    rt_size_t length;
 
-	va_start(args, format);
-	/* the return value of vsnprintf is the number of bytes that would be
-	 * written to buffer had if the size of the buffer been sufficiently
-	 * large excluding the terminating null byte. If the output string
-	 * would be larger than the rt_log_buf, we have to adjust the output
-	 * length. */
-	length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, format, args);
-	if (length > RT_CONSOLEBUF_SIZE - 1)
-		length = RT_CONSOLEBUF_SIZE - 1;
+    va_start(args, format);
+    /* the return value of vsnprintf is the number of bytes that would be
+     * written to buffer had if the size of the buffer been sufficiently
+     * large excluding the terminating null byte. If the output string
+     * would be larger than the rt_log_buf, we have to adjust the output
+     * length. */
+    length = rt_vsnprintf(rt_log_buf, sizeof(rt_log_buf) - 1, format, args);
+    if (length > RT_CONSOLEBUF_SIZE - 1)
+        length = RT_CONSOLEBUF_SIZE - 1;
 #ifdef RT_USING_DEVICE
-	rt_kprintf("%s", rt_log_buf);
+    rt_kprintf("%s", rt_log_buf);
 #else
-	rt_hw_console_output(rt_log_buf);
+    rt_hw_console_output(rt_log_buf);
 #endif
-	va_end(args);
+    va_end(args);
 }
 
 /*
@@ -110,9 +94,9 @@ void jerry_port_log (jerry_log_level_t level, const char *format, ...)
  */
 bool jerry_port_get_time_zone (jerry_time_zone_t *tz_p)
 {
-	tz_p->offset = 0;
-	tz_p->daylight_saving_time = 0;
-	return true;
+    tz_p->offset = 0;
+    tz_p->daylight_saving_time = 0;
+    return true;
 }
 
 /**