From 145fba4109ee8b72d81b0dde2ec0537067bf0169 Mon Sep 17 00:00:00 2001 From: "e.gavrin" Date: Wed, 11 Feb 2015 12:49:09 +0300 Subject: [PATCH] Remove optimizer. Move literal to JS folder. --- src/main.cpp | 3 -- src/parser/js/lexer.h | 5 +- src/parser/{collections => js}/literal.cpp | 0 src/parser/js/literal.h | 62 ++++++++++++++++++++++ src/parser/js/optimizer-passes.cpp | 28 ---------- src/parser/js/optimizer-passes.h | 24 --------- src/parser/js/parser.cpp | 1 - 7 files changed, 63 insertions(+), 60 deletions(-) rename src/parser/{collections => js}/literal.cpp (100%) create mode 100644 src/parser/js/literal.h delete mode 100644 src/parser/js/optimizer-passes.cpp delete mode 100644 src/parser/js/optimizer-passes.h diff --git a/src/main.cpp b/src/main.cpp index ef4e8079f..e544f5113 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,6 @@ static const char generated_source [] = JERRY_MCU_SCRIPT; #include "parser.h" #include "serializer.h" #include "deserializer.h" -#include "optimizer-passes.h" #define MAX_STRINGS 100 #define MAX_NUMS 25 @@ -49,8 +48,6 @@ jerry_run (const char *script_source, size_t script_source_size, opcodes = (const opcode_t*) deserialize_bytecode (); - optimizer_run_passes ((opcode_t *) opcodes); - #ifdef __TARGET_HOST serializer_print_opcodes (); #endif /* __TARGET_HOST */ diff --git a/src/parser/js/lexer.h b/src/parser/js/lexer.h index e022d8607..cf1deb59f 100644 --- a/src/parser/js/lexer.h +++ b/src/parser/js/lexer.h @@ -1,4 +1,4 @@ -/* Copyright 2014-2015 Samsung Electronics Co., Ltd. +/* 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. @@ -16,10 +16,7 @@ #ifndef LEXER_H #define LEXER_H -#include "jrt.h" -#include "ecma-globals.h" #include "literal.h" -#include "opcodes.h" #define INVALID_VALUE 255 #define INVALID_LITERAL UINT32_MAX diff --git a/src/parser/collections/literal.cpp b/src/parser/js/literal.cpp similarity index 100% rename from src/parser/collections/literal.cpp rename to src/parser/js/literal.cpp diff --git a/src/parser/js/literal.h b/src/parser/js/literal.h new file mode 100644 index 000000000..ea9cbf6e1 --- /dev/null +++ b/src/parser/js/literal.h @@ -0,0 +1,62 @@ +/* Copyright 2015 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 LITERAL_H +#define LITERAL_H + +#include "ecma-globals.h" +#include "lp-string.h" + +typedef enum +{ + LIT_UNKNOWN, + LIT_STR, + LIT_MAGIC_STR, + LIT_NUMBER +} +literal_type; + +typedef struct +{ + union + { + ecma_magic_string_id_t magic_str_id; + ecma_number_t num; + lp_string lp; + void *none; + } + data; + literal_type type; +} +literal; + +#define LITERAL_TO_REWRITE (INVALID_VALUE - 1) + +literal create_empty_literal (void); +literal create_literal_from_num (ecma_number_t); +literal create_literal_from_str (const char *, ecma_length_t); +literal create_literal_from_str_compute_len (const char *); +literal create_literal_from_zt (const ecma_char_t *, ecma_length_t); +bool literal_equal (literal, literal); +bool literal_equal_s (literal, const char *); +bool literal_equal_zt (literal, const ecma_char_t *); +bool literal_equal_num (literal, ecma_number_t); +bool literal_equal_type (literal, literal); +bool literal_equal_type_s (literal, const char *); +bool literal_equal_type_zt (literal, const ecma_char_t *); +bool literal_equal_type_num (literal, ecma_number_t); +const ecma_char_t *literal_to_zt (literal); + +#endif /* LITERAL_H */ diff --git a/src/parser/js/optimizer-passes.cpp b/src/parser/js/optimizer-passes.cpp deleted file mode 100644 index 4fa90866f..000000000 --- a/src/parser/js/optimizer-passes.cpp +++ /dev/null @@ -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. - */ - -#include "optimizer-passes.h" -#include "opcodes.h" -#include "deserializer.h" -#include "serializer.h" -#include "jerry-libc.h" - -#define NAME_TO_ID(op) (__op__idx_##op) - -void -optimizer_run_passes (opcode_t *opcodes __unused) -{ - FIXME (/*Write optimizer when postparser will be ready. */) -} diff --git a/src/parser/js/optimizer-passes.h b/src/parser/js/optimizer-passes.h deleted file mode 100644 index 1adcdd6ae..000000000 --- a/src/parser/js/optimizer-passes.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright 2014-2015 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 OPTIMIZER_PASSES_H -#define OPTIMIZER_PASSES_H - -#include "jrt.h" -#include "opcodes.h" - -void optimizer_run_passes (opcode_t *); - -#endif // OPTIMIZER_PASSES_H diff --git a/src/parser/js/parser.cpp b/src/parser/js/parser.cpp index 357eef5bb..34b6ac26e 100644 --- a/src/parser/js/parser.cpp +++ b/src/parser/js/parser.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include "optimizer-passes.h" #include "jerry-libc.h" #include "parser.h" #include "opcodes.h"