Apply clang-formatting

This commit is contained in:
Junyoung Cho 2016-12-08 13:37:18 +09:00
commit f7a22f54fc
169 changed files with 2946 additions and 3074 deletions

90
.clang-format Normal file
View file

@ -0,0 +1,90 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 500
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...

View file

@ -1,28 +1,28 @@
#ifndef __Escargot__
#define __Escargot__
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <string>
#include <cstring>
#include <sstream>
#include <cassert>
#include <functional>
#include <algorithm>
#include <cassert>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <limits>
#include <locale>
#include <clocale>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cwchar>
#include <climits>
#include <functional>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <unicode/locid.h>
#include <unicode/uchar.h>
@ -31,8 +31,8 @@
#ifndef PROFILE_MASSIF
#include <gc_cpp.h>
#include <gc_allocator.h>
#include <gc_cpp.h>
#else
@ -55,8 +55,8 @@ void GC_free_hook(void* address);
#define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) GC_register_finalizer_no_order(p, f, d, of, od)
#include <gc_cpp.h>
#include <gc_allocator.h>
#include <gc_cpp.h>
#endif
@ -66,57 +66,56 @@ namespace Escargot {
template <class GC_Tp>
class gc_malloc_allocator {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef const GC_Tp* const_pointer;
typedef GC_Tp& reference;
typedef GC_Tp& reference;
typedef const GC_Tp& const_reference;
typedef GC_Tp value_type;
typedef GC_Tp value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_allocator<GC_Tp1> other;
};
gc_malloc_allocator() throw() { }
gc_malloc_allocator(const gc_malloc_allocator&) throw() { }
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
gc_malloc_allocator() throw() {}
gc_malloc_allocator(const gc_malloc_allocator&) throw() {}
#if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
template <class GC_Tp1> gc_malloc_allocator
(const gc_malloc_allocator<GC_Tp1>&) throw() { }
# endif
~gc_malloc_allocator() throw() { }
template <class GC_Tp1>
gc_malloc_allocator(const gc_malloc_allocator<GC_Tp1>&) throw() {}
#endif
~gc_malloc_allocator() throw()
{
}
pointer address(reference GC_x) const { return &GC_x; }
const_pointer address(const_reference GC_x) const { return &GC_x; }
// GC_n is permitted to be 0. The C++ standard says nothing about what
// the return value is when GC_n == 0.
GC_Tp* allocate(size_type GC_n, const void* = 0)
{
return (GC_Tp *)GC_MALLOC(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC(sizeof(GC_Tp) * GC_n);
}
// __p is not permitted to be a null pointer.
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
{ return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new(__p) GC_Tp(__val); }
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) { GC_FREE(__p); }
size_type max_size() const throw() { return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new (__p) GC_Tp(__val); }
void destroy(pointer __p) { __p->~GC_Tp(); }
};
template<>
template <>
class gc_malloc_allocator<void> {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
typedef void value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_allocator<GC_Tp1> other;
};
};
@ -137,57 +136,56 @@ inline bool operator!=(const gc_malloc_allocator<GC_T1>&, const gc_malloc_alloca
template <class GC_Tp>
class gc_malloc_pointer_free_allocator {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef const GC_Tp* const_pointer;
typedef GC_Tp& reference;
typedef GC_Tp& reference;
typedef const GC_Tp& const_reference;
typedef GC_Tp value_type;
typedef GC_Tp value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_pointer_free_allocator<GC_Tp1> other;
};
gc_malloc_pointer_free_allocator() throw() { }
gc_malloc_pointer_free_allocator(const gc_malloc_pointer_free_allocator&) throw() { }
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
gc_malloc_pointer_free_allocator() throw() {}
gc_malloc_pointer_free_allocator(const gc_malloc_pointer_free_allocator&) throw() {}
#if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
template <class GC_Tp1> gc_malloc_pointer_free_allocator
(const gc_malloc_pointer_free_allocator<GC_Tp1>&) throw() { }
# endif
~gc_malloc_pointer_free_allocator() throw() { }
template <class GC_Tp1>
gc_malloc_pointer_free_allocator(const gc_malloc_pointer_free_allocator<GC_Tp1>&) throw() {}
#endif
~gc_malloc_pointer_free_allocator() throw()
{
}
pointer address(reference GC_x) const { return &GC_x; }
const_pointer address(const_reference GC_x) const { return &GC_x; }
// GC_n is permitted to be 0. The C++ standard says nothing about what
// the return value is when GC_n == 0.
GC_Tp* allocate(size_type GC_n, const void* = 0)
{
return (GC_Tp *)GC_MALLOC_ATOMIC(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC_ATOMIC(sizeof(GC_Tp) * GC_n);
}
// __p is not permitted to be a null pointer.
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
{ return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new(__p) GC_Tp(__val); }
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) { GC_FREE(__p); }
size_type max_size() const throw() { return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new (__p) GC_Tp(__val); }
void destroy(pointer __p) { __p->~GC_Tp(); }
};
template<>
template <>
class gc_malloc_pointer_free_allocator<void> {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
typedef void value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_pointer_free_allocator<GC_Tp1> other;
};
};
@ -209,61 +207,60 @@ inline bool operator!=(const gc_malloc_pointer_free_allocator<GC_T1>&, const gc_
template <class GC_Tp>
class gc_malloc_ignore_off_page_allocator {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef const GC_Tp* const_pointer;
typedef GC_Tp& reference;
typedef GC_Tp& reference;
typedef const GC_Tp& const_reference;
typedef GC_Tp value_type;
typedef GC_Tp value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_ignore_off_page_allocator<GC_Tp1> other;
};
gc_malloc_ignore_off_page_allocator() throw() { }
gc_malloc_ignore_off_page_allocator(const gc_malloc_ignore_off_page_allocator&) throw() { }
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
gc_malloc_ignore_off_page_allocator() throw() {}
gc_malloc_ignore_off_page_allocator(const gc_malloc_ignore_off_page_allocator&) throw() {}
#if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
template <class GC_Tp1> gc_malloc_ignore_off_page_allocator
(const gc_malloc_ignore_off_page_allocator<GC_Tp1>&) throw() { }
# endif
~gc_malloc_ignore_off_page_allocator() throw() { }
template <class GC_Tp1>
gc_malloc_ignore_off_page_allocator(const gc_malloc_ignore_off_page_allocator<GC_Tp1>&) throw() {}
#endif
~gc_malloc_ignore_off_page_allocator() throw()
{
}
pointer address(reference GC_x) const { return &GC_x; }
const_pointer address(const_reference GC_x) const { return &GC_x; }
// GC_n is permitted to be 0. The C++ standard says nothing about what
// the return value is when GC_n == 0.
GC_Tp* allocate(size_type GC_n, const void* = 0)
{
if (sizeof(GC_Tp) * GC_n > 1024) {
return (GC_Tp *)GC_MALLOC_IGNORE_OFF_PAGE(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC_IGNORE_OFF_PAGE(sizeof(GC_Tp) * GC_n);
} else {
return (GC_Tp *)GC_MALLOC(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC(sizeof(GC_Tp) * GC_n);
}
}
// __p is not permitted to be a null pointer.
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
{ return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new(__p) GC_Tp(__val); }
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) { GC_FREE(__p); }
size_type max_size() const throw() { return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new (__p) GC_Tp(__val); }
void destroy(pointer __p) { __p->~GC_Tp(); }
};
template<>
template <>
class gc_malloc_ignore_off_page_allocator<void> {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
typedef void value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_ignore_off_page_allocator<GC_Tp1> other;
};
};
@ -284,61 +281,60 @@ inline bool operator!=(const gc_malloc_ignore_off_page_allocator<GC_T1>&, const
template <class GC_Tp>
class gc_malloc_atomic_ignore_off_page_allocator {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef GC_Tp* pointer;
typedef const GC_Tp* const_pointer;
typedef GC_Tp& reference;
typedef GC_Tp& reference;
typedef const GC_Tp& const_reference;
typedef GC_Tp value_type;
typedef GC_Tp value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_atomic_ignore_off_page_allocator<GC_Tp1> other;
};
gc_malloc_atomic_ignore_off_page_allocator() throw() { }
gc_malloc_atomic_ignore_off_page_allocator(const gc_malloc_atomic_ignore_off_page_allocator&) throw() { }
# if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
gc_malloc_atomic_ignore_off_page_allocator() throw() {}
gc_malloc_atomic_ignore_off_page_allocator(const gc_malloc_atomic_ignore_off_page_allocator&) throw() {}
#if !(GC_NO_MEMBER_TEMPLATES || 0 < _MSC_VER && _MSC_VER <= 1200)
// MSVC++ 6.0 do not support member templates
template <class GC_Tp1> gc_malloc_atomic_ignore_off_page_allocator
(const gc_malloc_atomic_ignore_off_page_allocator<GC_Tp1>&) throw() { }
# endif
~gc_malloc_atomic_ignore_off_page_allocator() throw() { }
template <class GC_Tp1>
gc_malloc_atomic_ignore_off_page_allocator(const gc_malloc_atomic_ignore_off_page_allocator<GC_Tp1>&) throw() {}
#endif
~gc_malloc_atomic_ignore_off_page_allocator() throw()
{
}
pointer address(reference GC_x) const { return &GC_x; }
const_pointer address(const_reference GC_x) const { return &GC_x; }
// GC_n is permitted to be 0. The C++ standard says nothing about what
// the return value is when GC_n == 0.
GC_Tp* allocate(size_type GC_n, const void* = 0)
{
if (sizeof(GC_Tp) * GC_n > 1024) {
return (GC_Tp *)GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC_ATOMIC_IGNORE_OFF_PAGE(sizeof(GC_Tp) * GC_n);
} else {
return (GC_Tp *)GC_MALLOC_ATOMIC(sizeof(GC_Tp) * GC_n);
return (GC_Tp*)GC_MALLOC_ATOMIC(sizeof(GC_Tp) * GC_n);
}
}
// __p is not permitted to be a null pointer.
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
{ return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new(__p) GC_Tp(__val); }
void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n) { GC_FREE(__p); }
size_type max_size() const throw() { return size_t(-1) / sizeof(GC_Tp); }
void construct(pointer __p, const GC_Tp& __val) { new (__p) GC_Tp(__val); }
void destroy(pointer __p) { __p->~GC_Tp(); }
};
template<>
template <>
class gc_malloc_atomic_ignore_off_page_allocator<void> {
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef void* pointer;
typedef const void* const_pointer;
typedef void value_type;
typedef void value_type;
template <class GC_Tp1> struct rebind {
template <class GC_Tp1>
struct rebind {
typedef gc_malloc_atomic_ignore_off_page_allocator<GC_Tp1> other;
};
};
@ -355,12 +351,11 @@ inline bool operator!=(const gc_malloc_atomic_ignore_off_page_allocator<GC_T1>&,
{
return false;
}
}
/* COMPILER() - the compiler being used to build the project */
#define COMPILER(FEATURE) (defined COMPILER_##FEATURE && COMPILER_##FEATURE)
#define COMPILER(FEATURE) (defined COMPILER_##FEATURE && COMPILER_##FEATURE)
/* COMPILER(MSVC) - Microsoft Visual C++ */
@ -468,7 +463,7 @@ inline bool operator!=(const gc_malloc_atomic_ignore_off_page_allocator<GC_T1>&,
#include <dlog/dlog.h>
#undef ESCARGOT_LOG_INFO
#undef ESCARGOT_LOG_ERROR
#define ESCARGOT_LOG_INFO(...) dlog_print(DLOG_INFO, "Escargot", __VA_ARGS__);
#define ESCARGOT_LOG_INFO(...) dlog_print(DLOG_INFO, "Escargot", __VA_ARGS__);
#define ESCARGOT_LOG_ERROR(...) dlog_print(DLOG_ERROR, "Escargot", __VA_ARGS__);
#endif
@ -482,7 +477,10 @@ inline bool operator!=(const gc_malloc_atomic_ignore_off_page_allocator<GC_T1>&,
#define ASSERT_STATIC(assertion, reason)
#else
#define ASSERT(assertion) assert(assertion);
#define ASSERT_NOT_REACHED() do { assert(false); } while (0)
#define ASSERT_NOT_REACHED() \
do { \
assert(false); \
} while (0)
#define ASSERT_STATIC(assertion, reason) static_assert(assertion, reason)
#endif
@ -491,8 +489,18 @@ inline bool operator!=(const gc_malloc_atomic_ignore_off_page_allocator<GC_T1>&,
#define COMPILE_ASSERT(exp, name) static_assert((exp), #name)
#endif
#define RELEASE_ASSERT(assertion) do { if (!(assertion)) { ESCARGOT_LOG_ERROR("RELEASE_ASSERT at %s (%d)\n", __FILE__, __LINE__); abort(); } } while (0);
#define RELEASE_ASSERT_NOT_REACHED() do { ESCARGOT_LOG_ERROR("RELEASE_ASSERT_NOT_REACHED at %s (%d)\n", __FILE__, __LINE__); abort(); } while (0)
#define RELEASE_ASSERT(assertion) \
do { \
if (!(assertion)) { \
ESCARGOT_LOG_ERROR("RELEASE_ASSERT at %s (%d)\n", __FILE__, __LINE__); \
abort(); \
} \
} while (0);
#define RELEASE_ASSERT_NOT_REACHED() \
do { \
ESCARGOT_LOG_ERROR("RELEASE_ASSERT_NOT_REACHED at %s (%d)\n", __FILE__, __LINE__); \
abort(); \
} while (0)
#if !defined(WARN_UNUSED_RETURN) && COMPILER(GCC)
#define WARN_UNUSED_RETURN __attribute__((__warn_unused_result__))
@ -502,36 +510,21 @@ inline bool operator!=(const gc_malloc_atomic_ignore_off_page_allocator<GC_T1>&,
#define WARN_UNUSED_RETURN
#endif
#if defined(__BYTE_ORDER__) && __BYTE_ORDER == __BIG_ENDIAN || \
defined(__BIG_ENDIAN__) || \
defined(__ARMEB__) || \
defined(__THUMBEB__) || \
defined(__AARCH64EB__) || \
defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
#if defined(__BYTE_ORDER__) && __BYTE_ORDER == __BIG_ENDIAN || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || defined(_MIBSEB) || defined(__MIBSEB) || defined(__MIBSEB__)
#define ESCARGOT_BIG_ENDIAN
// #pragma message "big endian"
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER == __LITTLE_ENDIAN || \
defined(__LITTLE_ENDIAN__) || \
defined(__i386) || \
defined(_M_IX86) || \
defined(__ia64) || \
defined(__ia64__) || \
defined(_M_IA64) || \
defined(__ARMEL__) || \
defined(__THUMBEL__) || \
defined(__AARCH64EL__) || \
defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
#elif defined(__BYTE_ORDER__) && __BYTE_ORDER == __LITTLE_ENDIAN || defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(_M_IX86) || defined(__ia64) || defined(__ia64__) || defined(_M_IA64) || defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
#define ESCARGOT_LITTLE_ENDIAN
// #pragma message "little endian"
#else
#error "I don't know what architecture this is!"
#endif
#define MAKE_STACK_ALLOCATED() \
static void *operator new (size_t) = delete; \
static void *operator new[] (size_t) = delete; \
static void operator delete (void*) = delete; \
static void operator delete[](void*) = delete;
#define MAKE_STACK_ALLOCATED() \
static void* operator new(size_t) = delete; \
static void* operator new[](size_t) = delete; \
static void operator delete(void*) = delete; \
static void operator delete[](void*) = delete;
#define ALLOCA(bytes, typenameWithoutPointer, ec) (typenameWithoutPointer*)alloca(bytes)

View file

@ -25,7 +25,7 @@ NodeLOC ByteCodeBlock::computeNodeLOCFromByteCode(ByteCode* code, CodeBlock* cb)
}
size_t line = cb->sourceElementStart().line;
size_t column = cb->sourceElementStart().column;
for(size_t i = 0; i < code->m_loc.index; i ++) {
for (size_t i = 0; i < code->m_loc.index; i++) {
char16_t c = cb->src().charAt(i);
if (isLineTerminator(c)) {
line++;
@ -34,5 +34,4 @@ NodeLOC ByteCodeBlock::computeNodeLOCFromByteCode(ByteCode* code, CodeBlock* cb)
}
return NodeLOC(line, column, code->m_loc.index);
}
}

View file

@ -1,79 +1,79 @@
#ifndef __EscargotByteCode__
#define __EscargotByteCode__
#include "runtime/Value.h"
#include "runtime/String.h"
#include "interpreter/ByteCodeGenerator.h"
#include "parser/CodeBlock.h"
#include "parser/ast/Node.h"
#include "runtime/SmallValue.h"
#include "interpreter/ByteCodeGenerator.h"
#include "runtime/String.h"
#include "runtime/Value.h"
namespace Escargot {
class ObjectStructure;
class Node;
// <OpcodeName, PushCount, PopCount>
#define FOR_EACH_BYTECODE_OP(F) \
F(LoadLiteral, 1, 0) \
F(LoadByName, 1, 0) \
F(StoreByName, 0, 0) \
F(LoadByStackIndex, 1, 0) \
F(StoreByStackIndex, 0, 0) \
F(LoadByHeapIndex, 1, 0) \
F(StoreByHeapIndex, 0, 0) \
F(LoadByGlobalName, 1, 0) \
F(StoreByGlobalName, 0, 0) \
F(DeclareVarVariable, 0, 0) \
#define FOR_EACH_BYTECODE_OP(F) \
F(LoadLiteral, 1, 0) \
F(LoadByName, 1, 0) \
F(StoreByName, 0, 0) \
F(LoadByStackIndex, 1, 0) \
F(StoreByStackIndex, 0, 0) \
F(LoadByHeapIndex, 1, 0) \
F(StoreByHeapIndex, 0, 0) \
F(LoadByGlobalName, 1, 0) \
F(StoreByGlobalName, 0, 0) \
F(DeclareVarVariable, 0, 0) \
F(DeclareFunctionDeclaration, 1, 0) \
F(DeclareFunctionExpression, 1, 0) \
F(GetThis, 1, 0) \
F(NewOperation, 1, 0) \
F(BinaryPlus, 1, 2) \
F(BinaryMinus, 1, 2) \
F(BinaryMultiply, 1, 2) \
F(BinaryDivision, 1, 2) \
F(BinaryMod, 1, 2) \
F(BinaryEqual, 1, 2) \
F(BinaryLessThan, 1, 2) \
F(BinaryLessThanOrEqual, 1, 2) \
F(BinaryGreaterThan, 1, 2) \
F(BinaryGreaterThanOrEqual, 1, 2) \
F(BinaryNotEqual, 1, 2) \
F(BinaryStrictEqual, 1, 2) \
F(BinaryNotStrictEqual, 1, 2) \
F(BinaryBitwiseAnd, 1, 2) \
F(BinaryBitwiseOr, 1, 2) \
F(BinaryBitwiseXor, 1, 2) \
F(BinaryLeftShift, 1, 2) \
F(BinarySignedRightShift, 1, 2) \
F(BinaryUnsignedRightShift, 1, 2) \
F(CreateObject, 1, 0) \
F(GetObject, 1, 2) \
F(SetObject, 0, 2) \
F(GetObjectPreComputedCase, 1, 1) \
F(SetObjectPreComputedCase, 0, 1) \
F(GetGlobalObject, 1, 1) \
F(SetGlobalObject, 0, 1) \
F(Move, 1, 0) \
F(Increment, 1, 1) \
F(Decrement, 1, 1) \
F(UnaryMinus, 1, 1) \
F(UnaryPlus, 1, 1) \
F(Jump, 0, 0) \
F(JumpComplexCase, 0, 0) \
F(JumpIfTrue, 0, 0) \
F(JumpIfFalse, 0, 0) \
F(CallFunction, -1, 0) \
F(ReturnFunction, 0, 0) \
F(ThrowOperation, 0, 0) \
F(CallNativeFunction, 0, 0) \
F(End, 0, 0) \
F(DeclareFunctionExpression, 1, 0) \
F(GetThis, 1, 0) \
F(NewOperation, 1, 0) \
F(BinaryPlus, 1, 2) \
F(BinaryMinus, 1, 2) \
F(BinaryMultiply, 1, 2) \
F(BinaryDivision, 1, 2) \
F(BinaryMod, 1, 2) \
F(BinaryEqual, 1, 2) \
F(BinaryLessThan, 1, 2) \
F(BinaryLessThanOrEqual, 1, 2) \
F(BinaryGreaterThan, 1, 2) \
F(BinaryGreaterThanOrEqual, 1, 2) \
F(BinaryNotEqual, 1, 2) \
F(BinaryStrictEqual, 1, 2) \
F(BinaryNotStrictEqual, 1, 2) \
F(BinaryBitwiseAnd, 1, 2) \
F(BinaryBitwiseOr, 1, 2) \
F(BinaryBitwiseXor, 1, 2) \
F(BinaryLeftShift, 1, 2) \
F(BinarySignedRightShift, 1, 2) \
F(BinaryUnsignedRightShift, 1, 2) \
F(CreateObject, 1, 0) \
F(GetObject, 1, 2) \
F(SetObject, 0, 2) \
F(GetObjectPreComputedCase, 1, 1) \
F(SetObjectPreComputedCase, 0, 1) \
F(GetGlobalObject, 1, 1) \
F(SetGlobalObject, 0, 1) \
F(Move, 1, 0) \
F(Increment, 1, 1) \
F(Decrement, 1, 1) \
F(UnaryMinus, 1, 1) \
F(UnaryPlus, 1, 1) \
F(Jump, 0, 0) \
F(JumpComplexCase, 0, 0) \
F(JumpIfTrue, 0, 0) \
F(JumpIfFalse, 0, 0) \
F(CallFunction, -1, 0) \
F(ReturnFunction, 0, 0) \
F(ThrowOperation, 0, 0) \
F(CallNativeFunction, 0, 0) \
F(End, 0, 0)
enum Opcode {
#define DECLARE_BYTECODE(name, pushCount, popCount) name##Opcode,
FOR_EACH_BYTECODE_OP(DECLARE_BYTECODE)
#undef DECLARE_BYTECODE
OpcodeKindEnd
OpcodeKindEnd
} __attribute__((packed));
struct OpcodeTable {
@ -89,10 +89,10 @@ inline const char* getByteCodeName(Opcode opcode)
{
switch (opcode) {
#define RETURN_BYTECODE_NAME(name, pushCount, popCount) \
case name##Opcode: \
case name##Opcode: \
return #name;
FOR_EACH_BYTECODE_OP(RETURN_BYTECODE_NAME)
#undef RETURN_BYTECODE_NAME
#undef RETURN_BYTECODE_NAME
default:
RELEASE_ASSERT_NOT_REACHED();
}
@ -102,7 +102,7 @@ inline const char* getByteCodeName(Opcode opcode)
#ifndef NDEBUG
inline const char* getByteCodeNameFromAddress(void* opcodeInAddress)
{
for (size_t i = 0; i < OpcodeKindEnd; i ++) {
for (size_t i = 0; i < OpcodeKindEnd; i++) {
if (g_opcodeTable.m_reverseTable[i].first == opcodeInAddress)
return getByteCodeName(g_opcodeTable.m_reverseTable[i].second);
}
@ -114,10 +114,10 @@ inline size_t getByteCodePushCount(Opcode code)
{
switch (code) {
#define RETURN_BYTECODE_CNT(name, pushCount, popCount) \
case name##Opcode: \
case name##Opcode: \
return pushCount;
FOR_EACH_BYTECODE_OP(RETURN_BYTECODE_CNT)
#undef RETURN_BYTECODE_CNT
#undef RETURN_BYTECODE_CNT
default:
RELEASE_ASSERT_NOT_REACHED();
}
@ -127,10 +127,10 @@ inline size_t getByteCodePopCount(Opcode code)
{
switch (code) {
#define RETURN_BYTECODE_CNT(name, pushCount, popCount) \
case name##Opcode: \
case name##Opcode: \
return popCount;
FOR_EACH_BYTECODE_OP(RETURN_BYTECODE_CNT)
#undef RETURN_BYTECODE_CNT
#undef RETURN_BYTECODE_CNT
default:
RELEASE_ASSERT_NOT_REACHED();
}
@ -190,7 +190,6 @@ public:
virtual void dump()
{
}
#endif
@ -203,7 +202,6 @@ public:
, m_registerIndex(registerIndex)
, m_value(v)
{
}
size_t m_registerIndex;
SmallValue m_value;
@ -476,26 +474,26 @@ public:
#ifdef NDEBUG
#define DEFINE_BINARY_OPERATION_DUMP(name)
#else
#define DEFINE_BINARY_OPERATION_DUMP(name) \
virtual void dump() \
{ \
printf(name" r%d <- r%d , r%d", (int)m_srcIndex0, (int)m_srcIndex0, (int)m_srcIndex1); \
#define DEFINE_BINARY_OPERATION_DUMP(name) \
virtual void dump() \
{ \
printf(name " r%d <- r%d , r%d", (int)m_srcIndex0, (int)m_srcIndex0, (int)m_srcIndex1); \
}
#endif
#define DEFINE_BINARY_OPERATION(CodeName, HumanName) \
class Binary##CodeName : public ByteCode { \
public: \
Binary##CodeName(const ByteCodeLOC& loc, const size_t& registerIndex0, const size_t& registerIndex1) \
: ByteCode(Opcode::Binary##CodeName##Opcode, loc) \
, m_srcIndex0(registerIndex0) \
, m_srcIndex1(registerIndex1) \
{ \
} \
size_t m_srcIndex0; \
size_t m_srcIndex1; \
DEFINE_BINARY_OPERATION_DUMP(HumanName) \
};
#define DEFINE_BINARY_OPERATION(CodeName, HumanName) \
class Binary##CodeName : public ByteCode { \
public: \
Binary##CodeName(const ByteCodeLOC& loc, const size_t& registerIndex0, const size_t& registerIndex1) \
: ByteCode(Opcode::Binary##CodeName##Opcode, loc) \
, m_srcIndex0(registerIndex0) \
, m_srcIndex1(registerIndex1) \
{ \
} \
size_t m_srcIndex0; \
size_t m_srcIndex1; \
DEFINE_BINARY_OPERATION_DUMP(HumanName) \
};
DEFINE_BINARY_OPERATION(Plus, "plus");
DEFINE_BINARY_OPERATION(Minus, "minus");
@ -578,7 +576,7 @@ public:
};
typedef Vector<ObjectStructure*, gc_malloc_ignore_off_page_allocator<ObjectStructure*> > ObjectStructureChain;
typedef Vector<ObjectStructure*, gc_malloc_ignore_off_page_allocator<ObjectStructure*>> ObjectStructureChain;
struct GetObjectInlineCacheData {
GetObjectInlineCacheData()
@ -590,7 +588,7 @@ struct GetObjectInlineCacheData {
};
struct GetObjectInlineCache {
Vector<GetObjectInlineCacheData, gc_malloc_ignore_off_page_allocator<GetObjectInlineCacheData> > m_cache;
Vector<GetObjectInlineCacheData, gc_malloc_ignore_off_page_allocator<GetObjectInlineCacheData>> m_cache;
size_t m_executeCount;
GetObjectInlineCache()
{
@ -702,9 +700,9 @@ public:
class Move : public ByteCode {
public:
Move(const ByteCodeLOC& loc, const size_t& registerIndex0, const size_t& registerIndex1) // 1 <= 0
: ByteCode(Opcode::MoveOpcode, loc)
, m_registerIndex0(registerIndex0)
, m_registerIndex1(registerIndex1)
: ByteCode(Opcode::MoveOpcode, loc),
m_registerIndex0(registerIndex0),
m_registerIndex1(registerIndex1)
{
}
@ -963,17 +961,17 @@ public:
template <typename CodeType>
void pushCode(const CodeType& code, ByteCodeGenerateContext* context, Node* node)
{
#ifndef NDEBUG
#ifndef NDEBUG
{
CodeType& t = const_cast<CodeType &>(code);
CodeType& t = const_cast<CodeType&>(code);
t.m_node = node;
t.m_loc.line = computeNodeLOCFromByteCode(&t, context->m_codeBlock).line;
t.m_loc.column = computeNodeLOCFromByteCode(&t, context->m_codeBlock).column;
}
#endif
#endif
const_cast<CodeType &>(code).assignOpcodeInAddress();
char* first = (char *)&code;
const_cast<CodeType&>(code).assignOpcodeInAddress();
char* first = (char*)&code;
m_code.insert(m_code.end(), first, first + sizeof(CodeType));
m_requiredRegisterFileSizeInValueSize = std::max(m_requiredRegisterFileSizeInValueSize, (size_t)context->m_baseRegisterCount);
@ -983,7 +981,7 @@ public:
{
char* pos = m_code.data();
pos = &pos[position];
return (CodeType *)pos;
return (CodeType*)pos;
}
template <typename CodeType>
@ -1002,7 +1000,6 @@ public:
ByteCodeBlockData m_code;
size_t m_requiredRegisterFileSizeInValueSize;
};
}
#endif

View file

@ -7,7 +7,7 @@ namespace Escargot {
void ByteCodeGenerateContext::consumeLabeledContinuePositions(ByteCodeBlock* cb, size_t position, String* lbl)
{
for (size_t i = 0; i < m_labeledContinueStatmentPositions.size(); i ++) {
for (size_t i = 0; i < m_labeledContinueStatmentPositions.size(); i++) {
if (*m_labeledContinueStatmentPositions[i].first == *lbl) {
Jump* shouldBeJump = cb->peekCode<Jump>(m_labeledContinueStatmentPositions[i].second);
ASSERT(shouldBeJump->m_orgOpcode == JumpOpcode);
@ -21,7 +21,7 @@ void ByteCodeGenerateContext::consumeLabeledContinuePositions(ByteCodeBlock* cb,
void ByteCodeGenerateContext::consumeBreakPositions(ByteCodeBlock* cb, size_t position)
{
for (size_t i = 0; i < m_breakStatementPositions.size(); i ++) {
for (size_t i = 0; i < m_breakStatementPositions.size(); i++) {
Jump* shouldBeJump = cb->peekCode<Jump>(m_breakStatementPositions[i]);
ASSERT(shouldBeJump->m_orgOpcode == JumpOpcode);
shouldBeJump->m_jumpPosition = position;
@ -33,7 +33,7 @@ void ByteCodeGenerateContext::consumeBreakPositions(ByteCodeBlock* cb, size_t po
void ByteCodeGenerateContext::consumeLabeledBreakPositions(ByteCodeBlock* cb, size_t position, String* lbl)
{
for (size_t i = 0; i < m_labeledBreakStatmentPositions.size(); i ++) {
for (size_t i = 0; i < m_labeledBreakStatmentPositions.size(); i++) {
if (*m_labeledBreakStatmentPositions[i].first == *lbl) {
Jump* shouldBeJump = cb->peekCode<Jump>(m_labeledBreakStatmentPositions[i].second);
ASSERT(shouldBeJump->m_orgOpcode == JumpOpcode);
@ -47,7 +47,7 @@ void ByteCodeGenerateContext::consumeLabeledBreakPositions(ByteCodeBlock* cb, si
void ByteCodeGenerateContext::consumeContinuePositions(ByteCodeBlock* cb, size_t position)
{
for (size_t i = 0; i < m_continueStatementPositions.size(); i ++) {
for (size_t i = 0; i < m_continueStatementPositions.size(); i++) {
Jump* shouldBeJump = cb->peekCode<Jump>(m_continueStatementPositions[i]);
ASSERT(shouldBeJump->m_orgOpcode == JumpOpcode);
shouldBeJump->m_jumpPosition = position;
@ -81,7 +81,7 @@ void ByteCodeGenerator::generateByteCode(Context* c, CodeBlock* codeBlock, Node*
// generate init function decls first
size_t len = codeBlock->childBlocks().size();
for (size_t i = 0; i < len; i ++) {
for (size_t i = 0; i < len; i++) {
CodeBlock* b = codeBlock->childBlocks()[i];
if (b->isFunctionDeclaration()) {
ctx.getRegister();
@ -107,10 +107,10 @@ void ByteCodeGenerator::generateByteCode(Context* c, CodeBlock* codeBlock, Node*
char* code = block->m_code.data();
char* end = &block->m_code.data()[block->m_code.size()];
while (&code[idx] < end) {
ByteCode* currentCode = (ByteCode *)(&code[idx]);
ByteCode* currentCode = (ByteCode*)(&code[idx]);
Opcode opcode = EndOpcode;
for (size_t i = 0; i < OpcodeKindEnd; i ++) {
for (size_t i = 0; i < OpcodeKindEnd; i++) {
if (g_opcodeTable.m_reverseTable[i].first == currentCode->m_opcodeInAddress) {
opcode = g_opcodeTable.m_reverseTable[i].second;
break;
@ -119,14 +119,14 @@ void ByteCodeGenerator::generateByteCode(Context* c, CodeBlock* codeBlock, Node*
switch (opcode) {
#define DUMP_BYTE_CODE(code, pushCount, popCount) \
case code##Opcode:\
currentCode->dumpCode(idx); \
idx += sizeof(code); \
continue;
case code##Opcode: \
currentCode->dumpCode(idx); \
idx += sizeof(code); \
continue;
FOR_EACH_BYTECODE_OP(DUMP_BYTE_CODE)
FOR_EACH_BYTECODE_OP(DUMP_BYTE_CODE)
#undef DUMP_BYTE_CODE
#undef DUMP_BYTE_CODE
default:
RELEASE_ASSERT_NOT_REACHED();
break;
@ -138,5 +138,4 @@ void ByteCodeGenerator::generateByteCode(Context* c, CodeBlock* codeBlock, Node*
codeBlock->m_byteCodeBlock = block;
}
}

View file

@ -1,9 +1,9 @@
#ifndef __EscargotByteCodeGenerator__
#define __EscargotByteCodeGenerator__
#include "runtime/Value.h"
#include "runtime/String.h"
#include "parser/CodeBlock.h"
#include "runtime/String.h"
#include "runtime/Value.h"
namespace Escargot {
@ -59,7 +59,6 @@ struct ByteCodeGenerateContext {
~ByteCodeGenerateContext()
{
}
void propagateInformationTo(ByteCodeGenerateContext& ctx)
@ -102,38 +101,37 @@ struct ByteCodeGenerateContext {
void registerJumpPositionsToComplexCase(size_t frontlimit)
{
ASSERT(m_tryStatementScopeCount);
for (unsigned i = 0 ; i < m_breakStatementPositions.size() ; i ++) {
if (m_breakStatementPositions[i] > (unsigned long) frontlimit) {
for (unsigned i = 0; i < m_breakStatementPositions.size(); i++) {
if (m_breakStatementPositions[i] > (unsigned long)frontlimit) {
if (m_complexCaseStatementPositions.find(m_breakStatementPositions[i]) == m_complexCaseStatementPositions.end()) {
m_complexCaseStatementPositions.insert(std::make_pair(m_breakStatementPositions[i], m_tryStatementScopeCount));
}
}
}
for (unsigned i = 0 ; i < m_continueStatementPositions.size() ; i ++) {
if (m_continueStatementPositions[i] > (unsigned long) frontlimit) {
for (unsigned i = 0; i < m_continueStatementPositions.size(); i++) {
if (m_continueStatementPositions[i] > (unsigned long)frontlimit) {
if (m_complexCaseStatementPositions.find(m_continueStatementPositions[i]) == m_complexCaseStatementPositions.end()) {
m_complexCaseStatementPositions.insert(std::make_pair(m_continueStatementPositions[i], m_tryStatementScopeCount));
}
}
}
for (unsigned i = 0 ; i < m_labeledBreakStatmentPositions.size() ; i ++) {
if (m_labeledBreakStatmentPositions[i].second > (unsigned long) frontlimit) {
for (unsigned i = 0; i < m_labeledBreakStatmentPositions.size(); i++) {
if (m_labeledBreakStatmentPositions[i].second > (unsigned long)frontlimit) {
if (m_complexCaseStatementPositions.find(m_labeledBreakStatmentPositions[i].second) == m_complexCaseStatementPositions.end()) {
m_complexCaseStatementPositions.insert(std::make_pair(m_labeledBreakStatmentPositions[i].second, m_tryStatementScopeCount));
}
}
}
for (unsigned i = 0 ; i < m_labeledContinueStatmentPositions.size() ; i ++) {
if (m_labeledContinueStatmentPositions[i].second > (unsigned long) frontlimit) {
for (unsigned i = 0; i < m_labeledContinueStatmentPositions.size(); i++) {
if (m_labeledContinueStatmentPositions[i].second > (unsigned long)frontlimit) {
if (m_complexCaseStatementPositions.find(m_labeledContinueStatmentPositions[i].second) == m_complexCaseStatementPositions.end()) {
m_complexCaseStatementPositions.insert(std::make_pair(m_labeledContinueStatmentPositions[i].second, m_tryStatementScopeCount));
}
}
}
}
size_t getLastRegisterIndex()
@ -188,6 +186,7 @@ struct ByteCodeGenerateContext {
class ByteCodeGenerator {
MAKE_STACK_ALLOCATED();
public:
ByteCodeGenerator()
{
@ -195,7 +194,6 @@ public:
void generateByteCode(Context* c, CodeBlock* codeBlock, Node* ast);
};
}
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,10 @@
#ifndef __EscargotByteCodeInterpreter__
#define __EscargotByteCodeInterpreter__
#include "runtime/Value.h"
#include "runtime/String.h"
#include "runtime/ExecutionState.h"
#include "parser/CodeBlock.h"
#include "runtime/ExecutionState.h"
#include "runtime/String.h"
#include "runtime/Value.h"
namespace Escargot {
@ -29,7 +29,6 @@ public:
static inline std::pair<bool, Value> getObjectPrecomputedCaseOperation(ExecutionState& state, const Value& willBeObject, const PropertyName& name, GetObjectInlineCache& inlineCache);
static inline void setObjectPreComputedCaseOperation(ExecutionState& state, const Value& willBeObject, const PropertyName& name, const Value& value, SetObjectInlineCache& inlineCache);
};
}
#endif

View file

@ -42,7 +42,7 @@ CodeBlock::CodeBlock(Context* ctx, const NativeFunctionInfo& info)
m_byteCodeBlock = new ByteCodeBlock();
CallNativeFunction code(info.m_nativeFunction);
code.assignOpcodeInAddress();
char* first = (char *)&code;
char* first = (char*)&code;
m_byteCodeBlock->m_code.insert(m_byteCodeBlock->m_code.end(), first, first + sizeof(CallNativeFunction));
}
@ -76,7 +76,7 @@ CodeBlock::CodeBlock(Context* ctx, Script* script, StringView src, bool isStrict
m_canAllocateEnvironmentOnStack = false;
m_needsComplexParameterCopy = false;
for (size_t i = 0; i < innerIdentifiers.size(); i ++) {
for (size_t i = 0; i < innerIdentifiers.size(); i++) {
IdentifierInfo info;
info.m_name = innerIdentifiers[i];
info.m_needToAllocateOnStack = false;
@ -86,7 +86,7 @@ CodeBlock::CodeBlock(Context* ctx, Script* script, StringView src, bool isStrict
}
CodeBlock::CodeBlock(Context* ctx, Script* script, StringView src, NodeLOC sourceElementStart, bool isStrict, size_t astNodeStartIndex, AtomicString functionName, const AtomicStringVector& parameterNames, const AtomicStringVector& innerIdentifiers,
CodeBlock* parentBlock, CodeBlockInitFlag initFlags)
CodeBlock* parentBlock, CodeBlockInitFlag initFlags)
: m_context(ctx)
, m_script(script)
, m_src(src)
@ -147,7 +147,7 @@ CodeBlock::CodeBlock(Context* ctx, Script* script, StringView src, NodeLOC sourc
m_canAllocateEnvironmentOnStack = false;
}
for (size_t i = 0; i < innerIdentifiers.size(); i ++) {
for (size_t i = 0; i < innerIdentifiers.size(); i++) {
IdentifierInfo info;
info.m_name = innerIdentifiers[i];
info.m_needToAllocateOnStack = m_canUseIndexedVariableStorage;
@ -160,7 +160,7 @@ CodeBlock::CodeBlock(Context* ctx, Script* script, StringView src, NodeLOC sourc
bool CodeBlock::tryCaptureIdentifiersFromChildCodeBlock(AtomicString name)
{
for (size_t i = 0; i < m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < m_identifierInfos.size(); i++) {
if (m_identifierInfos[i].m_name == name) {
m_canAllocateEnvironmentOnStack = false;
m_identifierInfos[i].m_needToAllocateOnStack = false;
@ -201,7 +201,7 @@ bool CodeBlock::hasNonConfiguableNameOnGlobal(const AtomicString& name)
void CodeBlock::computeVariables()
{
if (m_functionName.string()->length()) {
for (size_t i = 0; i < m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < m_identifierInfos.size(); i++) {
if (m_identifierInfos[i].m_name == m_functionName) {
m_functionNameIndex = i;
break;
@ -212,7 +212,7 @@ void CodeBlock::computeVariables()
if (canUseIndexedVariableStorage()) {
size_t s = 0;
size_t h = 0;
for (size_t i = 0; i < m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < m_identifierInfos.size(); i++) {
if (m_identifierInfos[i].m_name == m_functionName) {
m_functionNameSaveInfo.m_isAllocatedOnStack = m_identifierInfos[i].m_needToAllocateOnStack;
if (m_identifierInfos[i].m_needToAllocateOnStack) {
@ -238,7 +238,7 @@ void CodeBlock::computeVariables()
m_parametersInfomation.resizeWithUninitializedValues(siz);
size_t heapCount = 0;
size_t stackCount = 0;
for (size_t i = 0; i < siz; i ++) {
for (size_t i = 0; i < siz; i++) {
bool isHeap = !m_identifierInfos[i].m_needToAllocateOnStack;
m_parametersInfomation[i].m_isHeapAllocated = isHeap;
if (isHeap) {
@ -251,5 +251,4 @@ void CodeBlock::computeVariables()
}
}
}
}

View file

@ -1,10 +1,10 @@
#ifndef __EscargotCodeBlock__
#define __EscargotCodeBlock__
#include "runtime/String.h"
#include "runtime/AtomicString.h"
#include "parser/ast/Node.h"
#include "runtime/AtomicString.h"
#include "runtime/ExecutionState.h"
#include "runtime/String.h"
namespace Escargot {
@ -54,6 +54,7 @@ class CodeBlock : public gc {
friend class ScriptParser;
friend class ByteCodeGenerator;
friend class FunctionObject;
public:
// init native CodeBlock
CodeBlock(Context* ctx, const NativeFunctionInfo& info);
@ -119,7 +120,7 @@ public:
bool hasName(const AtomicString& name)
{
for (size_t i = 0; i < m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < m_identifierInfos.size(); i++) {
if (m_identifierInfos[i].m_name == name) {
return true;
}
@ -129,7 +130,7 @@ public:
size_t findName(const AtomicString& name)
{
for (size_t i = 0; i < m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < m_identifierInfos.size(); i++) {
if (m_identifierInfos[i].m_name == name) {
return i;
}
@ -320,7 +321,7 @@ protected:
size_t m_identifierOnStackCount;
size_t m_identifierOnHeapCount;
size_t m_functionNameIndex;
struct FunctionNameSaveInfo{
struct FunctionNameSaveInfo {
bool m_isAllocatedOnStack;
size_t m_index;
} m_functionNameSaveInfo;
@ -344,7 +345,6 @@ protected:
ASTScopeContext* m_scopeContext;
#endif
};
}
#endif

View file

@ -42,7 +42,7 @@ Script::ScriptExecuteResult Script::execute(Context* ctx)
result.result = sandBoxResult.result;
result.error.errorValue = sandBoxResult.error;
if (!sandBoxResult.error.isEmpty()) {
for (size_t i = 0; i < sandBoxResult.stackTraceData.size(); i ++) {
for (size_t i = 0; i < sandBoxResult.stackTraceData.size(); i++) {
ScriptExecuteResult::Error::StackTrace t;
t.fileName = sandBoxResult.stackTraceData[i].fileName;
t.line = sandBoxResult.stackTraceData[i].loc.line;
@ -52,5 +52,4 @@ Script::ScriptExecuteResult Script::execute(Context* ctx)
}
return result;
}
}

View file

@ -15,6 +15,7 @@ class Script : public gc {
, m_topCodeBlock(nullptr)
{
}
public:
struct ScriptExecuteResult {
MAKE_STACK_ALLOCATED();
@ -34,11 +35,11 @@ public:
{
return m_fileName;
}
protected:
String* m_fileName;
CodeBlock* m_topCodeBlock;
};
}
#endif

View file

@ -21,16 +21,10 @@ CodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context* ctx, String
codeBlock = new CodeBlock(ctx, script, source, scopeCtx->m_isStrict, scopeCtx->m_locStart, scopeCtx->m_names);
} else {
codeBlock = new CodeBlock(ctx, script, StringView(source, scopeCtx->m_locStart.index, scopeCtx->m_locEnd.index),
scopeCtx->m_locStart,
scopeCtx->m_isStrict, scopeCtx->m_nodeStartIndex,
scopeCtx->m_functionName, scopeCtx->m_parameters, scopeCtx->m_names, parentCodeBlock,
(CodeBlock::CodeBlockInitFlag)
((scopeCtx->m_hasEval ? CodeBlock::CodeBlockHasEval : 0) |
(scopeCtx->m_hasWith ? CodeBlock::CodeBlockHasWith : 0) |
(scopeCtx->m_hasYield ? CodeBlock::CodeBlockHasYield : 0) |
(scopeCtx->m_associateNode->type() == FunctionExpression ? CodeBlock::CodeBlockIsFunctionExpression : 0) |
(scopeCtx->m_associateNode->type() == FunctionDeclaration ? CodeBlock::CodeBlockIsFunctionDeclaration : 0)
));
scopeCtx->m_locStart,
scopeCtx->m_isStrict, scopeCtx->m_nodeStartIndex,
scopeCtx->m_functionName, scopeCtx->m_parameters, scopeCtx->m_names, parentCodeBlock,
(CodeBlock::CodeBlockInitFlag)((scopeCtx->m_hasEval ? CodeBlock::CodeBlockHasEval : 0) | (scopeCtx->m_hasWith ? CodeBlock::CodeBlockHasWith : 0) | (scopeCtx->m_hasYield ? CodeBlock::CodeBlockHasYield : 0) | (scopeCtx->m_associateNode->type() == FunctionExpression ? CodeBlock::CodeBlockIsFunctionExpression : 0) | (scopeCtx->m_associateNode->type() == FunctionDeclaration ? CodeBlock::CodeBlockIsFunctionDeclaration : 0)));
}
#ifndef NDEBUG
@ -48,7 +42,7 @@ CodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context* ctx, String
}
}
for (size_t i = 0; i < scopeCtx->m_usingNames.size(); i ++) {
for (size_t i = 0; i < scopeCtx->m_usingNames.size(); i++) {
AtomicString uname = scopeCtx->m_usingNames[i];
if (!codeBlock->hasName(uname)) {
CodeBlock* c = codeBlock->parentCodeBlock();
@ -61,7 +55,7 @@ CodeBlock* ScriptParser::generateCodeBlockTreeFromASTWalker(Context* ctx, String
}
}
for (size_t i = 0 ; i < scopeCtx->m_childScopes.size(); i ++) {
for (size_t i = 0; i < scopeCtx->m_childScopes.size(); i++) {
codeBlock->appendChildBlock(generateCodeBlockTreeFromASTWalker(ctx, source, script, scopeCtx->m_childScopes[i], codeBlock));
}
@ -90,40 +84,42 @@ ScriptParser::ScriptParserResult ScriptParser::parse(StringView scriptSource, St
topCodeBlock->m_cachedASTNode = program;
script->m_topCodeBlock = topCodeBlock;
// dump Code Block
// dump Code Block
#ifndef NDEBUG
if (getenv("DUMP_CODEBLOCK_TREE") && strlen(getenv("DUMP_CODEBLOCK_TREE"))) {
std::function<void(CodeBlock*, size_t depth)> fn = [&](CodeBlock* cb, size_t depth) {
std::function<void (CodeBlock*, size_t depth)> fn = [&](CodeBlock* cb, size_t depth) {
#define PRINT_TAB() for (size_t i = 0; i < depth; i ++) { printf(" "); }
#define PRINT_TAB() \
for (size_t i = 0; i < depth; i++) { \
printf(" "); \
}
PRINT_TAB()
printf("CodeBlock %s (%d:%d -> %d:%d)(%s, %s) (E:%d, W:%d, Y:%d)\n", cb->m_functionName.string()->toUTF8StringData().data(),
(int)cb->m_locStart.line,
(int)cb->m_locStart.column,
(int)cb->m_locEnd.line,
(int)cb->m_locEnd.column,
cb->m_canAllocateEnvironmentOnStack ? "Stack" : "Heap",
cb->m_canUseIndexedVariableStorage ? "Indexed" : "Named",
(int)cb->m_hasEval, (int)cb->m_hasWith, (int)cb->m_hasYield);
(int)cb->m_locStart.line,
(int)cb->m_locStart.column,
(int)cb->m_locEnd.line,
(int)cb->m_locEnd.column,
cb->m_canAllocateEnvironmentOnStack ? "Stack" : "Heap",
cb->m_canUseIndexedVariableStorage ? "Indexed" : "Named",
(int)cb->m_hasEval, (int)cb->m_hasWith, (int)cb->m_hasYield);
PRINT_TAB()
printf("Names: ");
for (size_t i = 0; i < cb->m_identifierInfos.size(); i ++) {
for (size_t i = 0; i < cb->m_identifierInfos.size(); i++) {
printf("%s(%s, %d), ", cb->m_identifierInfos[i].m_name.string()->toUTF8StringData().data(),
cb->m_identifierInfos[i].m_needToAllocateOnStack ? "Stack" : "Heap", (int)cb->m_identifierInfos[i].m_indexForIndexedStorage);
cb->m_identifierInfos[i].m_needToAllocateOnStack ? "Stack" : "Heap", (int)cb->m_identifierInfos[i].m_indexForIndexedStorage);
}
puts("");
PRINT_TAB()
printf("Using Names: ");
for (size_t i = 0; i < cb->m_scopeContext->m_usingNames.size(); i ++) {
for (size_t i = 0; i < cb->m_scopeContext->m_usingNames.size(); i++) {
printf("%s, ", cb->m_scopeContext->m_usingNames[i].string()->toUTF8StringData().data());
}
puts("");
for (size_t i = 0; i < cb->m_childBlocks.size(); i ++) {
for (size_t i = 0; i < cb->m_childBlocks.size(); i++) {
fn(cb->m_childBlocks[i], depth + 1);
}
@ -132,7 +128,7 @@ ScriptParser::ScriptParserResult ScriptParser::parse(StringView scriptSource, St
}
#endif
} catch(esprima::Error* orgError) {
} catch (esprima::Error* orgError) {
script = nullptr;
error = new ScriptParseError();
error->column = orgError->column;
@ -152,10 +148,9 @@ Node* ScriptParser::parseFunction(CodeBlock* codeBlock)
try {
Node* body = esprima::parseSingleFunction(m_context, codeBlock);
return body;
} catch(esprima::Error* orgError) {
} catch (esprima::Error* orgError) {
//
RELEASE_ASSERT_NOT_REACHED();
}
}
}

View file

@ -1,8 +1,8 @@
#ifndef __EscargotScriptParser__
#define __EscargotScriptParser__
#include "runtime/String.h"
#include "parser/Script.h"
#include "runtime/String.h"
namespace Escargot {
@ -49,7 +49,6 @@ protected:
Context* m_context;
};
}
#endif

View file

@ -18,7 +18,6 @@
#define AST_h
#include "ArrayExpressionNode.h"
#include "AssignmentExpressionSimpleNode.h"
#include "AssignmentExpressionBitwiseAndNode.h"
#include "AssignmentExpressionBitwiseOrNode.h"
#include "AssignmentExpressionBitwiseXorNode.h"
@ -29,8 +28,8 @@
#include "AssignmentExpressionMultiplyNode.h"
#include "AssignmentExpressionPlusNode.h"
#include "AssignmentExpressionSignedRightShiftNode.h"
#include "AssignmentExpressionSimpleNode.h"
#include "AssignmentExpressionUnsignedRightShiftNode.h"
#include "Node.h"
#include "BinaryExpressionBitwiseAndNode.h"
#include "BinaryExpressionBitwiseOrNode.h"
#include "BinaryExpressionBitwiseXorNode.h"
@ -54,49 +53,47 @@
#include "BinaryExpressionSignedRightShiftNode.h"
#include "BinaryExpressionStrictEqualNode.h"
#include "BinaryExpressionUnsignedRightShiftNode.h"
#include "UpdateExpressionDecrementPostfixNode.h"
#include "UpdateExpressionDecrementPrefixNode.h"
#include "UpdateExpressionIncrementPostfixNode.h"
#include "UpdateExpressionIncrementPrefixNode.h"
#include "BlockStatementNode.h"
#include "BreakStatementNode.h"
#include "BreakLabelStatementNode.h"
#include "BreakStatementNode.h"
#include "CallExpressionNode.h"
#include "CatchClauseNode.h"
#include "ConditionalExpressionNode.h"
#include "ContinueStatementNode.h"
#include "ContinueLabelStatementNode.h"
#include "ContinueStatementNode.h"
#include "DirectiveNode.h"
#include "DoWhileStatementNode.h"
#include "EmptyNode.h"
#include "EmptyStatementNode.h"
#include "ExpressionNode.h"
#include "SequenceExpressionNode.h"
#include "ExpressionStatementNode.h"
#include "ForInStatementNode.h"
#include "ForStatementNode.h"
#include "FunctionDeclarationNode.h"
#include "FunctionExpressionNode.h"
#include "FunctionNode.h"
#include "IdentifierNode.h"
#include "IfStatementNode.h"
#include "ForInStatementNode.h"
#include "ForStatementNode.h"
#include "WhileStatementNode.h"
#include "DoWhileStatementNode.h"
#include "LabeledStatementNode.h"
#include "LiteralNode.h"
#include "DirectiveNode.h"
#include "RegExpLiteralNode.h"
#include "RestElementNode.h"
#include "MemberExpressionNode.h"
#include "NewExpressionNode.h"
#include "Node.h"
#include "Node.h"
#include "ObjectExpressionNode.h"
#include "PatternNode.h"
#include "ProgramNode.h"
#include "RegExpLiteralNode.h"
#include "RestElementNode.h"
#include "ReturnStatmentNode.h"
#include "StatementNode.h"
#include "SequenceExpressionNode.h"
#include "SpreadElementNode.h"
#include "SwitchStatementNode.h"
#include "StatementNode.h"
#include "SwitchCaseNode.h"
#include "SwitchStatementNode.h"
#include "ThisExpressionNode.h"
#include "ThrowStatementNode.h"
#include "TryStatementNode.h"
#include "UnaryExpressionBitwiseNotNode.h"
#include "UnaryExpressionDeleteNode.h"
#include "UnaryExpressionLogicalNotNode.h"
@ -104,9 +101,12 @@
#include "UnaryExpressionPlusNode.h"
#include "UnaryExpressionTypeOfNode.h"
#include "UnaryExpressionVoidNode.h"
#include "UpdateExpressionDecrementPostfixNode.h"
#include "UpdateExpressionDecrementPrefixNode.h"
#include "UpdateExpressionIncrementPostfixNode.h"
#include "UpdateExpressionIncrementPrefixNode.h"
#include "VariableDeclarationNode.h"
#include "VariableDeclaratorNode.h"
#include "TryStatementNode.h"
#include "ThrowStatementNode.h"
#include "WhileStatementNode.h"
#endif

View file

@ -34,7 +34,6 @@ public:
protected:
ExpressionNodeVector m_elements;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionBitwiseAndNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryBitwiseAnd(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionBitwiseOrNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryBitwiseOr(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionBitwiseXorNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryBitwiseXor(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionDivisionNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryDivision(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionLeftShiftNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryLeftShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionMinusNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryMinus(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionModNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryMod(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionMultiplyNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -51,7 +51,6 @@ protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionPlusNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinaryPlus(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionSignedRightShiftNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -46,11 +46,11 @@ public:
codeBlock->pushCode(BinarySignedRightShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionSimpleNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
// #include "MemberExpressionNode.h"
namespace Escargot {
@ -42,7 +42,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::AssignmentExpressionSimple; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_right->generateExpressionByteCode(codeBlock, context);
@ -53,7 +52,6 @@ protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -18,8 +18,8 @@
#define AssignmentExpressionUnsignedRightShiftNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "IdentifierNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -45,11 +45,11 @@ public:
codeBlock->pushCode(BinaryUnsignedRightShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
m_left->generateStoreByteCode(codeBlock, context);
}
protected:
Node* m_left; // left: Pattern;
Node* m_right; // right: Expression;
};
}
#endif

View file

@ -21,11 +21,11 @@
namespace Escargot {
class BinaryExpressionBitwiseAndNode: public ExpressionNode {
class BinaryExpressionBitwiseAndNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionBitwiseAndNode(Node *left, Node* right)
BinaryExpressionBitwiseAndNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryBitwiseAnd(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -21,11 +21,11 @@
namespace Escargot {
class BinaryExpressionBitwiseOrNode: public ExpressionNode {
class BinaryExpressionBitwiseOrNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionBitwiseOrNode(Node *left, Node* right)
BinaryExpressionBitwiseOrNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryBitwiseOr(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -21,11 +21,11 @@
namespace Escargot {
class BinaryExpressionBitwiseXorNode: public ExpressionNode {
class BinaryExpressionBitwiseXorNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionBitwiseXorNode(Node *left, Node* right)
BinaryExpressionBitwiseXorNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryBitwiseXor(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionDivisionNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionDivisionNode(Node *left, Node* right)
BinaryExpressionDivisionNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -33,7 +33,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionDivison; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -45,11 +44,11 @@ public:
codeBlock->pushCode(BinaryDivision(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionEqualNode(Node *left, Node* right)
BinaryExpressionEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -33,7 +33,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionEqual; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -45,11 +44,11 @@ public:
codeBlock->pushCode(BinaryEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionGreaterThanNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionGreaterThanNode(Node *left, Node* right)
BinaryExpressionGreaterThanNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryGreaterThan(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionGreaterThanOrEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionGreaterThanOrEqualNode(Node *left, Node* right)
BinaryExpressionGreaterThanOrEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryGreaterThanOrEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionInNode : public ExpressionNode {
public:
BinaryExpressionInNode(Node *left, Node* right)
BinaryExpressionInNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,12 +31,10 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionIn; }
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionInstanceOfNode : public ExpressionNode {
public:
BinaryExpressionInstanceOfNode(Node *left, Node* right)
BinaryExpressionInstanceOfNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,12 +31,10 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionInstanceOf; }
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionLeftShiftNode : public ExpressionNode {
public:
BinaryExpressionLeftShiftNode(Node *left, Node* right)
BinaryExpressionLeftShiftNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -42,11 +42,11 @@ public:
codeBlock->pushCode(BinaryLeftShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionLessThanNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionLessThanNode(Node *left, Node* right)
BinaryExpressionLessThanNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryLessThan(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionLessThanOrEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionLessThanOrEqualNode(Node *left, Node* right)
BinaryExpressionLessThanOrEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryLessThanOrEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionLogicalAndNode : public ExpressionNode {
public:
BinaryExpressionLogicalAndNode(Node *left, Node* right)
BinaryExpressionLogicalAndNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionLogicalAnd; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -42,11 +41,11 @@ public:
m_right->generateExpressionByteCode(codeBlock, context);
codeBlock->peekCode<JumpIfFalse>(pos)->m_jumpPosition = codeBlock->currentCodeSize();
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionLogicalOrNode : public ExpressionNode {
public:
BinaryExpressionLogicalOrNode(Node *left, Node* right)
BinaryExpressionLogicalOrNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionLogicalOr; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -41,11 +40,11 @@ public:
m_right->generateExpressionByteCode(codeBlock, context);
codeBlock->peekCode<JumpIfTrue>(pos)->m_jumpPosition = codeBlock->currentCodeSize();
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionMinusNode : public ExpressionNode {
public:
BinaryExpressionMinusNode(Node *left, Node* right)
BinaryExpressionMinusNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionMinus; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -43,11 +42,11 @@ public:
codeBlock->pushCode(BinaryMinus(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionModNode : public ExpressionNode {
public:
BinaryExpressionModNode(Node *left, Node* right)
BinaryExpressionModNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -42,11 +42,11 @@ public:
codeBlock->pushCode(BinaryMod(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionMultiplyNode : public ExpressionNode {
public:
BinaryExpressionMultiplyNode(Node *left, Node* right)
BinaryExpressionMultiplyNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionMultiply; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -43,11 +42,11 @@ public:
codeBlock->pushCode(BinaryMultiply(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionNotEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionNotEqualNode(Node *left, Node* right)
BinaryExpressionNotEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryNotEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionNotStrictEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionNotStrictEqualNode(Node *left, Node* right)
BinaryExpressionNotStrictEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryNotStrictEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionPlusNode : public ExpressionNode {
public:
BinaryExpressionPlusNode(Node *left, Node* right)
BinaryExpressionPlusNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BinaryExpressionPlus; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_left->generateExpressionByteCode(codeBlock, context);
@ -43,11 +42,11 @@ public:
codeBlock->pushCode(BinaryPlus(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionSignedRightShiftNode : public ExpressionNode {
public:
BinaryExpressionSignedRightShiftNode(Node *left, Node* right)
BinaryExpressionSignedRightShiftNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -42,11 +42,11 @@ public:
codeBlock->pushCode(BinarySignedRightShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -25,7 +25,7 @@ class BinaryExpressionStrictEqualNode : public ExpressionNode {
public:
friend class ScriptParser;
BinaryExpressionStrictEqualNode(Node *left, Node* right)
BinaryExpressionStrictEqualNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -44,11 +44,11 @@ public:
codeBlock->pushCode(BinaryStrictEqual(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -23,7 +23,7 @@ namespace Escargot {
class BinaryExpressionUnsignedRightShiftNode : public ExpressionNode {
public:
BinaryExpressionUnsignedRightShiftNode(Node *left, Node* right)
BinaryExpressionUnsignedRightShiftNode(Node* left, Node* right)
: ExpressionNode()
{
m_left = (ExpressionNode*)left;
@ -42,11 +42,11 @@ public:
codeBlock->pushCode(BinaryUnsignedRightShift(ByteCodeLOC(m_loc.index), src0, src1), context, this);
}
protected:
ExpressionNode* m_left;
ExpressionNode* m_right;
};
}
#endif

View file

@ -33,11 +33,10 @@ public:
virtual ASTNodeType type() { return ASTNodeType::BlockStatement; }
size_t size() { return m_body.size(); }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
size_t len = m_body.size();
for (size_t i = 0; i < len; i ++) {
for (size_t i = 0; i < len; i++) {
m_body[i]->generateStatementByteCode(codeBlock, context);
}
}
@ -45,8 +44,6 @@ public:
protected:
StatementNodeVector m_body; // body: [ Statement ];
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BreakLabelStatement; }
protected:
String* m_label;
};
}
#endif

View file

@ -30,9 +30,7 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::BreakStatement; }
};
}
#endif

View file

@ -18,8 +18,8 @@
#define CallExpressionNode_h
#include "ExpressionNode.h"
#include "PatternNode.h"
#include "MemberExpressionNode.h"
#include "PatternNode.h"
namespace Escargot {
@ -35,7 +35,6 @@ public:
Node* callee() { return m_callee; }
virtual ASTNodeType type() { return ASTNodeType::CallExpression; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
if (m_callee->isIdentifier() && m_callee->asIdentifier()->name().string()->equals("eval")) {
@ -56,10 +55,10 @@ public:
size_t baseRegister = context->getLastRegisterIndex() - 1;
context->m_inCallingExpressionScope = false;
for (size_t i = 0; i < m_arguments.size(); i ++) {
for (size_t i = 0; i < m_arguments.size(); i++) {
m_arguments[i]->generateExpressionByteCode(codeBlock, context);
}
for (size_t i = 0; i < m_arguments.size(); i ++) {
for (size_t i = 0; i < m_arguments.size(); i++) {
context->giveUpRegister();
}
@ -74,7 +73,6 @@ protected:
Node* m_callee; // callee: Expression;
ArgumentVector m_arguments; // arguments: [ Expression ];
};
}
#endif

View file

@ -17,10 +17,10 @@
#ifndef CatchClauseNode_h
#define CatchClauseNode_h
#include "Node.h"
#include "BlockStatementNode.h"
#include "ExpressionNode.h"
#include "IdentifierNode.h"
#include "BlockStatementNode.h"
#include "Node.h"
namespace Escargot {
@ -31,21 +31,19 @@ public:
CatchClauseNode(Node *param, Node *guard, Node *body)
: Node()
{
m_param = (IdentifierNode*) param;
m_guard = (ExpressionNode*) guard;
m_body = (BlockStatementNode*) body;
m_param = (IdentifierNode *)param;
m_guard = (ExpressionNode *)guard;
m_body = (BlockStatementNode *)body;
}
virtual ASTNodeType type() { return ASTNodeType::CatchClause; }
protected:
IdentifierNode* m_param;
ExpressionNode* m_guard;
BlockStatementNode* m_body;
IdentifierNode *m_param;
ExpressionNode *m_guard;
BlockStatementNode *m_body;
};
typedef Vector<Node *, gc_malloc_ignore_off_page_allocator<Node *>> CatchClauseNodeVector;
}
#endif

View file

@ -24,22 +24,20 @@ namespace Escargot {
class ConditionalExpressionNode : public ExpressionNode {
public:
friend class ScriptParser;
ConditionalExpressionNode(Node *test, Node *consequente, Node *alternate)
ConditionalExpressionNode(Node* test, Node* consequente, Node* alternate)
: ExpressionNode()
{
m_test = (ExpressionNode*) test;
m_consequente = (ExpressionNode*) consequente;
m_alternate = (ExpressionNode*) alternate;
m_test = (ExpressionNode*)test;
m_consequente = (ExpressionNode*)consequente;
m_alternate = (ExpressionNode*)alternate;
}
virtual ASTNodeType type() { return ASTNodeType::ConditionalExpression; }
protected:
ExpressionNode* m_test;
ExpressionNode* m_consequente;
ExpressionNode* m_alternate;
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::ContinueLabelStatement; }
protected:
String* m_label;
};
}
#endif

View file

@ -30,9 +30,7 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::ContinueStatement; }
};
}
#endif

View file

@ -28,9 +28,9 @@ public:
: StatementNode()
{
}
protected:
};
}

View file

@ -17,8 +17,8 @@
#ifndef DirectiveNode_h
#define DirectiveNode_h
#include "Node.h"
#include "ExpressionNode.h"
#include "Node.h"
namespace Escargot {
@ -37,7 +37,6 @@ protected:
ExpressionNode* m_expr;
StringView m_value;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef DoWhileStatementNode_h
#define DoWhileStatementNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
namespace Escargot {
@ -28,17 +28,15 @@ public:
DoWhileStatementNode(Node *test, Node *body)
: StatementNode()
{
m_test = (ExpressionNode*) test;
m_body = (StatementNode*) body;
m_test = (ExpressionNode *)test;
m_body = (StatementNode *)body;
}
virtual ASTNodeType type() { return ASTNodeType::DoWhileStatement; }
protected:
ExpressionNode *m_test;
StatementNode *m_body;
};
}
#endif

View file

@ -29,10 +29,8 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::Empty; }
protected:
};
}
#endif

View file

@ -30,10 +30,8 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::EmptyStatement; }
protected:
};
}
#endif

View file

@ -35,9 +35,9 @@ public:
{
return true;
}
protected:
};
}
#endif

View file

@ -32,9 +32,7 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::ExpressionStatement; }
Node* expression() { return m_expression; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
#ifndef NDEBUG
@ -45,10 +43,10 @@ public:
context->giveUpRegister();
ASSERT(context->m_baseRegisterCount == before);
}
protected:
Node* m_expression; // expression: Expression;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef ForInStatementNode_h
#define ForInStatementNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
namespace Escargot {
@ -28,21 +28,19 @@ public:
ForInStatementNode(Node *left, Node *right, Node *body, bool each)
: StatementNode()
{
m_left = (ExpressionNode*) left;
m_right = (ExpressionNode*) right;
m_body = (StatementNode*) body;
m_left = (ExpressionNode *)left;
m_right = (ExpressionNode *)right;
m_body = (StatementNode *)body;
m_each = each;
}
virtual ASTNodeType type() { return ASTNodeType::ForInStatement; }
protected:
ExpressionNode *m_left;
ExpressionNode *m_right;
StatementNode *m_body;
bool m_each;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef ForStatementNode_h
#define ForStatementNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
namespace Escargot {
@ -28,14 +28,14 @@ public:
ForStatementNode(Node *init, Node *test, Node *update, Node *body)
: StatementNode()
{
m_init = (ExpressionNode*) init;
m_test = (ExpressionNode*) test;
m_update = (ExpressionNode*) update;
m_body = (StatementNode*) body;
m_init = (ExpressionNode *)init;
m_test = (ExpressionNode *)test;
m_update = (ExpressionNode *)update;
m_body = (StatementNode *)body;
}
virtual ASTNodeType type() { return ASTNodeType::ForStatement; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
virtual void generateStatementByteCode(ByteCodeBlock *codeBlock, ByteCodeGenerateContext *context)
{
ByteCodeGenerateContext newContext(*context);
@ -71,13 +71,13 @@ public:
newContext.m_positionToContinue = updatePosition;
newContext.propagateInformationTo(*context);
}
protected:
ExpressionNode *m_init;
ExpressionNode *m_test;
ExpressionNode *m_update;
StatementNode *m_body;
};
}
#endif

View file

@ -30,7 +30,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::FunctionDeclaration; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
// do nothing
@ -39,7 +38,6 @@ public:
protected:
FunctionNode m_function;
};
}
#endif

View file

@ -33,7 +33,7 @@ public:
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
CodeBlock* blk = nullptr;
for (size_t i = 0; i < context->m_codeBlock->childBlocks().size(); i ++) {
for (size_t i = 0; i < context->m_codeBlock->childBlocks().size(); i++) {
CodeBlock* c = context->m_codeBlock->childBlocks()[i];
if (c->isFunctionExpression() && c->astNodeStartIndex() == m_loc.index) {
blk = c;
@ -43,12 +43,12 @@ public:
ASSERT(blk);
codeBlock->pushCode(DeclareFunctionExpression(ByteCodeLOC(m_loc.index), context->getRegister(), blk), context, this);
}
protected:
FunctionNode m_function;
// defaults: [ Expression ];
// rest: Identifier | null;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef FunctionNode_h
#define FunctionNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
namespace Escargot {
@ -38,7 +38,6 @@ public:
inline Node* body() { return m_body; }
inline const AtomicString& id() { return m_id; }
ASTScopeContext* scopeContext() { return m_scopeContext; }
protected:
bool m_isGenerator;
AtomicString m_id; // id: Identifier;
@ -46,7 +45,6 @@ protected:
Node* m_body;
ASTScopeContext* m_scopeContext;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef IdentifierNode_h
#define IdentifierNode_h
#include "Node.h"
#include "ExpressionNode.h"
#include "Node.h"
#include "PatternNode.h"
namespace Escargot {
@ -34,7 +34,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::Identifier; }
AtomicString name()
{
return m_name;
@ -83,10 +82,10 @@ public:
}
}
}
protected:
AtomicString m_name;
};
}
#endif

View file

@ -24,16 +24,15 @@ namespace Escargot {
class IfStatementNode : public StatementNode {
public:
friend class ScriptParser;
IfStatementNode(Node *test, Node *consequente, Node *alternate)
IfStatementNode(Node* test, Node* consequente, Node* alternate)
: StatementNode()
{
m_test = (ExpressionNode*) test;
m_consequente = (StatementNode*) consequente;
m_alternate = (StatementNode*) alternate;
m_test = (ExpressionNode*)test;
m_consequente = (StatementNode*)consequente;
m_alternate = (StatementNode*)alternate;
}
virtual ASTNodeType type() { return ASTNodeType::IfStatement; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
if (!m_alternate) {
@ -69,11 +68,10 @@ public:
}
protected:
ExpressionNode *m_test;
StatementNode *m_consequente;
StatementNode *m_alternate;
ExpressionNode* m_test;
StatementNode* m_consequente;
StatementNode* m_alternate;
};
}
#endif

View file

@ -32,12 +32,10 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::LabeledStatement; }
protected:
StatementNode* m_statementNode;
String* m_label;
};
}
#endif

View file

@ -31,17 +31,15 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::Literal; }
const Value& value() { return m_value; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
codeBlock->pushCode(LoadLiteral(ByteCodeLOC(m_loc.index), context->getRegister(), m_value), context, this);
}
protected:
Value m_value;
};
}
#endif

View file

@ -34,7 +34,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::MemberExpression; }
bool isPreComputedCase()
{
return m_computed;
@ -43,7 +42,7 @@ public:
AtomicString propertyName()
{
ASSERT(isPreComputedCase());
return ((IdentifierNode *)m_property)->name();
return ((IdentifierNode*)m_property)->name();
}
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
@ -100,7 +99,6 @@ protected:
bool m_computed;
};
}
#endif

View file

@ -37,21 +37,21 @@ public:
m_callee->generateExpressionByteCode(codeBlock, context);
size_t base = context->getLastRegisterIndex();
for (size_t i = 0; i < m_arguments.size(); i ++) {
for (size_t i = 0; i < m_arguments.size(); i++) {
m_arguments[i]->generateExpressionByteCode(codeBlock, context);
}
codeBlock->pushCode(NewOperation(ByteCodeLOC(m_loc.index), base, m_arguments.size()), context, this);
for (size_t i = 0; i < m_arguments.size(); i ++) {
for (size_t i = 0; i < m_arguments.size(); i++) {
context->giveUpRegister();
}
}
protected:
Node* m_callee;
ArgumentVector m_arguments;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef Node_h
#define Node_h
#include "runtime/Value.h"
#include "runtime/AtomicString.h"
#include "runtime/Value.h"
namespace Escargot {
@ -144,15 +144,16 @@ class IdentifierNode;
class Node : public gc {
friend class ScriptParser;
protected:
Node()
: m_loc(SIZE_MAX, SIZE_MAX, SIZE_MAX)
{
}
public:
virtual ~Node()
{
}
virtual ASTNodeType type() = 0;
@ -162,10 +163,10 @@ public:
return type() == ASTNodeType::Identifier;
}
IdentifierNode* asIdentifier()
IdentifierNode *asIdentifier()
{
ASSERT(isIdentifier());
return (IdentifierNode*)this;
return (IdentifierNode *)this;
}
bool isLiteral()
@ -193,17 +194,17 @@ public:
return m_loc;
}
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
virtual void generateStatementByteCode(ByteCodeBlock *codeBlock, ByteCodeGenerateContext *context)
{
RELEASE_ASSERT_NOT_REACHED();
}
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
virtual void generateExpressionByteCode(ByteCodeBlock *codeBlock, ByteCodeGenerateContext *context)
{
RELEASE_ASSERT_NOT_REACHED();
}
virtual void generateStoreByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
virtual void generateStoreByteCode(ByteCodeBlock *codeBlock, ByteCodeGenerateContext *context)
{
RELEASE_ASSERT_NOT_REACHED();
// TODO
@ -215,7 +216,6 @@ public:
class Pattern {
public:
};
struct ASTScopeContext : public gc {
@ -223,13 +223,13 @@ struct ASTScopeContext : public gc {
bool m_hasEval;
bool m_hasWith;
bool m_hasYield;
ASTScopeContext* m_parentContext;
Node* m_associateNode;
ASTScopeContext *m_parentContext;
Node *m_associateNode;
AtomicStringVector m_names;
AtomicStringVector m_usingNames;
AtomicStringVector m_parameters;
AtomicString m_functionName;
Vector<ASTScopeContext*, gc_malloc_ignore_off_page_allocator<ASTScopeContext*>> m_childScopes;
Vector<ASTScopeContext *, gc_malloc_ignore_off_page_allocator<ASTScopeContext *>> m_childScopes;
NodeLOC m_locStart;
NodeLOC m_locEnd;
size_t m_nodeStartIndex;
@ -248,7 +248,7 @@ struct ASTScopeContext : public gc {
}
}
ASTScopeContext(bool isStrict, ASTScopeContext* parentContext)
ASTScopeContext(bool isStrict, ASTScopeContext *parentContext)
: m_locStart(SIZE_MAX, SIZE_MAX, SIZE_MAX)
, m_locEnd(SIZE_MAX, SIZE_MAX, SIZE_MAX)
, m_nodeStartIndex(SIZE_MAX)

View file

@ -33,12 +33,11 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::ObjectExpression; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
codeBlock->pushCode(CreateObject(ByteCodeLOC(m_loc.index), context->getRegister()), context, this);
size_t objIndex = context->getLastRegisterIndex();
for (unsigned i = 0; i < m_properties.size() ; i ++) {
for (unsigned i = 0; i < m_properties.size(); i++) {
PropertyNode* p = m_properties[i];
AtomicString propertyAtomicName;
if (p->key()->isIdentifier()) {
@ -73,10 +72,10 @@ public:
}
ASSERT(objIndex == context->getLastRegisterIndex());
}
protected:
PropertiesNodeVector m_properties;
};
}
#endif

View file

@ -27,9 +27,9 @@ public:
: Node()
{
}
protected:
};
}
#endif

View file

@ -35,20 +35,19 @@ public:
virtual ASTNodeType type() { return ASTNodeType::Program; }
ASTScopeContext* scopeContext() { return m_scopeContext; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
size_t len = m_body.size();
for (size_t i = 0; i < len; i ++) {
for (size_t i = 0; i < len; i++) {
m_body[i]->generateStatementByteCode(codeBlock, context);
}
}
protected:
StatementNodeVector m_body; // body: [ Statement ];
ASTScopeContext* m_scopeContext;
};
}
#endif

View file

@ -26,7 +26,9 @@ class PropertyNode : public Node {
public:
friend class ScriptParser;
enum Kind {
Init, Get, Set
Init,
Get,
Set
};
PropertyNode(Node* key, Node* value, Kind kind)
@ -38,7 +40,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::Property; }
Node* key()
{
return m_key;
@ -64,7 +65,6 @@ protected:
Node* m_key; // key: Literal | Identifier;
Node* m_value; // value: Expression;
};
}
#endif

View file

@ -41,7 +41,6 @@ protected:
Escargot::ESRegExpObject::Option m_flag;
};
*/
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef RestElementNode_h
#define RestElementNode_h
#include "Node.h"
#include "IdentifierNode.h"
#include "Node.h"
namespace Escargot {
@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::RestElement; }
IdentifierNode* argument()
{
return m_argument;
@ -40,7 +39,6 @@ public:
protected:
IdentifierNode* m_argument;
};
}
#endif

View file

@ -31,7 +31,6 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::ReturnStatement; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
if (m_argument) {
@ -42,10 +41,10 @@ public:
codeBlock->pushCode(ReturnFunction(ByteCodeLOC(m_loc.index), SIZE_MAX), context, this);
}
}
protected:
Node* m_argument;
};
}
#endif

View file

@ -32,13 +32,10 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::SequenceExpression; }
const ExpressionNodeVector& expressions() { return m_expressions; }
protected:
ExpressionNodeVector m_expressions; // expression: Expression;
};
}
#endif

View file

@ -33,10 +33,10 @@ public:
{
return SpreadElement;
}
protected:
Node* m_arg;
};
}
#endif

View file

@ -35,7 +35,6 @@ public:
protected:
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef SwitchCaseNode_h
#define SwitchCaseNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
namespace Escargot {
@ -29,12 +29,11 @@ public:
SwitchCaseNode(Node* test, StatementNodeVector&& consequent)
: StatementNode()
{
m_test = (ExpressionNode*) test;
m_test = (ExpressionNode*)test;
m_consequent = consequent;
}
virtual ASTNodeType type() { return ASTNodeType::SwitchCase; }
bool isDefaultNode()
{
return !m_test;
@ -44,7 +43,6 @@ protected:
ExpressionNode* m_test;
StatementNodeVector m_consequent;
};
}
#endif

View file

@ -17,8 +17,8 @@
#ifndef SwitchStatementNode_h
#define SwitchStatementNode_h
#include "StatementNode.h"
#include "ExpressionNode.h"
#include "StatementNode.h"
#include "SwitchCaseNode.h"
namespace Escargot {
@ -29,15 +29,14 @@ public:
SwitchStatementNode(Node* discriminant, StatementNodeVector&& casesA, Node* deflt, StatementNodeVector&& casesB, bool lexical)
: StatementNode()
{
m_discriminant = (ExpressionNode*) discriminant;
m_discriminant = (ExpressionNode*)discriminant;
m_casesA = casesA;
m_default = (StatementNode*) deflt;
m_default = (StatementNode*)deflt;
m_casesB = casesB;
m_lexical = lexical;
}
virtual ASTNodeType type() { return ASTNodeType::SwitchStatement; }
protected:
ExpressionNode* m_discriminant;
StatementNodeVector m_casesA;
@ -45,7 +44,6 @@ protected:
StatementNodeVector m_casesB;
bool m_lexical;
};
}
#endif

View file

@ -24,16 +24,18 @@ namespace Escargot {
class ThisExpressionNode : public ExpressionNode {
public:
ThisExpressionNode()
: ExpressionNode() { }
: ExpressionNode()
{
}
virtual ASTNodeType type() { return ASTNodeType::ThisExpression; }
virtual void generateExpressionByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
codeBlock->pushCode(GetThis(ByteCodeLOC(m_loc.index), context->getRegister()), context, this);
}
protected:
};
}
#endif

View file

@ -25,24 +25,23 @@ namespace Escargot {
class ThrowStatementNode : public StatementNode {
public:
friend class ScriptParser;
ThrowStatementNode(Node *argument)
ThrowStatementNode(Node* argument)
: StatementNode()
{
m_argument = argument;
}
virtual ASTNodeType type() { return ASTNodeType::ThrowStatement; }
virtual void generateStatementByteCode(ByteCodeBlock* codeBlock, ByteCodeGenerateContext* context)
{
m_argument->generateExpressionByteCode(codeBlock, context);
codeBlock->pushCode(ThrowOperation(ByteCodeLOC(m_loc.index), context->getLastRegisterIndex()), context, this);
context->giveUpRegister();
}
protected:
Node* m_argument;
};
}
#endif

View file

@ -17,33 +17,31 @@
#ifndef TryStatementNode_h
#define TryStatementNode_h
#include "CatchClauseNode.h"
#include "StatementNode.h"
#include "runtime/ExecutionContext.h"
#include "CatchClauseNode.h"
namespace Escargot {
class TryStatementNode : public StatementNode {
public:
friend class ScriptParser;
TryStatementNode(Node *block, Node *handler, CatchClauseNodeVector&& guardedHandlers, Node *finalizer)
TryStatementNode(Node *block, Node *handler, CatchClauseNodeVector &&guardedHandlers, Node *finalizer)
: StatementNode()
{
m_block = (BlockStatementNode*) block;
m_handler = (CatchClauseNode*) handler;
m_block = (BlockStatementNode *)block;
m_handler = (CatchClauseNode *)handler;
m_guardedHandlers = guardedHandlers;
m_finalizer = (BlockStatementNode*) finalizer;
m_finalizer = (BlockStatementNode *)finalizer;
}
virtual ASTNodeType type() { return ASTNodeType::TryStatement; }
protected:
BlockStatementNode *m_block;
CatchClauseNode *m_handler;
CatchClauseNodeVector m_guardedHandlers;
BlockStatementNode *m_finalizer;
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::UnaryExpressionBitwiseNot; }
protected:
Node* m_argument;
};
}
#endif

View file

@ -27,15 +27,13 @@ public:
UnaryExpressionDeleteNode(Node* argument)
: ExpressionNode()
{
m_argument = (ExpressionNode*) argument;
m_argument = (ExpressionNode*)argument;
}
virtual ASTNodeType type() { return ASTNodeType::UnaryExpressionDelete; }
protected:
ExpressionNode* m_argument;
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::UnaryExpressionLogicalNot; }
protected:
Node* m_argument;
};
}
#endif

View file

@ -36,10 +36,10 @@ public:
m_argument->generateExpressionByteCode(codeBlock, context);
codeBlock->pushCode(UnaryMinus(ByteCodeLOC(m_loc.index), context->getLastRegisterIndex()), context, this);
}
protected:
Node* m_argument;
};
}
#endif

View file

@ -36,10 +36,10 @@ public:
m_argument->generateExpressionByteCode(codeBlock, context);
codeBlock->pushCode(UnaryPlus(ByteCodeLOC(m_loc.index), context->getLastRegisterIndex()), context, this);
}
protected:
Node* m_argument;
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::UnaryExpressionTypeOf; }
protected:
Node* m_argument;
};
}
#endif

View file

@ -31,11 +31,9 @@ public:
}
virtual ASTNodeType type() { return ASTNodeType::UnaryExpressionVoid; }
protected:
Node* m_argument;
};
}
#endif

Some files were not shown because too many files have changed in this diff Show more