refactor(lex_parser): 重命名libcore为scc_core并重构头文件包含
- 将依赖项从libcore重命名为scc_core - 更新头文件包含路径从<libcore.h>到<scc_core.h> - 保持原有功能不变 refactor(lexer): 重命名libcore为scc_core并添加词法流式解析功能 - 将依赖项从libcore重命名为scc_core - 移除不再需要的scc_lexer_token结构体定义 - 重命名struct cc_lexer为struct scc_lexer - 添加scc_lexer_stream_t流式解析器相关定义和实现 - 新增lexer_stream.c文件实现流式token缓冲功能 refactor(lexer_log): 重命名logger变量和头文件定义 - 将头文件保护宏从__SMCC_LEXER_LOG_H__改为__SCC_LEXER_LOG_H__ - 将logger变量从__smcc_lexer_log改为__scc_lexer_log - 更新头文件包含从<libcore.h>到<scc_core.h> refactor(lexer_token): 重新组织token头文件结构 - 将头文件保护宏从__SMCC_CC_TOKEN_H__改为__SCC_LEXER_TOKEN_H__ - 更新头文件包含从<libcore.h>到<scc_core.h> - 将scc_lexer_token结构体定义移至该文件 refactor(lexer): 简化token匹配代码格式 - 移除LCC相关的注释内容 - 优化括号符号的token匹配代码格式,使用clang-format控制 refactor(pprocessor): 更新依赖项名称和头文件包含 - 将libcore重命名为scc_core - 将libutils重命名为scc_utils - 更新头文件包含路径 refactor(runtime): 重命名libcore为scc_core并重构目录结构 - 将libcore目录重命名为scc_core - 将libutils目录重命名为scc_utils - 更新所有相关的头文件包含路径 - 修改cbuild.toml中的包名称 - 更新core_vec.h中的宏定义以支持标准库模式
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
#ifndef __SCC_CORE_H__
|
||||
#define __SCC_CORE_H__
|
||||
|
||||
#include <core_log.h>
|
||||
|
||||
#include <core_impl.h>
|
||||
#include <core_macro.h>
|
||||
#include <core_mem.h>
|
||||
#include <core_pos.h>
|
||||
#include <core_str.h>
|
||||
#include <core_stream.h>
|
||||
#include <core_vec.h>
|
||||
|
||||
#endif // __SCC_CORE_H__
|
||||
@@ -1,7 +0,0 @@
|
||||
[package]
|
||||
name = "libutils"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies = [
|
||||
{ name = "core", path = "../libcore" }
|
||||
]
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "libcore"
|
||||
name = "scc_core"
|
||||
version = "0.1.0"
|
||||
|
||||
default_features = ["std_impl"]
|
||||
14
runtime/scc_core/include/scc_core.h
Normal file
14
runtime/scc_core/include/scc_core.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef __SCC_CORE_H__
|
||||
#define __SCC_CORE_H__
|
||||
|
||||
#include <scc_core_log.h>
|
||||
|
||||
#include <scc_core_impl.h>
|
||||
#include <scc_core_macro.h>
|
||||
#include <scc_core_mem.h>
|
||||
#include <scc_core_pos.h>
|
||||
#include <scc_core_str.h>
|
||||
#include <scc_core_stream.h>
|
||||
#include <scc_core_vec.h>
|
||||
|
||||
#endif // __SCC_CORE_H__
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __SCC_CORE_IMPL_H__
|
||||
#define __SCC_CORE_IMPL_H__
|
||||
|
||||
#include "core_type.h"
|
||||
#include "scc_core_type.h"
|
||||
|
||||
/* ====== 内存管理核心接口 ====== */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __SCC_CORE_MEM_H__
|
||||
#define __SCC_CORE_MEM_H__
|
||||
|
||||
#include "core_type.h"
|
||||
#include "scc_core_type.h"
|
||||
|
||||
void *scc_memcpy(void *dest, const void *src, usize n);
|
||||
void *scc_memmove(void *dest, const void *src, usize n);
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef __SCC_CORE_POS_H__
|
||||
#define __SCC_CORE_POS_H__
|
||||
|
||||
#include "core_str.h"
|
||||
#include "core_type.h"
|
||||
#include "scc_core_str.h"
|
||||
#include "scc_core_type.h"
|
||||
typedef struct scc_pos {
|
||||
scc_cstring_t name;
|
||||
usize line;
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef __SCC_CORE_STR_H__
|
||||
#define __SCC_CORE_STR_H__
|
||||
|
||||
#include "core_impl.h"
|
||||
#include "core_log.h"
|
||||
#include "core_type.h"
|
||||
#include "scc_core_impl.h"
|
||||
#include "scc_core_log.h"
|
||||
#include "scc_core_mem.h"
|
||||
#include "scc_core_type.h"
|
||||
|
||||
/**
|
||||
* @brief 动态字符串结构体
|
||||
@@ -68,7 +69,7 @@ static inline void scc_cstring_free(scc_cstring_t *str) {
|
||||
if (str == null) {
|
||||
return;
|
||||
}
|
||||
if (str->cap != 0 && str->data != null) {
|
||||
if (str->data != null) {
|
||||
scc_free(str->data);
|
||||
str->data = null;
|
||||
}
|
||||
@@ -188,14 +189,14 @@ static inline void scc_cstring_clear(scc_cstring_t *str) {
|
||||
*/
|
||||
static inline char *scc_cstring_as_cstr(const scc_cstring_t *str) {
|
||||
if (str == null || str->data == null) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
return str->data;
|
||||
}
|
||||
|
||||
static inline char *scc_cstring_move_cstr(scc_cstring_t *str) {
|
||||
if (str == null || str->data == null) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
char *ret = str->data;
|
||||
str->data = null;
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef __SMCC_CORE_PROBE_STREAM_H__
|
||||
#define __SMCC_CORE_PROBE_STREAM_H__
|
||||
|
||||
#include "core_impl.h"
|
||||
#include "core_macro.h"
|
||||
#include "core_mem.h"
|
||||
#include "core_str.h"
|
||||
#include "scc_core_impl.h"
|
||||
#include "scc_core_macro.h"
|
||||
#include "scc_core_mem.h"
|
||||
#include "scc_core_str.h"
|
||||
|
||||
struct scc_probe_stream;
|
||||
typedef struct scc_probe_stream scc_probe_stream_t;
|
||||
@@ -8,11 +8,34 @@
|
||||
#ifndef __SCC_CORE_VEC_H__
|
||||
#define __SCC_CORE_VEC_H__
|
||||
|
||||
#include "core_impl.h"
|
||||
#include "core_type.h"
|
||||
#ifndef __SCC_CORE_VEC_USE_STD__
|
||||
#include "scc_core_impl.h"
|
||||
#include "scc_core_type.h"
|
||||
|
||||
#define __scc_vec_realloc scc_realloc
|
||||
#define __scc_vec_free scc_free
|
||||
#else
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef size_t usize;
|
||||
#define __scc_vec_realloc realloc
|
||||
#define __scc_vec_free free
|
||||
|
||||
#ifndef LOG_FATAL
|
||||
#include <stdio.h>
|
||||
#define LOG_FATAL(...) \
|
||||
do { \
|
||||
printf(__VA_ARGS__); \
|
||||
exit(1); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef Assert
|
||||
#include <assert.h>
|
||||
#define Assert(cond) assert(cond)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/** @defgroup vec_struct 数据结构定义 */
|
||||
|
||||
@@ -51,6 +74,22 @@
|
||||
(vec).size = 0, (vec).cap = 0, (vec).data = 0; \
|
||||
} while (0)
|
||||
|
||||
#define scc_vec_realloc(vec, new_cap) \
|
||||
do { \
|
||||
void *data = \
|
||||
__scc_vec_realloc((vec).data, new_cap * sizeof(*(vec).data)); \
|
||||
if (!data) { \
|
||||
LOG_FATAL("vector_push: realloc failed\n"); \
|
||||
} \
|
||||
(vec).cap = new_cap; \
|
||||
(vec).data = data; \
|
||||
} while (0)
|
||||
|
||||
#define scc_vec_size(vec) ((vec).size)
|
||||
#define scc_vec_cap(vec) ((vec).cap)
|
||||
#define scc_vec_foreach(vec, idx) \
|
||||
for (usize idx = 0; idx < scc_vec_size(vec); ++idx)
|
||||
|
||||
/**
|
||||
* @def scc_vec_push(vec, value)
|
||||
* @brief 添加元素到向量末尾
|
||||
@@ -64,13 +103,7 @@
|
||||
do { \
|
||||
if ((vec).size >= (vec).cap) { \
|
||||
int cap = (vec).cap ? (vec).cap * 2 : 4; \
|
||||
void *data = \
|
||||
__scc_vec_realloc((vec).data, cap * sizeof(*(vec).data)); \
|
||||
if (!data) { \
|
||||
LOG_FATAL("vector_push: realloc failed\n"); \
|
||||
} \
|
||||
(vec).cap = cap; \
|
||||
(vec).data = data; \
|
||||
scc_vec_realloc(vec, cap); \
|
||||
} \
|
||||
Assert((vec).data != null); \
|
||||
(vec).data[(vec).size++] = value; \
|
||||
@@ -2,7 +2,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include <core_impl.h>
|
||||
#include <scc_core_impl.h>
|
||||
#define __SCC_LOG_IMPORT_SRC__
|
||||
#define log_snprintf scc_snprintf
|
||||
#define log_printf scc_printf
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <core_mem.h>
|
||||
#include <scc_core_mem.h>
|
||||
|
||||
// 判断是否支持非对齐访问(x86/x64 支持)
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || \
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <core_log.h>
|
||||
#include <core_stream.h>
|
||||
#include <scc_core_log.h>
|
||||
#include <scc_core_stream.h>
|
||||
|
||||
#ifndef __SCC_CORE_NO_MEM_PROBE_STREAM__
|
||||
|
||||
5
runtime/scc_utils/cbuild.toml
Normal file
5
runtime/scc_utils/cbuild.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
[package]
|
||||
name = "scc_utils"
|
||||
version = "0.1.0"
|
||||
|
||||
dependencies = [{ name = "core", path = "../scc_core" }]
|
||||
@@ -8,7 +8,7 @@
|
||||
#ifndef __SCC_HASHTABLE_H__
|
||||
#define __SCC_HASHTABLE_H__
|
||||
|
||||
#include <libcore.h>
|
||||
#include <scc_core.h>
|
||||
|
||||
/**
|
||||
* @enum hp_entry_state_t
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef __SCC_STRPOOL_H__
|
||||
#define __SCC_STRPOOL_H__
|
||||
|
||||
#include "hashtable.h"
|
||||
#include <libcore.h>
|
||||
#include "scc_hashtable.h"
|
||||
#include <scc_core.h>
|
||||
|
||||
/**
|
||||
* @struct strpool_t
|
||||
@@ -1,9 +1,9 @@
|
||||
#ifndef __SMCC_UTILS_H__
|
||||
#define __SMCC_UTILS_H__
|
||||
|
||||
#include "hashtable.h"
|
||||
#include "kllist.h"
|
||||
#include "strpool.h"
|
||||
#include <libcore.h>
|
||||
#include "scc_hashtable.h"
|
||||
#include "scc_strpool.h"
|
||||
#include <scc_core.h>
|
||||
|
||||
#endif /* __SMCC_UTILS_H__ */
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <hashtable.h>
|
||||
#include <scc_hashtable.h>
|
||||
|
||||
#ifndef SCC_INIT_HASHMAP_SIZE
|
||||
#define SCC_INIT_HASHMAP_SIZE (32)
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "strpool.h"
|
||||
#include <scc_strpool.h>
|
||||
|
||||
void scc_strpool_init(scc_strpool_t *pool) {
|
||||
pool->ht.hash_func = (u32 (*)(const void *))scc_strhash32;
|
||||
Reference in New Issue
Block a user