Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions tslang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})

set(LLVM_ENABLE_EH "ON")
set(LLVM_ENABLE_RTTI "ON")
set(LLVM_REQUIRES_RTTI "ON")
set(LLVM_ENABLE_PIC "ON")

# clang fix
Expand Down
9 changes: 7 additions & 2 deletions tslang/cmake/config_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ if(MSVC)
else()
#SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-function -Wno-unused-result -Wno-unused-variable -Wno-unused-private-field -Wno-sign-compare -Wno-implicit-fallthrough -Wno-logical-op-parentheses -Wno-parentheses -Wno-unused-command-line-argument -frtti -lstdc++fs")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-function -Wno-unused-result -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough -Wno-parentheses -Wno-type-limits -Wno-unused-const-variable -Wno-unused-private-field")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-function -Wno-unused-result -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough -Wno-parentheses -Wno-type-limits -Wno-unused-const-variable -Wno-unused-private-field -Wno-dollar-in-identifier-extension -Wno-c++20-extensions")
else()
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-unused-function -Wno-unused-result -Wno-unused-variable -Wno-sign-compare -Wno-implicit-fallthrough -Wno-parentheses -Wno-type-limits -Wno-unused-but-set-variable -Wno-subobject-linkage")
endif()
# enable RTTI
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")

if (LLVM_ENABLE_RTTI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fexceptions")
endif()
endif()

endmacro()
Expand Down
14 changes: 7 additions & 7 deletions tslang/include/TypeScript/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
#define TYPESCRIPT_HELPER_H

#include <memory>
#include "llvm/Support/Casting.h" // Add this header

template< typename T, typename U >
inline std::unique_ptr< T > dynamic_pointer_cast(std::unique_ptr< U > &&ptr) {
U * const stored_ptr = ptr.release();
T * const converted_stored_ptr = dynamic_cast< T * >(stored_ptr);
if (converted_stored_ptr) {
return std::unique_ptr< T >(converted_stored_ptr);

// Check type using LLVM's custom, RTTI-free system
if (stored_ptr && llvm::isa< T >(stored_ptr)) {
return std::unique_ptr< T >(static_cast< T * >(stored_ptr));
}
else {
if (stored_ptr)
{
if (stored_ptr) {
throw "Invalid cast";
}

ptr.reset(stored_ptr);
return std::unique_ptr< T >();
}
}

#endif // TYPESCRIPT_HELPER_H
#endif // TYPESCRIPT_HELPER_H
6 changes: 0 additions & 6 deletions tslang/lib/TypeScriptAsyncRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
endif()

add_mlir_library(TypeScriptAsyncRuntime
STATIC
AsyncRuntime.cpp
Expand Down
8 changes: 0 additions & 8 deletions tslang/lib/TypeScriptRuntime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# Include dir + lib location come from the BDWgc::gc imported target (find_package
# in the top-level CMakeLists), so no hardcoded include_directories/link_directories.
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
endif()

# On Windows the runtime takes Boehm from gc.dll rather than linking it in: under the JIT this
# DLL shares the process with the default library's DLL and with user shared libraries, and a
# second static collector frees what the others still hold. See the top-level CMakeLists and
Expand Down
6 changes: 0 additions & 6 deletions tslang/ts-new-parser/parser_fwd_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ template <typename T> struct ptr_t
return U(instance);
}

template <typename U, typename D = typename U::data> inline auto is() -> boolean
{
// TODO: review and simplify using Kind
return !!std::dynamic_pointer_cast<D>(instance);
}

REF_TYPE(T) instance;
};

Expand Down
11 changes: 11 additions & 0 deletions tslang/ts-new-parser/parser_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ struct Node : TextRange
{
}

// RTTI-free structural check used by isNamedDeclaration(); overridden by NamedDeclaration.
virtual auto getDeclarationName() -> PTR(DeclarationName)
{
return PTR(DeclarationName)();
}

Node() = default;
Node(SyntaxKind kind, pos_type pos, number end) : TextRange{pos, end}, _kind(kind)
{
Expand Down Expand Up @@ -370,6 +376,11 @@ struct Declaration : DeclarationStatement {
struct NamedDeclaration : Declaration
{
PTR(DeclarationName) name;

auto getDeclarationName() -> PTR(DeclarationName) override
{
return name;
}
};

struct ClassElement : NamedDeclaration
Expand Down
3 changes: 2 additions & 1 deletion tslang/ts-new-parser/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,8 @@ inline auto isClassMemberModifier(SyntaxKind idToken) -> boolean

inline static auto isNamedDeclaration(Node node) -> boolean
{
return !!node.is<NamedDeclaration>(); // A 'name' property should always be a DeclarationName.
// A 'name' property should always be a DeclarationName; RTTI-free via virtual dispatch.
return !!node && !!node->getDeclarationName();
}

inline static auto isPropertyName(Node node) -> boolean
Expand Down
Loading