Skip to content

Commit

Permalink
Merge pull request #177 from blade-lang/172-merge-wire-into-blade
Browse files Browse the repository at this point in the history
172 merge wire into blade
  • Loading branch information
mcfriend99 authored Jun 14, 2023
2 parents cd0eb5f + 4a57c61 commit 0d81f94
Show file tree
Hide file tree
Showing 85 changed files with 2,080 additions and 349,732 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [ main, dev ]
branches: [ main, dev, odyssey ]
pull_request:
branches: [ main ]

Expand Down
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ target_include_directories(libblade PUBLIC "${INCLUDE_GEN_DIR}")
set(LIBRARY_NAME_END "${CMAKE_DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(SHARED_LIBRARY_NAME_END "${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}")

add_dependencies(libblade pcre2)

set_target_properties(libblade
PROPERTIES
OUTPUT_NAME blade
Expand All @@ -160,8 +158,24 @@ if(MINGW OR MUSL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-stringop-overread")
endif()

cmake_policy(SET CMP0135 OLD)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(PCRE2_USE_STATIC_LIBS ON)
include(FetchContent)
FetchContent_Declare(pcre2
URL https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.42/pcre2-10.42.tar.gz
URL_HASH SHA256=c33b418e3b936ee3153de2c61cc638e7e4fe3156022a5c77d0711bcbb9d64f1f
)
FetchContent_MakeAvailable(pcre2)

if(NOT pcre2_POPULATED)
FetchContent_Populate(pcre2)
add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BUILD_DIR})
endif()

# link pcre2
target_link_libraries(libblade PRIVATE pcre2)
target_link_libraries(libblade PRIVATE pcre2-8-static)
target_include_directories(libblade PUBLIC "${pcre2_BINARY_DIR}")

if(UNIX)
# Add linenoise as dependency and link it.
Expand Down Expand Up @@ -198,6 +212,8 @@ add_custom_command(TARGET blade POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:blade> ${EXE_FILE}
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:libblade> ${LIBRARY_FILE}
COMMAND ${EXE_FILE} "${PROJECT_SOURCE_DIR}/scripts/make_blade.b" "${PROJECT_SOURCE_DIR}"
# The first one is useful for development purposes but doesn't in any way harm release.
COMMAND ${EXE_FILE} "${PROJECT_SOURCE_DIR}/scripts/ast.b" "${PROJECT_SOURCE_DIR}/libs/ast"
COMMAND ${EXE_FILE} "${PROJECT_SOURCE_DIR}/scripts/ast.b" "${OUTPUT_DIR}/libs/ast"
COMMENT "Generating Blade header and copy output..."
)
Expand Down
140 changes: 140 additions & 0 deletions libs/ast/decl.b
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#!-- This file is autogenerated by scripts/ast.b
/**
* base Decl class
*/
class Decl {
var doc
}

/**
* Var Decl representation
* @serializable
*/
class VarDecl < Decl {

/**
* VarDecl(name, value)
* @constructor
*/
VarDecl(name, value) {
self.name = name
self.value = value
}

@to_json() {
return {
type: 'VarDecl',
name: self.name,
value: self.value,
}
}
}

/**
* Function Decl representation
* @serializable
*/
class FunctionDecl < Decl {

/**
* FunctionDecl(name, params, body)
* @constructor
*/
FunctionDecl(name, params, body) {
self.name = name
self.params = params
self.body = body
}

@to_json() {
return {
type: 'FunctionDecl',
name: self.name,
params: self.params,
body: self.body,
}
}
}

/**
* Method Decl representation
* @serializable
*/
class MethodDecl < Decl {

/**
* MethodDecl(name, params, body, is_static)
* @constructor
*/
MethodDecl(name, params, body, is_static) {
self.name = name
self.params = params
self.body = body
self.is_static = is_static
}

@to_json() {
return {
type: 'MethodDecl',
name: self.name,
params: self.params,
body: self.body,
is_static: self.is_static,
}
}
}

/**
* Property Decl representation
* @serializable
*/
class PropertyDecl < Decl {

/**
* PropertyDecl(name, value, is_static)
* @constructor
*/
PropertyDecl(name, value, is_static) {
self.name = name
self.value = value
self.is_static = is_static
}

@to_json() {
return {
type: 'PropertyDecl',
name: self.name,
value: self.value,
is_static: self.is_static,
}
}
}

/**
* Class Decl representation
* @serializable
*/
class ClassDecl < Decl {

/**
* ClassDecl(name, superclass, properties, methods)
* @constructor
*/
ClassDecl(name, superclass, properties, methods) {
self.name = name
self.superclass = superclass
self.properties = properties
self.methods = methods
}

@to_json() {
return {
type: 'ClassDecl',
name: self.name,
superclass: self.superclass,
properties: self.properties,
methods: self.methods,
}
}
}

29 changes: 29 additions & 0 deletions libs/ast/defn.b
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!-- This file is autogenerated by scripts/ast.b
/**
* base Defn class
*/
class Defn {
}

/**
* Doc Defn representation
* @serializable
*/
class DocDefn < Defn {

/**
* DocDefn(data)
* @constructor
*/
DocDefn(data) {
self.data = data
}

@to_json() {
return {
type: 'DocDefn',
data: self.data,
}
}
}

Loading

0 comments on commit 0d81f94

Please sign in to comment.