Merge with master
This commit is contained in:
@@ -12,144 +12,49 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
TARGET ?= jerry
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
OBJ_DIR = ./obj
|
||||
OUT_DIR = ./out
|
||||
#
|
||||
# Target naming scheme
|
||||
#
|
||||
# Main targets: {dev,debug,release,debug_release}.{linux,stm32f{4}}[.{check,flash}]
|
||||
#
|
||||
# Target mode part (before dot):
|
||||
# dev: - JERRY_NDEBUG; - optimizations; + debug symbols; - -Werror | local development build
|
||||
# debug: - JERRY_NDEBUG; - optimizations; + debug symbols; + -Werror | debug build
|
||||
# debug_release: - JERRY_NDEBUG; + optimizations; + debug symbols; + -Werror | checked release build
|
||||
# release: + JERRY_NDEBUG; + optimizations; - debug symbols; + -Werror | release build
|
||||
#
|
||||
# Target system part (after first dot):
|
||||
# linux - target system is linux
|
||||
# stm32f{4} - target is STM32F{4} board
|
||||
#
|
||||
# Target action part (optional, after second dot):
|
||||
# check - run cppcheck on src folder, unit and other tests
|
||||
# flash - flash specified mcu target binary
|
||||
#
|
||||
#
|
||||
# Unit test target: unittests
|
||||
#
|
||||
|
||||
MAIN_MODULE_SRC = ./src/main.c
|
||||
UNITTESTS_SRC_DIR = ./tests/unit
|
||||
export TARGET_MODES = dev debug debug_release release
|
||||
export TARGET_PC_SYSTEMS = linux
|
||||
export TARGET_MCU_SYSTEMS = $(addprefix stm32f,4) # now only stm32f4 is supported, to add, for example, to stm32f3, change to $(addprefix stm32f,3 4)
|
||||
export TARGET_SYSTEMS = $(TARGET_PC_SYSTEMS) $(TARGET_MCU_SYSTEMS)
|
||||
|
||||
LNK_SCRIPT_STM32F4 = ./third-party/stm32f4.ld
|
||||
SUP_STM32F4 = ./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s
|
||||
# Target list
|
||||
export JERRY_TARGETS = $(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_SYSTEMS),$(__MODE).$(__SYSTEM)))
|
||||
export TESTS_TARGET = unittests
|
||||
export CHECK_TARGETS = $(foreach __TARGET,$(JERRY_TARGETS),$(__TARGET).check)
|
||||
export FLASH_TARGETS = $(foreach __TARGET,$(foreach __MODE,$(TARGET_MODES),$(foreach __SYSTEM,$(TARGET_MCU_SYSTEMS),$(__MODE).$(__SYSTEM))),$(__TARGET).flash)
|
||||
|
||||
export OBJ_DIR = ./obj
|
||||
export OUT_DIR = ./out
|
||||
export UNITTESTS_SRC_DIR = ./tests/unit
|
||||
|
||||
# FIXME:
|
||||
# Place jerry-libc.c, pretty-printer.c to some subdirectory (libruntime?)
|
||||
# and add them to the SOURCES list through wildcard.
|
||||
# FIXME:
|
||||
# Add common-io.c and sensors.c
|
||||
SOURCES = \
|
||||
$(sort \
|
||||
$(wildcard ./src/libruntime/*.c) \
|
||||
$(wildcard ./src/libperipherals/actuators.c) \
|
||||
$(wildcard ./src/libjsparser/*.c) \
|
||||
$(wildcard ./src/libecmaobjects/*.c) \
|
||||
$(wildcard ./src/libecmaoperations/*.c) \
|
||||
$(wildcard ./src/liballocator/*.c) \
|
||||
$(wildcard ./src/libcoreint/*.c) )
|
||||
all: clean $(JERRY_TARGETS) $(TESTS_TARGET) $(CHECK_TARGETS)
|
||||
|
||||
SOURCES_STM32F4 = \
|
||||
third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c \
|
||||
$(wildcard src/libruntime/target/stm32f4/*)
|
||||
|
||||
SOURCES_LINUX = \
|
||||
$(wildcard src/libruntime/target/linux/*)
|
||||
|
||||
HEADERS = \
|
||||
$(sort \
|
||||
$(wildcard ./src/*.h) \
|
||||
$(wildcard ./src/libruntime/*.h) \
|
||||
$(wildcard ./src/libperipherals/*.h) \
|
||||
$(wildcard ./src/libjsparser/*.h) \
|
||||
$(wildcard ./src/libecmaobjects/*.h) \
|
||||
$(wildcard ./src/libecmaoperations/*.h) \
|
||||
$(wildcard ./src/liballocator/*.h) \
|
||||
$(wildcard ./src/libcoreint/*.h) )
|
||||
|
||||
INCLUDES = \
|
||||
-I src \
|
||||
-I src/libruntime \
|
||||
-I src/libperipherals \
|
||||
-I src/libjsparser \
|
||||
-I src/libecmaobjects \
|
||||
-I src/libecmaoperations \
|
||||
-I src/liballocator \
|
||||
-I src/libcoreint
|
||||
|
||||
INCLUDES_STM32F4 = \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
|
||||
|
||||
UNITTESTS = \
|
||||
$(sort \
|
||||
$(patsubst %.c,%,$(notdir \
|
||||
$(wildcard $(UNITTESTS_SRC_DIR)/*))))
|
||||
|
||||
OBJS = \
|
||||
$(sort \
|
||||
$(patsubst %.c,./%.o,$(notdir $(MAIN_MODULE_SRC) $(SOURCES))))
|
||||
|
||||
CC = gcc
|
||||
LD = ld
|
||||
OBJDUMP = objdump
|
||||
OBJCOPY = objcopy
|
||||
SIZE = size
|
||||
STRIP = strip
|
||||
|
||||
# General flags
|
||||
CFLAGS ?= $(INCLUDES) -std=c99 -Werror #-fdiagnostics-color=always
|
||||
CFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Winline
|
||||
CFLAGS += -Wformat-nonliteral -Winit-self -Wstack-protector
|
||||
CFLAGS += -Wconversion -Wsign-conversion -Wformat-security
|
||||
CFLAGS += -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
# Flags for MCU
|
||||
MCU_CFLAGS += -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb
|
||||
MCU_CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
MCU_CFLAGS += -ffunction-sections -fdata-sections -nostdlib -fno-common
|
||||
|
||||
LDFLAGS = -nostartfiles -T$(LNK_SCRIPT_STM32F4)
|
||||
|
||||
DEBUG_OPTIONS = -g3 -O0 # -fsanitize=address
|
||||
RELEASE_OPTIONS = -Os -flto -DJERRY_NDEBUG
|
||||
|
||||
DEFINES = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -DMEM_STATS
|
||||
TARGET_HOST = -D__HOST
|
||||
TARGET_MCU = -D__TARGET_MCU
|
||||
|
||||
#-I third-party/STM32F4-Discovery_FW_V1.1.0/Project/Demonstration \
|
||||
|
||||
.PHONY: all debug debug.stdm32f4 release clean tests check install
|
||||
|
||||
all: debug release
|
||||
|
||||
debug.stdm32f4: clean debug.stdm32f4.bin
|
||||
|
||||
debug.stdm32f4.o:
|
||||
mkdir -p $(OUT_DIR)/debug.stdm32f4/
|
||||
$(CROSS_COMPILE)$(CC) \
|
||||
$(SUP_STM32F4) $(SOURCES_STM32F4) $(INCLUDES_STM32F4) \
|
||||
$(CFLAGS) $(MCU_CFLAGS) $(DEBUG_OPTIONS) \
|
||||
$(DEFINES) $(TARGET_MCU) $(MAIN_MODULE_SRC) -c
|
||||
|
||||
debug.stdm32f4.elf: debug.stdm32f4.o
|
||||
$(CROSS_COMPILE)$(LD) $(LDFLAGS) -o $(TARGET).elf *.o
|
||||
rm -f *.o
|
||||
|
||||
debug.stdm32f4.bin: debug.stdm32f4.elf
|
||||
$(CROSS_COMPILE)$(OBJCOPY) -Obinary $(TARGET).elf $(TARGET).bin
|
||||
rm -f *.elf
|
||||
|
||||
debug: clean
|
||||
mkdir -p $(OUT_DIR)/debug.host/
|
||||
$(CC) $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||
$(SOURCES) $(SOURCES_LINUX) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/debug.host/$(TARGET)
|
||||
|
||||
release: clean
|
||||
mkdir -p $(OUT_DIR)/release.host/
|
||||
$(CC) $(CFLAGS) $(RELEASE_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||
$(SOURCES) $(SOURCES_LINUX) $(MAIN_MODULE_SRC) -o $(OUT_DIR)/release.host/$(TARGET)
|
||||
$(STRIP) $(OUT_DIR)/release.host/$(TARGET)
|
||||
|
||||
tests:
|
||||
mkdir -p $(OUT_DIR)/tests.host/
|
||||
for unit_test in $(UNITTESTS); \
|
||||
do \
|
||||
$(CC) -O3 $(CFLAGS) $(DEBUG_OPTIONS) $(DEFINES) $(TARGET_HOST) \
|
||||
$(SOURCES) $(SOURCES_LINUX) $(UNITTESTS_SRC_DIR)/"$$unit_test".c -o $(OUT_DIR)/tests.host/"$$unit_test"; \
|
||||
done
|
||||
$(JERRY_TARGETS) $(TESTS_TARGET) $(FLASH_TARGETS) $(CHECK_TARGETS):
|
||||
@echo $@
|
||||
@make -f Makefile.mak TARGET=$@ $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ_DIR)/*.o *.bin *.o *~ *.log *.log
|
||||
@@ -161,31 +66,3 @@ clean:
|
||||
rm -f $(TARGET).hex
|
||||
rm -f $(TARGET).lst
|
||||
rm -f js.files
|
||||
|
||||
check: tests
|
||||
@ mkdir -p $(OUT_DIR)
|
||||
@ cd $(OUT_DIR)
|
||||
|
||||
@ echo "=== Running cppcheck ==="
|
||||
@ cppcheck $(HEADERS) $(SOURCES) --error-exitcode=1 --enable=all --std=c99
|
||||
@ echo Done
|
||||
@ echo
|
||||
|
||||
@ echo "=== Running unit tests ==="
|
||||
@ ./tools/jerry_unittest.sh $(OUT_DIR)/tests.host $(UNITTESTS)
|
||||
@ echo Done
|
||||
@ echo
|
||||
|
||||
@ echo "=== Running js tests ==="
|
||||
@ if [ -f $(OUT_DIR)/release.host/$(TARGET) ]; then \
|
||||
./tools/jerry_test.sh $(OUT_DIR)/release.host/$(TARGET);\
|
||||
fi
|
||||
|
||||
@ if [ -f $(OUT_DIR)/debug.host/$(TARGET) ]; then \
|
||||
./tools/jerry_test.sh $(OUT_DIR)/debug.host/$(TARGET); \
|
||||
fi
|
||||
@echo Done
|
||||
@echo
|
||||
|
||||
install:
|
||||
st-flash write $(TARGET).bin 0x08000000
|
||||
|
||||
+279
@@ -0,0 +1,279 @@
|
||||
ifeq ($(TARGET),)
|
||||
$(error TARGET not set)
|
||||
endif
|
||||
|
||||
ENGINE_NAME ?= jerry
|
||||
|
||||
CROSS_COMPILE ?= arm-none-eabi-
|
||||
CC = gcc
|
||||
LD = ld
|
||||
OBJDUMP = objdump
|
||||
OBJCOPY = objcopy
|
||||
SIZE = size
|
||||
STRIP = strip
|
||||
|
||||
MAIN_MODULE_SRC = ./src/main.c
|
||||
|
||||
LNK_SCRIPT_STM32F4 = ./third-party/stm32f4.ld
|
||||
|
||||
# Parsing target
|
||||
# '.' -> ' '
|
||||
TARGET_SPACED = $(subst ., ,$(TARGET))
|
||||
# extract target mode part
|
||||
TARGET_MODE = $(word 1,$(TARGET_SPACED))
|
||||
# extract target system part
|
||||
TARGET_SYSTEM = $(word 2,$(TARGET_SPACED))
|
||||
# extract optional action part
|
||||
TARGET_ACTION = $(word 3,$(TARGET_SPACED))
|
||||
|
||||
# Target used as dependency of an action (check, flash, etc.)
|
||||
TARGET_OF_ACTION = $(TARGET_MODE).$(TARGET_SYSTEM)
|
||||
|
||||
# target folder name in $(OUT_DIR)
|
||||
TARGET_DIR=$(OUT_DIR)/$(TARGET_MODE).$(TARGET_SYSTEM)
|
||||
|
||||
# unittests mode -> linux system
|
||||
ifeq ($(TARGET_MODE),$(TESTS_TARGET))
|
||||
TARGET_SYSTEM = linux
|
||||
endif
|
||||
|
||||
#
|
||||
# Options setup
|
||||
#
|
||||
|
||||
# JERRY_NDEBUG, debug symbols
|
||||
ifeq ($(TARGET_MODE),release)
|
||||
OPTION_NDEBUG = enable
|
||||
OPTION_DEBUG_SYMS = disable
|
||||
OPTION_STRIP = enable
|
||||
else
|
||||
OPTION_NDEBUG = disable
|
||||
OPTION_DEBUG_SYMS = enable
|
||||
OPTION_STRIP = disable
|
||||
endif
|
||||
|
||||
# Optimizations
|
||||
ifeq ($(filter-out debug_release release $(TESTS_TARGET),$(TARGET_MODE)),)
|
||||
OPTION_OPTIMIZE = enable
|
||||
else
|
||||
OPTION_OPTIMIZE = disable
|
||||
endif
|
||||
|
||||
# -Werror
|
||||
ifeq ($(TARGET_MODE),dev)
|
||||
OPTION_WERROR = disable
|
||||
else
|
||||
OPTION_WERROR = enable
|
||||
endif
|
||||
|
||||
# Is MCU target?
|
||||
ifeq ($(filter-out $(TARGET_MCU_SYSTEMS),$(TARGET_SYSTEM)),)
|
||||
OPTION_MCU = enable
|
||||
else
|
||||
OPTION_MCU = disable
|
||||
endif
|
||||
|
||||
#
|
||||
# Target CPU
|
||||
#
|
||||
TARGET_CPU = $(strip $(if $(filter linux,$(TARGET_SYSTEM)), x64, \
|
||||
$(if $(filter stm32f3,$(TARGET_SYSTEM)), cortexm4, \
|
||||
$(if $(filter stm32f4,$(TARGET_SYSTEM)), cortexm4, \
|
||||
$(error Do not know target CPU for target system '$(TARGET_SYSTEM)')))))
|
||||
|
||||
#
|
||||
# Flag blocks
|
||||
#
|
||||
|
||||
# Warnings
|
||||
CFLAGS_WARNINGS ?= -Wall -Wextra -Wpedantic -Wlogical-op -Winline \
|
||||
-Wformat-nonliteral -Winit-self -Wstack-protector \
|
||||
-Wconversion -Wsign-conversion -Wformat-security \
|
||||
-Wstrict-prototypes -Wmissing-prototypes
|
||||
CFLAGS_WERROR ?= -Werror
|
||||
|
||||
# Optimizations
|
||||
CFLAGS_OPTIMIZE ?= -Os -flto
|
||||
CFLAGS_NO_OPTIMIZE ?= -O0
|
||||
LDFLAGS_OPTIMIZE ?=
|
||||
LDFLAGS_NO_OPTIMIZE ?=
|
||||
|
||||
# Debug symbols
|
||||
CFLAGS_DEBUG_SYMS ?= -g3
|
||||
|
||||
# Cortex-M4 MCU
|
||||
CFLAGS_CORTEXM4 ?= -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb \
|
||||
-mfpu=fpv4-sp-d16 -mfloat-abi=hard
|
||||
|
||||
|
||||
#
|
||||
# Common
|
||||
#
|
||||
|
||||
CFLAGS_COMMON ?= $(INCLUDES) -std=c99 # -fsanitize=address -fdiagnostics-color=always
|
||||
|
||||
LDFLAGS ?=
|
||||
|
||||
ifeq ($(OPTION_OPTIMIZE),enable)
|
||||
CFLAGS_COMMON += $(CFLAGS_OPTIMIZE)
|
||||
LDFLAGS += $(LDFLAGS_OPTIMIZE)
|
||||
else
|
||||
CFLAGS_COMMON += $(CFLAGS_NO_OPTIMIZE)
|
||||
LDFLAGS += $(LDFLAGS_NO_OPTIMIZE)
|
||||
endif
|
||||
|
||||
ifeq ($(OPTION_DEBUG_SYMS),enable)
|
||||
CFLAGS_COMMON += $(CFLAGS_DEBUG_SYMS)
|
||||
endif
|
||||
|
||||
# CPU-specific common
|
||||
ifeq ($(TARGET_CPU),cortexm4)
|
||||
CFLAGS_COMMON += $(CFLAGS_CORTEXM4)
|
||||
endif
|
||||
|
||||
# System-specific common
|
||||
ifeq ($(TARGET_SYSTEM),stm32f4)
|
||||
LDFLAGS += -nostartfiles -T$(LNK_SCRIPT_STM32F4)
|
||||
endif
|
||||
|
||||
ifeq ($(OPTION_MCU),enable)
|
||||
CC := $(CROSS_COMPILE)$(CC)
|
||||
LD := $(CROSS_COMPILE)$(LD)
|
||||
OBJDUMP := $(CROSS_COMPILE)$(OBJDUMP)
|
||||
OBJCOPY := $(CROSS_COMPILE)$(OBJCOPY)
|
||||
SIZE := $(CROSS_COMPILE)$(SIZE)
|
||||
STRIP := $(CROSS_COMPILE)$(STRIP)
|
||||
endif
|
||||
|
||||
#
|
||||
# Jerry part sources, headers, includes, cflags, ldflags
|
||||
#
|
||||
|
||||
CFLAGS_JERRY = $(CFLAGS_WARNINGS)
|
||||
DEFINES_JERRY = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -DMEM_STATS
|
||||
|
||||
# FIXME:
|
||||
# Add common-io.c and sensors.c
|
||||
SOURCES_JERRY = \
|
||||
$(sort \
|
||||
$(wildcard ./src/libruntime/*.c) \
|
||||
$(wildcard ./src/libperipherals/actuators.c) \
|
||||
$(wildcard ./src/libjsparser/*.c) \
|
||||
$(wildcard ./src/libecmaobjects/*.c) \
|
||||
$(wildcard ./src/libecmaoperations/*.c) \
|
||||
$(wildcard ./src/liballocator/*.c) \
|
||||
$(wildcard ./src/libcoreint/*.c) ) \
|
||||
$(wildcard src/libruntime/target/$(TARGET_SYSTEM)/*)
|
||||
|
||||
INCLUDES_JERRY = \
|
||||
-I src \
|
||||
-I src/libruntime \
|
||||
-I src/libperipherals \
|
||||
-I src/libjsparser \
|
||||
-I src/libecmaobjects \
|
||||
-I src/libecmaoperations \
|
||||
-I src/liballocator \
|
||||
-I src/libcoreint
|
||||
|
||||
ifeq ($(OPTION_NDEBUG),enable)
|
||||
DEFINES_JERRY += -DJERRY_NDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(OPTION_WERROR),enable)
|
||||
CFLAGS_JERRY += $(CFLAGS_WERROR)
|
||||
endif
|
||||
|
||||
ifeq ($(OPTION_MCU),disable)
|
||||
DEFINES_JERRY += -D__HOST
|
||||
else
|
||||
CFLAGS_COMMON += -ffunction-sections -fdata-sections -nostdlib
|
||||
DEFINES_JERRY += -D__TARGET_MCU
|
||||
endif
|
||||
|
||||
#
|
||||
# Third-party sources, headers, includes, cflags, ldflags
|
||||
#
|
||||
|
||||
SOURCES_THIRDPARTY =
|
||||
INCLUDES_THIRDPARTY =
|
||||
CFLAGS_THIRDPARTY =
|
||||
|
||||
ifeq ($(TARGET_SYSTEM),stm32f4)
|
||||
SOURCES_THIRDPARTY += \
|
||||
./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c \
|
||||
./third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Source/Templates/gcc_ride7/startup_stm32f4xx.s
|
||||
|
||||
INCLUDES_THIRDPARTY += \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/ST/STM32F4xx/Include \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/STM32F4xx_StdPeriph_Driver/inc \
|
||||
-I third-party/STM32F4-Discovery_FW_V1.1.0/Libraries/CMSIS/Include
|
||||
|
||||
#-I third-party/STM32F4-Discovery_FW_V1.1.0/Project/Demonstration \
|
||||
|
||||
endif
|
||||
|
||||
# Unit tests
|
||||
|
||||
SOURCES_UNITTESTS = \
|
||||
$(sort \
|
||||
$(patsubst %.c,%,$(notdir \
|
||||
$(wildcard $(UNITTESTS_SRC_DIR)/*))))
|
||||
|
||||
.PHONY: all clean check install $(JERRY_TARGETS) $(TESTS_TARGET)
|
||||
|
||||
all: clean $(JERRY_TARGETS)
|
||||
|
||||
$(JERRY_TARGETS):
|
||||
@rm -rf $(TARGET_DIR)
|
||||
@mkdir -p $(TARGET_DIR)
|
||||
@rm -rf $(OBJ_DIR)
|
||||
@mkdir $(OBJ_DIR)
|
||||
@source_index=0; \
|
||||
for jerry_src in $(SOURCES_JERRY) $(MAIN_MODULE_SRC); do \
|
||||
cmd="$(CC) -c $(DEFINES_JERRY) $(CFLAGS_COMMON) $(CFLAGS_JERRY) $(INCLUDES_JERRY) $(INCLUDES_THIRDPARTY) $$jerry_src -o $(OBJ_DIR)/$$(basename $$jerry_src).$$source_index.o"; \
|
||||
$$cmd; \
|
||||
if [ $$? -ne 0 ]; then echo Failed "'$$cmd'"; exit 1; fi; \
|
||||
source_index=$$(($$source_index+1)); \
|
||||
done; \
|
||||
for thirdparty_src in $(SOURCES_THIRDPARTY); do \
|
||||
cmd="$(CC) -c $(CFLAGS_COMMON) $(CFLAGS_THIRDPARTY) $(INCLUDES_THIRDPARTY) $$thirdparty_src -o $(OBJ_DIR)/$$(basename $$thirdparty_src).$$source_index.o"; \
|
||||
$$cmd; \
|
||||
if [ $$? -ne 0 ]; then echo Failed "'$$cmd'"; exit 1; fi; \
|
||||
source_index=$$(($$source_index+1)); \
|
||||
done; \
|
||||
cmd="$(CC) $(CFLAGS_COMMON) $(OBJ_DIR)/* $(LDFLAGS) -o $(TARGET_DIR)/$(ENGINE_NAME)"; \
|
||||
$$cmd; \
|
||||
if [ $$? -ne 0 ]; then echo Failed "'$$cmd'"; exit 1; fi;
|
||||
@if [ "$(OPTION_STRIP)" = "enable" ]; then $(STRIP) $(TARGET_DIR)/$(ENGINE_NAME) || exit $$?; fi;
|
||||
@if [ "$(OPTION_MCU)" = "enable" ]; then $(OBJCOPY) -Obinary $(TARGET_DIR)/$(ENGINE_NAME) $(TARGET_DIR)/$(ENGINE_NAME).bin || exit $$?; fi;
|
||||
|
||||
$(TESTS_TARGET):
|
||||
@echo $@ $(TARGET_DIR)
|
||||
@mkdir -p $(TARGET_DIR)
|
||||
@for unit_test in $(SOURCES_UNITTESTS); \
|
||||
do \
|
||||
$(CC) $(DEFINES_JERRY) $(CFLAGS_COMMON) $(CFLAGS_JERRY) \
|
||||
$(INCLUDES_JERRY) $(INCLUDES_THIRDPARTY) $(SOURCES_JERRY) $(UNITTESTS_SRC_DIR)/"$$unit_test".c -o $(TARGET_DIR)/"$$unit_test"; \
|
||||
done
|
||||
@ echo "=== Running unit tests ==="
|
||||
@ ./tools/jerry_unittest.sh $(TARGET_DIR)
|
||||
@ echo Done
|
||||
@ echo
|
||||
|
||||
# FIXME: Change cppcheck's --error-exitcode to 1 after fixing cppcheck's warnings and errors.
|
||||
$(CHECK_TARGETS): $(TARGET_OF_ACTION)
|
||||
@ echo "=== Running cppcheck ==="
|
||||
@ cppcheck $(DEFINES_JERRY) `find $(UNITTESTS_SRC_DIR) -name *.[c]` $(SOURCES_JERRY) $(INCLUDES_JERRY) $(INCLUDES_THIRDPARTY) --error-exitcode=0 --enable=all --std=c99
|
||||
@ echo Done
|
||||
@ echo
|
||||
|
||||
@ echo "=== Running js tests ==="
|
||||
@ if [ -f $(TARGET_DIR)/$(ENGINE_NAME) ]; then \
|
||||
./tools/jerry_test.sh $(TARGET_DIR)/$(ENGINE_NAME); \
|
||||
fi
|
||||
|
||||
@echo Done
|
||||
@echo
|
||||
|
||||
$(FLASH_TARGETS): $(TARGET_OF_ACTION)
|
||||
st-flash write $(OUT_DIR)/$(TARGET_OF_ACTION)/jerry.bin 0x08000000 || exit $$?
|
||||
+7
-14
@@ -16,22 +16,15 @@
|
||||
#ifndef JERRY_GLOBALS_H
|
||||
#define JERRY_GLOBALS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
typedef unsigned long mword_t;
|
||||
typedef mword_t uintptr_t;
|
||||
typedef mword_t size_t;
|
||||
typedef signed long ssize_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
typedef signed int int32_t;
|
||||
|
||||
typedef enum {
|
||||
false, true
|
||||
} bool;
|
||||
|
||||
/**
|
||||
* Attributes
|
||||
@@ -43,8 +36,6 @@ typedef enum {
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
#define NULL ((void*)0)
|
||||
|
||||
#define JERRY_BITSINBYTE 8
|
||||
|
||||
/**
|
||||
@@ -99,8 +90,10 @@ extern void __noreturn jerry_AssertFail( const char *assertion, const char *file
|
||||
/**
|
||||
* Mark for unreachable points and unimplemented cases
|
||||
*/
|
||||
#define JERRY_UNREACHABLE() do { JERRY_ASSERT( false); __builtin_trap(); } while (0)
|
||||
extern void jerry_RefUnusedVariables(int unused_variables_follow, ...);
|
||||
#define JERRY_UNREACHABLE() do { JERRY_ASSERT( false); jerry_Exit( ERR_GENERAL); } while (0)
|
||||
#define JERRY_UNIMPLEMENTED() JERRY_UNREACHABLE()
|
||||
#define JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(...) do { JERRY_UNIMPLEMENTED(); if ( false ) { jerry_RefUnusedVariables( 0, __VA_ARGS__); } } while (0)
|
||||
|
||||
/**
|
||||
* Exit
|
||||
|
||||
@@ -99,7 +99,7 @@ opfunc_loop_inf (OPCODE opdata, struct __int_data *int_data)
|
||||
}
|
||||
|
||||
void
|
||||
opfunc_call_1 (OPCODE opdata, struct __int_data *int_data)
|
||||
opfunc_call_1 (OPCODE opdata __unused, struct __int_data *int_data)
|
||||
{
|
||||
#ifdef __HOST
|
||||
__printf ("%d::op_call_1:idx:%d:%d\n",
|
||||
|
||||
@@ -258,7 +258,7 @@ ecma_GCRun( void)
|
||||
|
||||
if ( pObject->m_IsLexicalEnvironment )
|
||||
{
|
||||
ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u_Attributes.m_LexicalEnvironment.m_pOuterReference);
|
||||
ecma_Object_t *pOuterLexicalEnvironment = ecma_GetPointer( pObject->u.m_LexicalEnvironment.m_pOuterReference);
|
||||
|
||||
if ( pOuterLexicalEnvironment != NULL )
|
||||
{
|
||||
@@ -266,7 +266,7 @@ ecma_GCRun( void)
|
||||
}
|
||||
} else
|
||||
{
|
||||
ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject);
|
||||
ecma_Object_t *pPrototypeObject = ecma_GetPointer( pObject->u.m_Object.m_pPrototypeObject);
|
||||
|
||||
if ( pPrototypeObject != NULL )
|
||||
{
|
||||
|
||||
@@ -101,12 +101,12 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Value type (ecma_Type_t) */
|
||||
uint32_t m_ValueType : 2;
|
||||
unsigned int m_ValueType : 2;
|
||||
|
||||
/**
|
||||
* Simple value (ecma_SimpleValue_t) or compressed pointer to value (depending on m_ValueType)
|
||||
*/
|
||||
uint32_t m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed ecma_Value_t;
|
||||
|
||||
/**
|
||||
@@ -116,15 +116,21 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Type (ecma_CompletionType_t) */
|
||||
uint32_t completion_type : 3;
|
||||
unsigned int type : 3;
|
||||
|
||||
/** Value */
|
||||
ecma_Value_t completion_value;
|
||||
ecma_Value_t value;
|
||||
|
||||
/** Target */
|
||||
uint32_t target : 8;
|
||||
unsigned int target : 8;
|
||||
} __packed ecma_CompletionValue_t;
|
||||
|
||||
/**
|
||||
* Target value indicating that target field
|
||||
* of ecma_CompletionValue_t defines no target.
|
||||
*/
|
||||
#define ECMA_TARGET_ID_RESERVED 255
|
||||
|
||||
/**
|
||||
* Internal properties' identifiers.
|
||||
*/
|
||||
@@ -152,10 +158,10 @@ typedef enum {
|
||||
*/
|
||||
typedef struct ecma_Property_t {
|
||||
/** Property's type (ecma_PropertyType_t) */
|
||||
uint32_t m_Type : 2;
|
||||
unsigned int m_Type : 2;
|
||||
|
||||
/** Compressed pointer to next property */
|
||||
uint32_t m_pNextProperty : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pNextProperty : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Property's details (depending on m_Type) */
|
||||
union {
|
||||
@@ -163,16 +169,16 @@ typedef struct ecma_Property_t {
|
||||
/** Description of named data property */
|
||||
struct __packed ecma_NamedDataProperty_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
uint32_t m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Writable' */
|
||||
uint32_t m_Writable : 1;
|
||||
unsigned int m_Writable : 1;
|
||||
|
||||
/** Attribute 'Enumerable' */
|
||||
uint32_t m_Enumerable : 1;
|
||||
unsigned int m_Enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' */
|
||||
uint32_t m_Configurable : 1;
|
||||
unsigned int m_Configurable : 1;
|
||||
|
||||
/** Value */
|
||||
ecma_Value_t m_Value;
|
||||
@@ -181,28 +187,28 @@ typedef struct ecma_Property_t {
|
||||
/** Description of named accessor property */
|
||||
struct __packed ecma_NamedAccessorProperty_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
uint32_t m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Enumerable' */
|
||||
uint32_t m_Enumerable : 1;
|
||||
unsigned int m_Enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' */
|
||||
uint32_t m_Configurable : 1;
|
||||
unsigned int m_Configurable : 1;
|
||||
|
||||
/** Compressed pointer to property's getter */
|
||||
uint32_t m_pGet : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pGet : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to property's setter */
|
||||
uint32_t m_pSet : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pSet : ECMA_POINTER_FIELD_WIDTH;
|
||||
} m_NamedAccessorProperty;
|
||||
|
||||
/** Description of internal property */
|
||||
struct __packed ecma_InternalProperty_t {
|
||||
/** Internal property's type */
|
||||
uint32_t m_InternalPropertyType : 4;
|
||||
unsigned int m_InternalPropertyType : 4;
|
||||
|
||||
/** Value (may be a compressed pointer) */
|
||||
uint32_t m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} m_InternalProperty;
|
||||
} u;
|
||||
} ecma_Property_t;
|
||||
@@ -215,7 +221,7 @@ typedef struct {
|
||||
* Flag that indicates if the object is valid for normal usage.
|
||||
* If the flag is zero, then the object is not valid and is queued for GC.
|
||||
*/
|
||||
uint32_t m_IsObjectValid : 1;
|
||||
unsigned int m_IsObjectValid : 1;
|
||||
|
||||
/** Details (depending on m_IsObjectValid) */
|
||||
union {
|
||||
@@ -227,10 +233,10 @@ typedef struct {
|
||||
* which is limited by size of address space allocated for JerryScript
|
||||
* (and, consequently, by ECMA_POINTER_FIELD_WIDTH).
|
||||
*/
|
||||
uint32_t m_Refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_Refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to next object in the list of objects, queued for GC (if !m_IsObjectValid) */
|
||||
uint32_t m_NextQueuedForGC : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_NextQueuedForGC : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed u;
|
||||
} ecma_GCInfo_t;
|
||||
|
||||
@@ -248,11 +254,11 @@ typedef enum {
|
||||
*/
|
||||
typedef struct ecma_Object_t {
|
||||
/** Compressed pointer to property list */
|
||||
uint32_t m_pProperties : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pProperties : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Flag indicating whether it is a general object (false)
|
||||
or a lexical environment (true) */
|
||||
uint32_t m_IsLexicalEnvironment : 1;
|
||||
unsigned int m_IsLexicalEnvironment : 1;
|
||||
|
||||
/**
|
||||
* Attributes of either general object or lexical environment
|
||||
@@ -264,10 +270,10 @@ typedef struct ecma_Object_t {
|
||||
*/
|
||||
struct {
|
||||
/** Attribute 'Extensible' */
|
||||
uint32_t m_Extensible : 1;
|
||||
unsigned int m_Extensible : 1;
|
||||
|
||||
/** Compressed pointer to prototype object (ecma_Object_t) */
|
||||
uint32_t m_pPrototypeObject : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pPrototypeObject : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed m_Object;
|
||||
|
||||
/**
|
||||
@@ -277,13 +283,13 @@ typedef struct ecma_Object_t {
|
||||
/**
|
||||
* Type of lexical environment (ecma_LexicalEnvironmentType_t).
|
||||
*/
|
||||
uint32_t m_Type : 1;
|
||||
unsigned int m_Type : 1;
|
||||
|
||||
/** Compressed pointer to outer lexical environment */
|
||||
uint32_t m_pOuterReference : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int m_pOuterReference : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed m_LexicalEnvironment;
|
||||
|
||||
} __packed u_Attributes;
|
||||
} __packed u;
|
||||
|
||||
/** GC's information */
|
||||
ecma_GCInfo_t m_GCInfo;
|
||||
@@ -342,6 +348,30 @@ typedef struct {
|
||||
uint8_t m_Elements[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (uint16_t) ];
|
||||
} ecma_ArrayNonFirstChunk_t;
|
||||
|
||||
/**
|
||||
* \addtogroup reference ECMA-reference
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* ECMA-reference (see also: ECMA-262 v5, 8.7).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** base value */
|
||||
ecma_Value_t base;
|
||||
|
||||
/** referenced name value pointer */
|
||||
ecma_Char_t *referenced_name_p;
|
||||
|
||||
/** strict reference flag */
|
||||
bool is_strict;
|
||||
} ecma_Reference_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* JERRY_ECMA_GLOBALS_H */
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmahelpers Helpers for operations with ECMA data types
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "globals.h"
|
||||
|
||||
/**
|
||||
* Check if the value is undefined.
|
||||
*
|
||||
* @return true - if the value contains ecma-undefined simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsUndefinedValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_UNDEFINED );
|
||||
} /* ecma_IsUndefinedValue */
|
||||
|
||||
/**
|
||||
* Check if the value is null.
|
||||
*
|
||||
* @return true - if the value contains ecma-null simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsNullValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_NULL );
|
||||
} /* ecma_IsNullValue */
|
||||
|
||||
/**
|
||||
* Check if the value is boolean.
|
||||
*
|
||||
* @return true - if the value contains ecma-true or ecma-false simple values,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsBooleanValue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_FALSE )
|
||||
|| ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE ) );
|
||||
} /* ecma_IsBooleanValue */
|
||||
|
||||
/**
|
||||
* Check if the value is true.
|
||||
*
|
||||
* Warning:
|
||||
* value must be boolean
|
||||
*
|
||||
* @return true - if the value contains ecma-true simple value,
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_IsValueTrue( ecma_Value_t value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT( ecma_IsBooleanValue( value) );
|
||||
|
||||
return ( value.m_ValueType == ECMA_TYPE_SIMPLE && value.m_Value == ECMA_SIMPLE_VALUE_TRUE );
|
||||
} /* ecma_IsValueTrue */
|
||||
|
||||
/**
|
||||
* Simple value constructor
|
||||
*/
|
||||
ecma_Value_t
|
||||
ecma_MakeSimpleValue( ecma_SimpleValue_t value) /**< simple value */
|
||||
{
|
||||
return (ecma_Value_t) { .m_ValueType = ECMA_TYPE_SIMPLE, .m_Value = value };
|
||||
} /* ecma_MakeSimpleValue */
|
||||
|
||||
/**
|
||||
* Object value constructor
|
||||
*/
|
||||
ecma_Value_t
|
||||
ecma_MakeObjectValue( ecma_Object_t* object_p) /**< object to reference in value */
|
||||
{
|
||||
JERRY_ASSERT( object_p != NULL );
|
||||
|
||||
ecma_Value_t object_value;
|
||||
|
||||
object_value.m_ValueType = ECMA_TYPE_OBJECT;
|
||||
ecma_SetPointer( object_value.m_Value, object_p);
|
||||
|
||||
return object_value;
|
||||
} /* ecma_MakeObjectValue */
|
||||
|
||||
/**
|
||||
* Completion value constructor
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_MakeCompletionValue(ecma_CompletionType_t type, /**< type */
|
||||
ecma_Value_t value, /**< value */
|
||||
uint8_t target) /**< target */
|
||||
{
|
||||
return (ecma_CompletionValue_t) { .type = type, .value = value, .target = target };
|
||||
} /* ecma_MakeCompletionValue */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -20,10 +20,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of helpers for operations with ECMA data types
|
||||
*/
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
@@ -94,8 +90,8 @@ ecma_CreateObject( ecma_Object_t *pPrototypeObject, /**< pointer to prototybe of
|
||||
* (at least with the ctx_GlobalObject variable) */
|
||||
pObject->m_GCInfo.u.m_Refs = 1;
|
||||
|
||||
pObject->u_Attributes.m_Object.m_Extensible = isExtensible;
|
||||
ecma_SetPointer( pObject->u_Attributes.m_Object.m_pPrototypeObject, pPrototypeObject);
|
||||
pObject->u.m_Object.m_Extensible = isExtensible;
|
||||
ecma_SetPointer( pObject->u.m_Object.m_pPrototypeObject, pPrototypeObject);
|
||||
|
||||
return pObject;
|
||||
} /* ecma_CreateObject */
|
||||
@@ -119,14 +115,14 @@ ecma_CreateLexicalEnvironment(ecma_Object_t *pOuterLexicalEnvironment, /**< oute
|
||||
ecma_Object_t *pNewLexicalEnvironment = ecma_AllocObject();
|
||||
|
||||
pNewLexicalEnvironment->m_IsLexicalEnvironment = true;
|
||||
pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_Type = type;
|
||||
pNewLexicalEnvironment->u.m_LexicalEnvironment.m_Type = type;
|
||||
|
||||
pNewLexicalEnvironment->m_pProperties = ECMA_NULL_POINTER;
|
||||
|
||||
pNewLexicalEnvironment->m_GCInfo.m_IsObjectValid = true;
|
||||
pNewLexicalEnvironment->m_GCInfo.u.m_Refs = 1;
|
||||
|
||||
ecma_SetPointer( pNewLexicalEnvironment->u_Attributes.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment);
|
||||
ecma_SetPointer( pNewLexicalEnvironment->u.m_LexicalEnvironment.m_pOuterReference, pOuterLexicalEnvironment);
|
||||
|
||||
return pNewLexicalEnvironment;
|
||||
} /* ecma_CreateLexicalEnvironment */
|
||||
@@ -157,7 +153,7 @@ ecma_CreateInternalProperty(ecma_Object_t *pObject, /**< the object */
|
||||
/**
|
||||
* Find internal property in the object's property set.
|
||||
*
|
||||
* @return pointer to the property's descriptor, if it is found,
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_Property_t*
|
||||
@@ -204,6 +200,47 @@ ecma_GetInternalProperty(ecma_Object_t *pObject, /**< object descriptor */
|
||||
return pProperty;
|
||||
} /* ecma_GetInternalProperty */
|
||||
|
||||
/**
|
||||
* Find named data property or named access property in specified object.
|
||||
*
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_Property_t*
|
||||
ecma_FindNamedProperty(ecma_Object_t *obj_p, /**< object to find property in */
|
||||
ecma_Char_t *string_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT( obj_p != NULL );
|
||||
JERRY_ASSERT( string_p != NULL );
|
||||
|
||||
for ( ecma_Property_t *property_p = ecma_GetPointer( obj_p->m_pProperties);
|
||||
property_p != NULL;
|
||||
property_p = ecma_GetPointer( property_p->m_pNextProperty) )
|
||||
{
|
||||
ecma_ArrayFirstChunk_t *property_name_p;
|
||||
|
||||
if ( property_p->m_Type == ECMA_PROPERTY_NAMEDDATA )
|
||||
{
|
||||
property_name_p = ecma_GetPointer( property_p->u.m_NamedDataProperty.m_pName);
|
||||
} else if ( property_p->m_Type == ECMA_PROPERTY_NAMEDACCESSOR )
|
||||
{
|
||||
property_name_p = ecma_GetPointer( property_p->u.m_NamedAccessorProperty.m_pName);
|
||||
} else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
JERRY_ASSERT( property_name_p != NULL );
|
||||
|
||||
if ( ecma_CompareCharBufferToEcmaString( string_p, property_name_p) )
|
||||
{
|
||||
return property_p;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
} /* ecma_FindNamedProperty */
|
||||
|
||||
/**
|
||||
* Allocate new ecma-string and fill it with characters from specified buffer
|
||||
*
|
||||
|
||||
@@ -41,6 +41,15 @@ extern void* ecma_DecompressPointer(uintptr_t compressedPointer);
|
||||
#define ecma_SetPointer( field, nonCompressedPointer) \
|
||||
(field) = ecma_CompressPointer( nonCompressedPointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1)
|
||||
|
||||
extern ecma_Value_t ecma_MakeSimpleValue( ecma_SimpleValue_t value);
|
||||
extern ecma_Value_t ecma_MakeObjectValue( ecma_Object_t* object_p);
|
||||
extern ecma_CompletionValue_t ecma_MakeCompletionValue( ecma_CompletionType_t type, ecma_Value_t value, uint8_t target);
|
||||
|
||||
extern bool ecma_IsUndefinedValue( ecma_Value_t value);
|
||||
extern bool ecma_IsNullValue( ecma_Value_t value);
|
||||
extern bool ecma_IsBooleanValue( ecma_Value_t value);
|
||||
extern bool ecma_IsValueTrue( ecma_Value_t value);
|
||||
|
||||
extern ecma_Object_t* ecma_CreateObject( ecma_Object_t *pPrototypeObject, bool isExtensible);
|
||||
extern ecma_Object_t* ecma_CreateLexicalEnvironment( ecma_Object_t *pOuterLexicalEnvironment, ecma_LexicalEnvironmentType_t type);
|
||||
|
||||
@@ -49,6 +58,8 @@ extern ecma_Property_t* ecma_FindInternalProperty(ecma_Object_t *pObject, ecma_I
|
||||
extern ecma_Property_t* ecma_GetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId);
|
||||
extern ecma_Property_t* ecma_SetInternalProperty(ecma_Object_t *pObject, ecma_InternalPropertyId_t propertyId);
|
||||
|
||||
extern ecma_Property_t *ecma_FindNamedProperty(ecma_Object_t *obj_p, ecma_Char_t *string_p);
|
||||
|
||||
extern ecma_ArrayFirstChunk_t* ecma_NewEcmaString( const ecma_Char_t *pString, ecma_Length_t length);
|
||||
extern ssize_t ecma_CopyEcmaStringCharsToBuffer( ecma_ArrayFirstChunk_t *pFirstChunk, uint8_t *pBuffer, size_t bufferSize);
|
||||
extern ecma_ArrayFirstChunk_t* ecma_DuplicateEcmaString( ecma_ArrayFirstChunk_t *pFirstChunk);
|
||||
@@ -61,4 +72,4 @@ extern void ecma_FreeArray( ecma_ArrayFirstChunk_t *pFirstChunk);
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
@@ -21,37 +21,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup syntacticreference Textual reference to variable/property
|
||||
* \addtogroup reference ECMA-reference
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Syntactic (textual/unresolved) reference to a variable/object's property.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* Flag indicating that this is reference to a property.
|
||||
*
|
||||
* Note:
|
||||
* m_PropertyName is valid only if m_IsPropertyReference is true.
|
||||
*/
|
||||
uint32_t m_IsPropertyReference : 1;
|
||||
|
||||
/**
|
||||
* Flag indicating that this reference is strict (see also: ECMA-262 v5, 8.7).
|
||||
*/
|
||||
uint32_t m_StrictReference : 1;
|
||||
|
||||
/**
|
||||
* Name of variable (Null-terminated string).
|
||||
*/
|
||||
ecma_Char_t* m_Name;
|
||||
|
||||
/**
|
||||
* Name of object's property (Null-terminated string).
|
||||
*/
|
||||
ecma_Char_t* m_PropertyName;
|
||||
} ecma_SyntacticReference_t;
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of ECMA GetValue and PutValue
|
||||
*/
|
||||
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "ecma-operations.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*
|
||||
* \addtogroup ecmaoperations ECMA-defined operations
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Resolve syntactic reference to ECMA-reference.
|
||||
*
|
||||
* Warning: string pointed by name_p
|
||||
* must not be freed or reused
|
||||
* until the reference is freed.
|
||||
*
|
||||
* @return ECMA-reference (if base value is an object, upon return
|
||||
* it's reference counter is increased by one).
|
||||
*/
|
||||
ecma_Reference_t
|
||||
ecma_OpGetIdentifierReference(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< identifier's name */
|
||||
bool is_strict) /**< strict reference flag */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL );
|
||||
|
||||
ecma_Object_t *lex_env_iter_p = lex_env_p;
|
||||
|
||||
while ( lex_env_iter_p != NULL )
|
||||
{
|
||||
ecma_CompletionValue_t completion_value;
|
||||
completion_value = ecma_OpHasBinding( lex_env_iter_p, name_p);
|
||||
|
||||
JERRY_ASSERT( completion_value.type == ECMA_COMPLETION_TYPE_NORMAL );
|
||||
|
||||
if ( ecma_IsValueTrue( completion_value.value) )
|
||||
{
|
||||
ecma_RefObject( lex_env_iter_p);
|
||||
|
||||
return (ecma_Reference_t) { .base = ecma_MakeObjectValue( lex_env_iter_p),
|
||||
.referenced_name_p = name_p,
|
||||
.is_strict = is_strict };
|
||||
}
|
||||
|
||||
lex_env_iter_p = ecma_GetPointer( lex_env_iter_p->u.m_LexicalEnvironment.m_pOuterReference);
|
||||
}
|
||||
|
||||
return (ecma_Reference_t) { .base = ecma_MakeObjectValue( NULL),
|
||||
.referenced_name_p = NULL,
|
||||
.is_strict = is_strict };
|
||||
} /* ecma_OpGetIdentifierReference */
|
||||
|
||||
/**
|
||||
* GetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetValue( ecma_Reference_t *ref_p) /**< ECMA-reference */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p);
|
||||
} /* ecma_OpGetValue */
|
||||
|
||||
/**
|
||||
* SetValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 8.7.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetValue(ecma_Reference_t *ref_p, /**< ECMA-reference */
|
||||
ecma_Value_t value) /**< ECMA-value */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( ref_p, value);
|
||||
} /* ecma_OpSetValue */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,153 @@
|
||||
/* 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 "ecma-globals.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-lex-env.h"
|
||||
#include "globals.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lexicalenvironment Lexical environment
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* HasBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpHasBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->m_IsLexicalEnvironment );
|
||||
|
||||
ecma_SimpleValue_t has_binding = ECMA_SIMPLE_VALUE_UNDEFINED;
|
||||
|
||||
switch ( (ecma_LexicalEnvironmentType_t) lex_env_p->u.m_LexicalEnvironment.m_Type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
ecma_Property_t *property_p = ecma_FindNamedProperty( lex_env_p, name_p);
|
||||
|
||||
has_binding = ( property_p != NULL ) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
||||
return ecma_MakeCompletionValue(ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_MakeSimpleValue( has_binding),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} /* ecma_OpHasBinding */
|
||||
|
||||
/**
|
||||
* CreateMutableBinding operation.
|
||||
*
|
||||
* see also: ecma-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpCreateMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
bool is_deletable) /**< argument D */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_deletable);
|
||||
} /* ecma_OpCreateMutableBinding */
|
||||
|
||||
/**
|
||||
* SetMutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpSetMutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
ecma_Value_t value, /**< argument V */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value, is_strict);
|
||||
} /* ecma_OpSetMutableBinding */
|
||||
|
||||
/**
|
||||
* GetBindingValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpGetBindingValue(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, is_strict);
|
||||
} /* ecma_OpGetBindingValue */
|
||||
|
||||
/**
|
||||
* DeleteBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpDeleteBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p);
|
||||
} /* ecma_OpDeleteBinding */
|
||||
|
||||
/**
|
||||
* ImplicitThisValue operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p);
|
||||
} /* ecma_OpImplicitThisValue */
|
||||
|
||||
/**
|
||||
* CreateImmutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpCreateImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p);
|
||||
} /* ecma_OpCreateImmutableBinding */
|
||||
|
||||
/**
|
||||
* InitializeImmutableBinding operation.
|
||||
*
|
||||
* See also: ECMA-262 v5, 10.2.1
|
||||
*/
|
||||
ecma_CompletionValue_t
|
||||
ecma_OpInitializeImmutableBinding(ecma_Object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_Char_t *name_p, /**< argument N */
|
||||
ecma_Value_t value) /**< argument V */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( lex_env_p, name_p, value);
|
||||
} /* ecma_OpInitializeImmutableBinding */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
@@ -0,0 +1,48 @@
|
||||
/* 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 ECMA_LEX_ENV_H
|
||||
#define ECMA_LEX_ENV_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "globals.h"
|
||||
|
||||
/** \addtogroup ecma ---TODO---
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* \addtogroup lexicalenvironment Lexical environment
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* ECMA-262 v5, Table 17. Abstract methods of Environment Records */
|
||||
extern ecma_CompletionValue_t ecma_OpHasBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpCreateMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_deletable);
|
||||
extern ecma_CompletionValue_t ecma_OpSetMutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value, bool is_strict);
|
||||
extern ecma_CompletionValue_t ecma_OpGetBindingValue( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict);
|
||||
extern ecma_CompletionValue_t ecma_OpDeleteBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpImplicitThisValue( ecma_Object_t *lex_env_p);
|
||||
|
||||
/* ECMA-262 v5, Table 18. Additional methods of Declarative Environment Records */
|
||||
extern ecma_CompletionValue_t ecma_OpCreateImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p);
|
||||
extern ecma_CompletionValue_t ecma_OpInitializeImmutableBinding( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* !ECMA_LEX_ENV_H */
|
||||
@@ -26,8 +26,10 @@
|
||||
#include "ecma-globals.h"
|
||||
#include "ecma-reference.h"
|
||||
|
||||
extern ecma_CompletionValue_t ecma_GetValue( ecma_SyntacticReference_t *ref_p);
|
||||
extern ecma_CompletionValue_t ecma_SetValue( ecma_SyntacticReference_t *ref_p, ecma_Value_t value);
|
||||
extern ecma_Reference_t ecma_OpGetIdentifierReference( ecma_Object_t *lex_env_p, ecma_Char_t *name_p, bool is_strict);
|
||||
|
||||
extern ecma_CompletionValue_t ecma_OpGetValue( ecma_Reference_t *ref_p);
|
||||
extern ecma_CompletionValue_t ecma_OpSetValue( ecma_Reference_t *ref_p, ecma_Value_t value);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -83,7 +83,7 @@ static string_and_token keyword_tokens[] =
|
||||
static string_and_token seen_names[MAX_NAMES];
|
||||
static uint8_t seen_names_num;
|
||||
|
||||
static inline bool
|
||||
static bool
|
||||
is_empty (token tok)
|
||||
{
|
||||
return tok.type == TOK_EMPTY;
|
||||
@@ -233,7 +233,7 @@ lexer_get_string_by_id (string_id id)
|
||||
return seen_names[id].str;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
new_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
@@ -247,7 +247,7 @@ consume_char (void)
|
||||
buffer++;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
static const char *
|
||||
current_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
|
||||
@@ -19,6 +19,36 @@
|
||||
|
||||
#include "jerry-libc.h"
|
||||
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
extern void *memcpy(void *s1, const void*s2, size_t n);
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
extern void *memset(void *s, int c, size_t n);
|
||||
|
||||
/**
|
||||
* memcpy alias to __memcpy (for compiler usage)
|
||||
*/
|
||||
void* memcpy(void *s1, /**< destination */
|
||||
const void* s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
return __memcpy(s1, s2, n);
|
||||
} /* memcpy */
|
||||
|
||||
/**
|
||||
* memset alias to __memset (for compiler usage)
|
||||
*/
|
||||
void* memset(void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
return __memset(s, c, n);
|
||||
} /* memset */
|
||||
|
||||
/**
|
||||
* memset
|
||||
*
|
||||
@@ -26,8 +56,8 @@
|
||||
*/
|
||||
void*
|
||||
__memset(void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
uint8_t *pArea = s;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
|
||||
@@ -55,6 +55,6 @@ extern int __fprintf(FILE *, const char *, ...);
|
||||
#define DBL_DIG ( 10)
|
||||
#define DBL_MIN_EXP (-324)
|
||||
#define DBL_MAX_EXP ( 308)
|
||||
#define HUGE_VAL (1e37)
|
||||
#define HUGE_VAL (1e37f)
|
||||
|
||||
#endif /* JERRY_LIBC_H */
|
||||
|
||||
@@ -48,7 +48,8 @@ pp_token (token tok)
|
||||
break;
|
||||
|
||||
case TOK_FLOAT:
|
||||
__printf ("FLOAT (%f)\n", tok.data.fp_num);
|
||||
FIXME(int -> float);
|
||||
__printf ("FLOAT (%d)\n", (int)tok.data.fp_num);
|
||||
break;
|
||||
|
||||
case TOK_NULL:
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
* Handle failed assertion
|
||||
*/
|
||||
void __noreturn
|
||||
jerry_AssertFail(const char *assertion, /**< assertion condition string */
|
||||
const char *file, /**< file name */
|
||||
const uint32_t line) /** line */
|
||||
jerry_AssertFail(const char *assertion __unused, /**< assertion condition string */
|
||||
const char *file __unused, /**< file name */
|
||||
const uint32_t line __unused) /** line */
|
||||
{
|
||||
__exit( -ERR_GENERAL);
|
||||
} /* jerry_AssertFail */
|
||||
|
||||
@@ -36,8 +36,13 @@ __printf(const char *format, /**< format string */
|
||||
|
||||
va_start( args, format);
|
||||
|
||||
int ret = vprintf( format, args);
|
||||
|
||||
/**
|
||||
* TODO: Call internal vprintf implementation when it appears.
|
||||
*/
|
||||
int ret = 0;
|
||||
|
||||
JERRY_UNIMPLEMENTED();
|
||||
|
||||
va_end( args);
|
||||
|
||||
return ret;
|
||||
@@ -52,7 +57,7 @@ __putchar (int c)
|
||||
|
||||
/** exit - cause normal process termination */
|
||||
void __noreturn
|
||||
__exit (int status)
|
||||
__exit (int status __unused)
|
||||
{
|
||||
/**
|
||||
* TODO: Blink LEDs? status -> binary -> LEDs?
|
||||
|
||||
@@ -13,6 +13,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "serializer.h"
|
||||
#include "globals.h"
|
||||
|
||||
void
|
||||
serializer_init (void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
serializer_dump_data (const void *data __unused, size_t size __unused)
|
||||
{
|
||||
}
|
||||
|
||||
TODO (Dump memory)
|
||||
+28
-19
@@ -14,9 +14,14 @@
|
||||
*/
|
||||
|
||||
#ifdef __TARGET_MCU
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
#pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx_gpio.h"
|
||||
#include "stm32f4xx_rcc.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#define LED_GREEN 12
|
||||
#define LED_ORANGE 13
|
||||
@@ -45,11 +50,11 @@ void
|
||||
fake_exit (void)
|
||||
{
|
||||
#ifdef __TARGET_MCU
|
||||
int pin = LED_RED;
|
||||
uint32_t mode = GPIO_Mode_OUT << (pin * 2);
|
||||
uint32_t speed = GPIO_Speed_100MHz << (pin * 2);
|
||||
uint32_t type = GPIO_OType_PP << pin;
|
||||
uint32_t pullup = GPIO_PuPd_NOPULL << (pin * 2);
|
||||
uint32_t pin = LED_RED;
|
||||
uint32_t mode = (uint32_t)GPIO_Mode_OUT << (pin * 2);
|
||||
uint32_t speed = (uint32_t)GPIO_Speed_100MHz << (pin * 2);
|
||||
uint32_t type = (uint32_t)GPIO_OType_PP << pin;
|
||||
uint32_t pullup = (uint32_t)GPIO_PuPd_NOPULL << (pin * 2);
|
||||
//
|
||||
// Initialise the peripheral clock.
|
||||
//
|
||||
@@ -57,10 +62,12 @@ fake_exit (void)
|
||||
//
|
||||
// Initilaise the GPIO port.
|
||||
//
|
||||
GPIOD->MODER |= mode;
|
||||
GPIOD->OSPEEDR |= speed;
|
||||
GPIOD->OTYPER |= type;
|
||||
GPIOD->PUPDR |= pullup;
|
||||
volatile GPIO_TypeDef* gpio = GPIOD;
|
||||
|
||||
gpio->MODER |= mode;
|
||||
gpio->OSPEEDR |= speed;
|
||||
gpio->OTYPER |= type;
|
||||
gpio->PUPDR |= pullup;
|
||||
//
|
||||
// Toggle the selected LED indefinitely.
|
||||
//
|
||||
@@ -73,17 +80,17 @@ fake_exit (void)
|
||||
|
||||
while (1)
|
||||
{
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dash; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dash; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin); for (index = 0; index < dash; index++);
|
||||
GPIOD->BSRRL = (1 << pin); for (index = 0; index < dot; index++); GPIOD->BSRRH = (1 << pin);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin); for (index = 0; index < dash; index++);
|
||||
gpio->BSRRL = (uint16_t) (1 << pin); for (index = 0; index < dot; index++); gpio->BSRRH = (uint16_t) (1 << pin);
|
||||
|
||||
for (index = 0; index < dash * 7; index++);
|
||||
}
|
||||
@@ -113,8 +120,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
statement st;
|
||||
uint8_t dump = 0;
|
||||
const char *file_name = NULL;
|
||||
#ifdef __HOST
|
||||
const char *file_name = NULL;
|
||||
FILE *file = NULL;
|
||||
#endif
|
||||
|
||||
@@ -129,8 +136,10 @@ main (int argc, char **argv)
|
||||
dump |= DUMP_AST;
|
||||
else if (!__strcmp ("-b", argv[i]))
|
||||
dump |= DUMP_BYTECODE;
|
||||
#ifdef __HOST
|
||||
else if (file_name == NULL)
|
||||
file_name = argv[i];
|
||||
#endif
|
||||
else
|
||||
jerry_Exit (ERR_SEVERAL_FILES);
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
require (leds);
|
||||
function LEDsOn () {
|
||||
LEDOn (LED3);
|
||||
LEDOn (LED6);
|
||||
LEDOn (LED7);
|
||||
LEDOn (LED4);
|
||||
LEDOn (LED10);
|
||||
LEDOn (LED8);
|
||||
LEDOn (LED9);
|
||||
LEDOn (LED5);
|
||||
}
|
||||
function LEDsOff () {
|
||||
LEDOff (LED3);
|
||||
LEDOff (LED6);
|
||||
LEDOff (LED7);
|
||||
LEDOff (LED4);
|
||||
LEDOff (LED10);
|
||||
LEDOff (LED8);
|
||||
LEDOff (LED9);
|
||||
LEDOff (LED5);
|
||||
}
|
||||
while (true) {
|
||||
setTimeout (LEDsOn, 500);
|
||||
setTimeout (LEDsOff, 500);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
NEWLINE
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (0.000000)
|
||||
NEWLINE
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (0.100000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (1.000000)
|
||||
FLOAT (0.100000)
|
||||
FLOAT (0.100000)
|
||||
FLOAT (0.100000)
|
||||
NEWLINE
|
||||
FLOAT (123.456001)
|
||||
FLOAT (123.000000)
|
||||
FLOAT (0.456000)
|
||||
FLOAT (inf)
|
||||
FLOAT (inf)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (inf)
|
||||
FLOAT (inf)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (inf)
|
||||
FLOAT (inf)
|
||||
FLOAT (0.000000)
|
||||
NEWLINE
|
||||
FLOAT (122999999650278146048.000000)
|
||||
FLOAT (122999999650278146048.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (123455997908642430976.000000)
|
||||
FLOAT (123455997908642430976.000000)
|
||||
FLOAT (0.000000)
|
||||
FLOAT (456000010710941696.000000)
|
||||
FLOAT (456000010710941696.000000)
|
||||
FLOAT (0.000000)
|
||||
@@ -1,12 +0,0 @@
|
||||
(function () {
|
||||
if ((this != null)) {
|
||||
return this;
|
||||
}
|
||||
while (true) {
|
||||
if ([][2]) return false;
|
||||
}
|
||||
}
|
||||
)({}, function () {
|
||||
return [true];
|
||||
}
|
||||
);
|
||||
@@ -1,8 +0,0 @@
|
||||
NEWLINE
|
||||
INTEGER (0)
|
||||
INTEGER (0)
|
||||
INTEGER (0)
|
||||
INTEGER (1223)
|
||||
INTEGER (57005)
|
||||
INTEGER (61453)
|
||||
INTEGER (61453)
|
||||
@@ -1,54 +0,0 @@
|
||||
NEWLINE
|
||||
KEYWORD (break)
|
||||
KEYWORD (do)
|
||||
KEYWORD (instanceof)
|
||||
KEYWORD (typeof)
|
||||
NEWLINE
|
||||
KEYWORD (case)
|
||||
KEYWORD (else)
|
||||
KEYWORD (new)
|
||||
KEYWORD (var)
|
||||
NEWLINE
|
||||
KEYWORD (catch)
|
||||
KEYWORD (finally)
|
||||
KEYWORD (return)
|
||||
KEYWORD (void)
|
||||
NEWLINE
|
||||
KEYWORD (continue)
|
||||
KEYWORD (for)
|
||||
KEYWORD (switch)
|
||||
KEYWORD (while)
|
||||
NEWLINE
|
||||
KEYWORD (debugger)
|
||||
KEYWORD (function)
|
||||
KEYWORD (this)
|
||||
KEYWORD (with)
|
||||
NEWLINE
|
||||
KEYWORD (default)
|
||||
KEYWORD (if)
|
||||
KEYWORD (throw)
|
||||
NEWLINE
|
||||
KEYWORD (delete)
|
||||
KEYWORD (in)
|
||||
KEYWORD (try)
|
||||
NEWLINE
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
NEWLINE
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
NEWLINE
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
NEWLINE
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
KEYWORD RESERVED
|
||||
NEWLINE
|
||||
@@ -1,2 +0,0 @@
|
||||
NEWLINE
|
||||
NEWLINE
|
||||
@@ -1,26 +0,0 @@
|
||||
var eval = 42;
|
||||
eval = eval++;
|
||||
eval += (--eval);
|
||||
eval -= (++eval);
|
||||
eval *= eval--;
|
||||
function eval (eval) {
|
||||
};
|
||||
try {
|
||||
}
|
||||
catch (eval) {
|
||||
}
|
||||
function strict () {
|
||||
"use strict";
|
||||
eval (arguments);
|
||||
}
|
||||
var eval = 42;
|
||||
eval = eval++;
|
||||
eval += (--eval);
|
||||
eval -= (++eval);
|
||||
eval *= eval--;
|
||||
function eval (eval) {
|
||||
};
|
||||
try {
|
||||
}
|
||||
catch (eval) {
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
with ({}) {
|
||||
}
|
||||
with ({x : 42}) {
|
||||
var foo = function () {
|
||||
"use strict";
|
||||
return x;
|
||||
};
|
||||
}
|
||||
with ({}) {
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
NEWLINE
|
||||
PUNC ({)
|
||||
PUNC (})
|
||||
PUNC (()
|
||||
PUNC ())
|
||||
PUNC ([)
|
||||
PUNC (])
|
||||
NEWLINE
|
||||
PUNC (.)
|
||||
PUNC (;)
|
||||
PUNC (,)
|
||||
PUNC (<)
|
||||
PUNC (>)
|
||||
PUNC (<=)
|
||||
NEWLINE
|
||||
PUNC (>=)
|
||||
PUNC (==)
|
||||
PUNC (!=)
|
||||
PUNC (===)
|
||||
PUNC (!==)
|
||||
NEWLINE
|
||||
PUNC (+)
|
||||
PUNC (-)
|
||||
PUNC (*)
|
||||
PUNC (%)
|
||||
PUNC (++)
|
||||
PUNC (--)
|
||||
NEWLINE
|
||||
PUNC (<<)
|
||||
PUNC (>>)
|
||||
PUNC (>>>)
|
||||
PUNC (&)
|
||||
PUNC (|)
|
||||
PUNC (^)
|
||||
NEWLINE
|
||||
PUNC (!)
|
||||
PUNC (~)
|
||||
PUNC (&&)
|
||||
PUNC (||)
|
||||
PUNC (?)
|
||||
PUNC (:)
|
||||
NEWLINE
|
||||
PUNC (=)
|
||||
PUNC (+=)
|
||||
PUNC (-=)
|
||||
PUNC (*=)
|
||||
PUNC (%=)
|
||||
PUNC (<<=)
|
||||
NEWLINE
|
||||
PUNC (>>=)
|
||||
PUNC (>>>=)
|
||||
PUNC (&=)
|
||||
PUNC (|=)
|
||||
PUNC (^=)
|
||||
@@ -1,5 +0,0 @@
|
||||
function foo () {
|
||||
"use strict";
|
||||
with ({}) {
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
NEWLINE
|
||||
STRING ()
|
||||
NEWLINE
|
||||
STRING ()
|
||||
NEWLINE
|
||||
STRING (a)
|
||||
NEWLINE
|
||||
STRING (aaa)
|
||||
NEWLINE
|
||||
STRING (a
|
||||
a)
|
||||
NEWLINE
|
||||
STRING (")
|
||||
NEWLINE
|
||||
STRING (')
|
||||
NEWLINE
|
||||
STRING (')
|
||||
NEWLINE
|
||||
STRING (')
|
||||
NEWLINE
|
||||
STRING (")
|
||||
NEWLINE
|
||||
STRING (")
|
||||
@@ -1,22 +0,0 @@
|
||||
var x = 42;
|
||||
var y = "hello world";
|
||||
if ((x == y)) {
|
||||
with ({x : 10, y : "20", z : 42}) {
|
||||
print (z);
|
||||
}
|
||||
}
|
||||
try {
|
||||
x = 2;
|
||||
throw y;
|
||||
y = 4;
|
||||
}
|
||||
catch (e) {
|
||||
y = e;
|
||||
}
|
||||
finally {
|
||||
x = y;
|
||||
}
|
||||
for (var i = 0; (i < 10); i++) {
|
||||
x += x;
|
||||
}
|
||||
print (y);
|
||||
@@ -15,7 +15,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR="$1"
|
||||
UNITTESTS="${*:2}"
|
||||
|
||||
rm -f $DIR/unit_tests_run.log
|
||||
|
||||
UNITTESTS=$(ls $DIR)
|
||||
|
||||
for unit_test in $UNITTESTS;
|
||||
do
|
||||
|
||||
Reference in New Issue
Block a user