forked from NUDT-compiler/nudt-compiler-cpp
Compare commits
8 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
6faa67fb65 | 1 week ago |
|
|
9184ba9c9d | 2 weeks ago |
|
|
c33d36e040 | 2 weeks ago |
|
|
97d5ec1d48 | 2 weeks ago |
|
|
f16c29db26 | 2 weeks ago |
|
|
04a29b2bf9 | 2 weeks ago |
|
|
477720eb5e | 2 weeks ago |
|
|
192b8004ed | 3 weeks ago |
@ -1,178 +1,151 @@
|
||||
#ifndef SEMANTIC_ANALYSIS_H
|
||||
#define SEMANTIC_ANALYSIS_H
|
||||
|
||||
#include "SymbolTable.h"
|
||||
#include "../../generated/antlr4/SysYBaseVisitor.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <unordered_map>
|
||||
#include <any>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "SymbolTable.h"
|
||||
#include "SysYBaseVisitor.h"
|
||||
#include "SysYParser.h"
|
||||
|
||||
// 错误信息结构体
|
||||
struct ErrorMsg {
|
||||
std::string msg;
|
||||
int line;
|
||||
int column;
|
||||
ErrorMsg(std::string m, int l, int c) : msg(std::move(m)), line(l), column(c) {}
|
||||
};
|
||||
std::string msg;
|
||||
int line;
|
||||
int column;
|
||||
|
||||
// 前向声明
|
||||
namespace antlr4 {
|
||||
class ParserRuleContext;
|
||||
namespace tree {
|
||||
class ParseTree;
|
||||
}
|
||||
}
|
||||
ErrorMsg(std::string m, int l, int c) : msg(std::move(m)), line(l), column(c) {}
|
||||
};
|
||||
|
||||
// 语义/IR生成上下文核心类
|
||||
class IRGenContext {
|
||||
public:
|
||||
// 错误管理
|
||||
void RecordError(const ErrorMsg& err) { errors_.push_back(err); }
|
||||
const std::vector<ErrorMsg>& GetErrors() const { return errors_; }
|
||||
bool HasError() const { return !errors_.empty(); }
|
||||
void ClearErrors() { errors_.clear(); }
|
||||
|
||||
// 类型绑定/查询 - 使用 void* 以兼容测试代码
|
||||
void SetType(void* ctx, SymbolType type) {
|
||||
node_type_map_[ctx] = type;
|
||||
}
|
||||
|
||||
SymbolType GetType(void* ctx) const {
|
||||
auto it = node_type_map_.find(ctx);
|
||||
return it == node_type_map_.end() ? SymbolType::TYPE_UNKNOWN : it->second;
|
||||
}
|
||||
|
||||
// 常量值绑定/查询 - 使用 void* 以兼容测试代码
|
||||
void SetConstVal(void* ctx, const std::any& val) {
|
||||
const_val_map_[ctx] = val;
|
||||
}
|
||||
|
||||
std::any GetConstVal(void* ctx) const {
|
||||
auto it = const_val_map_.find(ctx);
|
||||
return it == const_val_map_.end() ? std::any() : it->second;
|
||||
}
|
||||
|
||||
// 循环状态管理
|
||||
void EnterLoop() { sym_table_.EnterLoop(); }
|
||||
void ExitLoop() { sym_table_.ExitLoop(); }
|
||||
bool InLoop() const { return sym_table_.InLoop(); }
|
||||
|
||||
// 类型判断工具函数
|
||||
bool IsIntType(const std::any& val) const {
|
||||
return val.type() == typeid(long) || val.type() == typeid(int);
|
||||
}
|
||||
|
||||
bool IsFloatType(const std::any& val) const {
|
||||
return val.type() == typeid(double) || val.type() == typeid(float);
|
||||
}
|
||||
|
||||
// 当前函数返回类型
|
||||
SymbolType GetCurrentFuncReturnType() const {
|
||||
return current_func_ret_type_;
|
||||
}
|
||||
|
||||
void SetCurrentFuncReturnType(SymbolType type) {
|
||||
current_func_ret_type_ = type;
|
||||
}
|
||||
|
||||
// 符号表访问
|
||||
SymbolTable& GetSymbolTable() { return sym_table_; }
|
||||
const SymbolTable& GetSymbolTable() const { return sym_table_; }
|
||||
|
||||
// 作用域管理
|
||||
void EnterScope() { sym_table_.EnterScope(); }
|
||||
void LeaveScope() { sym_table_.LeaveScope(); }
|
||||
size_t GetScopeDepth() const { return sym_table_.GetScopeDepth(); }
|
||||
|
||||
private:
|
||||
SymbolTable sym_table_;
|
||||
std::unordered_map<void*, SymbolType> node_type_map_;
|
||||
std::unordered_map<void*, std::any> const_val_map_;
|
||||
std::vector<ErrorMsg> errors_;
|
||||
SymbolType current_func_ret_type_ = SymbolType::TYPE_UNKNOWN;
|
||||
public:
|
||||
void RecordError(const ErrorMsg& err) { errors_.push_back(err); }
|
||||
const std::vector<ErrorMsg>& GetErrors() const { return errors_; }
|
||||
bool HasError() const { return !errors_.empty(); }
|
||||
void ClearErrors() { errors_.clear(); }
|
||||
|
||||
void SetType(void* ctx, SymbolType type) { node_type_map_[ctx] = type; }
|
||||
|
||||
SymbolType GetType(void* ctx) const {
|
||||
auto it = node_type_map_.find(ctx);
|
||||
return it == node_type_map_.end() ? SymbolType::TYPE_UNKNOWN : it->second;
|
||||
}
|
||||
|
||||
void SetConstVal(void* ctx, const std::any& val) { const_val_map_[ctx] = val; }
|
||||
|
||||
std::any GetConstVal(void* ctx) const {
|
||||
auto it = const_val_map_.find(ctx);
|
||||
return it == const_val_map_.end() ? std::any() : it->second;
|
||||
}
|
||||
|
||||
void EnterLoop() { sym_table_.EnterLoop(); }
|
||||
void ExitLoop() { sym_table_.ExitLoop(); }
|
||||
bool InLoop() const { return sym_table_.InLoop(); }
|
||||
|
||||
bool IsIntType(const std::any& val) const {
|
||||
return val.type() == typeid(long) || val.type() == typeid(int);
|
||||
}
|
||||
|
||||
bool IsFloatType(const std::any& val) const {
|
||||
return val.type() == typeid(double) || val.type() == typeid(float);
|
||||
}
|
||||
|
||||
SymbolType GetCurrentFuncReturnType() const { return current_func_ret_type_; }
|
||||
void SetCurrentFuncReturnType(SymbolType type) { current_func_ret_type_ = type; }
|
||||
|
||||
SymbolTable& GetSymbolTable() { return sym_table_; }
|
||||
const SymbolTable& GetSymbolTable() const { return sym_table_; }
|
||||
|
||||
void EnterScope() { sym_table_.EnterScope(); }
|
||||
void LeaveScope() { sym_table_.LeaveScope(); }
|
||||
size_t GetScopeDepth() const { return sym_table_.GetScopeDepth(); }
|
||||
|
||||
private:
|
||||
SymbolTable sym_table_;
|
||||
std::unordered_map<void*, SymbolType> node_type_map_;
|
||||
std::unordered_map<void*, std::any> const_val_map_;
|
||||
std::vector<ErrorMsg> errors_;
|
||||
SymbolType current_func_ret_type_ = SymbolType::TYPE_UNKNOWN;
|
||||
};
|
||||
|
||||
class SemanticContext {
|
||||
public:
|
||||
void BindVarUse(const SysYParser::LValueContext* use,
|
||||
SysYParser::VarDefContext* decl) {
|
||||
var_uses_[use] = decl;
|
||||
}
|
||||
|
||||
SysYParser::VarDefContext* ResolveVarUse(
|
||||
const SysYParser::LValueContext* use) const {
|
||||
auto it = var_uses_.find(use);
|
||||
return it == var_uses_.end() ? nullptr : it->second;
|
||||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<const SysYParser::LValueContext*, SysYParser::VarDefContext*>
|
||||
var_uses_;
|
||||
};
|
||||
|
||||
// 错误信息格式化工具函数
|
||||
inline std::string FormatErrMsg(const std::string& msg, int line, int col) {
|
||||
std::ostringstream oss;
|
||||
oss << "[行:" << line << ",列:" << col << "] " << msg;
|
||||
return oss.str();
|
||||
std::ostringstream oss;
|
||||
oss << "[行:" << line << ",列:" << col << "] " << msg;
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
// 语义分析访问器 - 继承自生成的基类
|
||||
class SemaVisitor : public SysYBaseVisitor {
|
||||
public:
|
||||
explicit SemaVisitor(IRGenContext& ctx) : ir_ctx_(ctx) {}
|
||||
|
||||
// 必须实现的 ANTLR4 接口
|
||||
std::any visit(antlr4::tree::ParseTree* tree) override {
|
||||
if (tree) {
|
||||
return tree->accept(this);
|
||||
}
|
||||
return std::any();
|
||||
}
|
||||
|
||||
std::any visitTerminal(antlr4::tree::TerminalNode* node) override {
|
||||
return std::any();
|
||||
}
|
||||
|
||||
std::any visitErrorNode(antlr4::tree::ErrorNode* node) override {
|
||||
if (node) {
|
||||
int line = node->getSymbol()->getLine();
|
||||
int col = node->getSymbol()->getCharPositionInLine() + 1;
|
||||
ir_ctx_.RecordError(ErrorMsg("语法错误节点", line, col));
|
||||
}
|
||||
return std::any();
|
||||
}
|
||||
|
||||
// 核心访问方法
|
||||
std::any visitCompUnit(SysYParser::CompUnitContext* ctx) override;
|
||||
std::any visitFuncDef(SysYParser::FuncDefContext* ctx) override;
|
||||
std::any visitDecl(SysYParser::DeclContext* ctx) override;
|
||||
std::any visitConstDecl(SysYParser::ConstDeclContext* ctx) override;
|
||||
std::any visitVarDecl(SysYParser::VarDeclContext* ctx) override;
|
||||
std::any visitBlock(SysYParser::BlockContext* ctx) override;
|
||||
std::any visitStmt(SysYParser::StmtContext* ctx) override;
|
||||
std::any visitLVal(SysYParser::LValContext* ctx) override;
|
||||
std::any visitExp(SysYParser::ExpContext* ctx) override;
|
||||
std::any visitCond(SysYParser::CondContext* ctx) override;
|
||||
std::any visitPrimaryExp(SysYParser::PrimaryExpContext* ctx) override;
|
||||
std::any visitUnaryExp(SysYParser::UnaryExpContext* ctx) override;
|
||||
std::any visitMulExp(SysYParser::MulExpContext* ctx) override;
|
||||
std::any visitAddExp(SysYParser::AddExpContext* ctx) override;
|
||||
std::any visitRelExp(SysYParser::RelExpContext* ctx) override;
|
||||
std::any visitEqExp(SysYParser::EqExpContext* ctx) override;
|
||||
std::any visitLAndExp(SysYParser::LAndExpContext* ctx) override;
|
||||
std::any visitLOrExp(SysYParser::LOrExpContext* ctx) override;
|
||||
std::any visitConstExp(SysYParser::ConstExpContext* ctx) override;
|
||||
std::any visitNumber(SysYParser::NumberContext* ctx) override;
|
||||
std::any visitFuncRParams(SysYParser::FuncRParamsContext* ctx) override;
|
||||
|
||||
// 通用子节点访问
|
||||
std::any visitChildren(antlr4::tree::ParseTree* node) override {
|
||||
std::any result;
|
||||
if (node) {
|
||||
for (auto* child : node->children) {
|
||||
if (child) {
|
||||
result = child->accept(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 获取上下文引用
|
||||
IRGenContext& GetContext() { return ir_ctx_; }
|
||||
const IRGenContext& GetContext() const { return ir_ctx_; }
|
||||
|
||||
private:
|
||||
IRGenContext& ir_ctx_;
|
||||
public:
|
||||
explicit SemaVisitor(IRGenContext& ctx, SemanticContext* sema_ctx = nullptr)
|
||||
: ir_ctx_(ctx), sema_ctx_(sema_ctx) {}
|
||||
|
||||
std::any visitCompUnit(SysYParser::CompUnitContext* ctx) override;
|
||||
std::any visitDecl(SysYParser::DeclContext* ctx) override;
|
||||
std::any visitConstDecl(SysYParser::ConstDeclContext* ctx) override;
|
||||
std::any visitBtype(SysYParser::BtypeContext* ctx) override;
|
||||
std::any visitConstDef(SysYParser::ConstDefContext* ctx) override;
|
||||
std::any visitConstInitValue(SysYParser::ConstInitValueContext* ctx) override;
|
||||
std::any visitVarDecl(SysYParser::VarDeclContext* ctx) override;
|
||||
std::any visitVarDef(SysYParser::VarDefContext* ctx) override;
|
||||
std::any visitInitValue(SysYParser::InitValueContext* ctx) override;
|
||||
std::any visitFuncDef(SysYParser::FuncDefContext* ctx) override;
|
||||
std::any visitFuncType(SysYParser::FuncTypeContext* ctx) override;
|
||||
std::any visitFuncFParams(SysYParser::FuncFParamsContext* ctx) override;
|
||||
std::any visitFuncFParam(SysYParser::FuncFParamContext* ctx) override;
|
||||
std::any visitBlockStmt(SysYParser::BlockStmtContext* ctx) override;
|
||||
std::any visitBlockItem(SysYParser::BlockItemContext* ctx) override;
|
||||
std::any visitStmt(SysYParser::StmtContext* ctx) override;
|
||||
std::any visitReturnStmt(SysYParser::ReturnStmtContext* ctx) override;
|
||||
std::any visitExp(SysYParser::ExpContext* ctx) override;
|
||||
std::any visitCond(SysYParser::CondContext* ctx) override;
|
||||
std::any visitLValue(SysYParser::LValueContext* ctx) override;
|
||||
std::any visitPrimaryExp(SysYParser::PrimaryExpContext* ctx) override;
|
||||
std::any visitNumber(SysYParser::NumberContext* ctx) override;
|
||||
std::any visitUnaryExp(SysYParser::UnaryExpContext* ctx) override;
|
||||
std::any visitUnaryOp(SysYParser::UnaryOpContext* ctx) override;
|
||||
std::any visitFuncRParams(SysYParser::FuncRParamsContext* ctx) override;
|
||||
std::any visitMulExp(SysYParser::MulExpContext* ctx) override;
|
||||
std::any visitAddExp(SysYParser::AddExpContext* ctx) override;
|
||||
std::any visitRelExp(SysYParser::RelExpContext* ctx) override;
|
||||
std::any visitEqExp(SysYParser::EqExpContext* ctx) override;
|
||||
std::any visitLAndExp(SysYParser::LAndExpContext* ctx) override;
|
||||
std::any visitLOrExp(SysYParser::LOrExpContext* ctx) override;
|
||||
std::any visitConstExp(SysYParser::ConstExpContext* ctx) override;
|
||||
|
||||
IRGenContext& GetContext() { return ir_ctx_; }
|
||||
const IRGenContext& GetContext() const { return ir_ctx_; }
|
||||
|
||||
private:
|
||||
void RecordNodeError(antlr4::ParserRuleContext* ctx, const std::string& msg);
|
||||
|
||||
IRGenContext& ir_ctx_;
|
||||
SemanticContext* sema_ctx_ = nullptr;
|
||||
SymbolType current_decl_type_ = SymbolType::TYPE_UNKNOWN;
|
||||
bool current_decl_is_const_ = false;
|
||||
};
|
||||
|
||||
// 语义分析入口函数
|
||||
void RunSemanticAnalysis(SysYParser::CompUnitContext* ctx, IRGenContext& ir_ctx);
|
||||
SemanticContext RunSema(SysYParser::CompUnitContext& comp_unit);
|
||||
|
||||
#endif // SEMANTIC_ANALYSIS_H
|
||||
#endif // SEMANTIC_ANALYSIS_H
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "nudt-compiler-cpp",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,3 @@
|
||||
This project is dual-licensed under the Unlicense and MIT licenses.
|
||||
|
||||
You may use this code under the terms of either license.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,46 @@
|
||||
# `@img/sharp-libvips-linux-x64`
|
||||
|
||||
Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64.
|
||||
|
||||
## Licensing
|
||||
|
||||
This software contains third-party libraries
|
||||
used under the terms of the following licences:
|
||||
|
||||
| Library | Used under the terms of |
|
||||
|---------------|-----------------------------------------------------------------------------------------------------------|
|
||||
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
||||
| cairo | Mozilla Public License 2.0 |
|
||||
| cgif | MIT Licence |
|
||||
| expat | MIT Licence |
|
||||
| fontconfig | [fontconfig Licence](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
||||
| freetype | [freetype Licence](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
||||
| fribidi | LGPLv3 |
|
||||
| glib | LGPLv3 |
|
||||
| harfbuzz | MIT Licence |
|
||||
| highway | Apache-2.0 License, BSD 3-Clause |
|
||||
| lcms | MIT Licence |
|
||||
| libarchive | BSD 2-Clause |
|
||||
| libexif | LGPLv3 |
|
||||
| libffi | MIT Licence |
|
||||
| libheif | LGPLv3 |
|
||||
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
||||
| libnsgif | MIT Licence |
|
||||
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
||||
| librsvg | LGPLv3 |
|
||||
| libspng | [BSD 2-Clause, libpng License](https://github.com/randy408/libspng/blob/master/LICENSE) |
|
||||
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
||||
| libvips | LGPLv3 |
|
||||
| libwebp | New BSD License |
|
||||
| libxml2 | MIT Licence |
|
||||
| mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
||||
| pango | LGPLv3 |
|
||||
| pixman | MIT Licence |
|
||||
| proxy-libintl | LGPLv3 |
|
||||
| zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
||||
|
||||
Use of libraries under the terms of the LGPLv3 is via the
|
||||
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
||||
|
||||
Please report any errors or omissions via
|
||||
https://github.com/lovell/sharp-libvips/issues/new
|
||||
@ -0,0 +1,221 @@
|
||||
/* glibconfig.h
|
||||
*
|
||||
* This is a generated file. Please modify 'glibconfig.h.in'
|
||||
*/
|
||||
|
||||
#ifndef __GLIBCONFIG_H__
|
||||
#define __GLIBCONFIG_H__
|
||||
|
||||
#include <glib/gmacros.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#define GLIB_HAVE_ALLOCA_H
|
||||
|
||||
#define GLIB_STATIC_COMPILATION 1
|
||||
#define GOBJECT_STATIC_COMPILATION 1
|
||||
#define GIO_STATIC_COMPILATION 1
|
||||
#define GMODULE_STATIC_COMPILATION 1
|
||||
#define GI_STATIC_COMPILATION 1
|
||||
#define G_INTL_STATIC_COMPILATION 1
|
||||
#define FFI_STATIC_BUILD 1
|
||||
|
||||
/* Specifies that GLib's g_print*() functions wrap the
|
||||
* system printf functions. This is useful to know, for example,
|
||||
* when using glibc's register_printf_function().
|
||||
*/
|
||||
#define GLIB_USING_SYSTEM_PRINTF
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define G_MINFLOAT FLT_MIN
|
||||
#define G_MAXFLOAT FLT_MAX
|
||||
#define G_MINDOUBLE DBL_MIN
|
||||
#define G_MAXDOUBLE DBL_MAX
|
||||
#define G_MINSHORT SHRT_MIN
|
||||
#define G_MAXSHORT SHRT_MAX
|
||||
#define G_MAXUSHORT USHRT_MAX
|
||||
#define G_MININT INT_MIN
|
||||
#define G_MAXINT INT_MAX
|
||||
#define G_MAXUINT UINT_MAX
|
||||
#define G_MINLONG LONG_MIN
|
||||
#define G_MAXLONG LONG_MAX
|
||||
#define G_MAXULONG ULONG_MAX
|
||||
|
||||
typedef signed char gint8;
|
||||
typedef unsigned char guint8;
|
||||
|
||||
typedef signed short gint16;
|
||||
typedef unsigned short guint16;
|
||||
|
||||
#define G_GINT16_MODIFIER "h"
|
||||
#define G_GINT16_FORMAT "hi"
|
||||
#define G_GUINT16_FORMAT "hu"
|
||||
|
||||
|
||||
typedef signed int gint32;
|
||||
typedef unsigned int guint32;
|
||||
|
||||
#define G_GINT32_MODIFIER ""
|
||||
#define G_GINT32_FORMAT "i"
|
||||
#define G_GUINT32_FORMAT "u"
|
||||
|
||||
|
||||
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
||||
|
||||
typedef signed long gint64;
|
||||
typedef unsigned long guint64;
|
||||
|
||||
#define G_GINT64_CONSTANT(val) (val##L)
|
||||
#define G_GUINT64_CONSTANT(val) (val##UL)
|
||||
|
||||
#define G_GINT64_MODIFIER "l"
|
||||
#define G_GINT64_FORMAT "li"
|
||||
#define G_GUINT64_FORMAT "lu"
|
||||
|
||||
|
||||
#define GLIB_SIZEOF_VOID_P 8
|
||||
#define GLIB_SIZEOF_LONG 8
|
||||
#define GLIB_SIZEOF_SIZE_T 8
|
||||
#define GLIB_SIZEOF_SSIZE_T 8
|
||||
|
||||
typedef signed long gssize;
|
||||
typedef unsigned long gsize;
|
||||
#define G_GSIZE_MODIFIER "l"
|
||||
#define G_GSSIZE_MODIFIER "l"
|
||||
#define G_GSIZE_FORMAT "lu"
|
||||
#define G_GSSIZE_FORMAT "li"
|
||||
|
||||
#define G_MAXSIZE G_MAXULONG
|
||||
#define G_MINSSIZE G_MINLONG
|
||||
#define G_MAXSSIZE G_MAXLONG
|
||||
|
||||
typedef gint64 goffset;
|
||||
#define G_MINOFFSET G_MININT64
|
||||
#define G_MAXOFFSET G_MAXINT64
|
||||
|
||||
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
||||
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
||||
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
||||
|
||||
#define G_POLLFD_FORMAT "%d"
|
||||
|
||||
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
||||
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
||||
|
||||
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
||||
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
||||
|
||||
typedef signed long gintptr;
|
||||
typedef unsigned long guintptr;
|
||||
|
||||
#define G_GINTPTR_MODIFIER "l"
|
||||
#define G_GINTPTR_FORMAT "li"
|
||||
#define G_GUINTPTR_FORMAT "lu"
|
||||
|
||||
#define GLIB_MAJOR_VERSION 2
|
||||
#define GLIB_MINOR_VERSION 86
|
||||
#define GLIB_MICRO_VERSION 1
|
||||
|
||||
#define G_OS_UNIX
|
||||
|
||||
#define G_VA_COPY va_copy
|
||||
|
||||
#define G_VA_COPY_AS_ARRAY 1
|
||||
|
||||
#define G_HAVE_ISO_VARARGS 1
|
||||
|
||||
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
||||
* is passed ISO vararg support is turned off, and there is no work
|
||||
* around to turn it on, so we unconditionally turn it off.
|
||||
*/
|
||||
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
||||
# undef G_HAVE_ISO_VARARGS
|
||||
#endif
|
||||
|
||||
#define G_HAVE_GROWING_STACK 0
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# define G_HAVE_GNUC_VARARGS 1
|
||||
#endif
|
||||
|
||||
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||
#define G_GNUC_INTERNAL __hidden
|
||||
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define G_GNUC_INTERNAL
|
||||
#endif
|
||||
|
||||
#define G_THREADS_ENABLED
|
||||
#define G_THREADS_IMPL_POSIX
|
||||
|
||||
#define G_ATOMIC_LOCK_FREE
|
||||
|
||||
#define GINT16_TO_LE(val) ((gint16) (val))
|
||||
#define GUINT16_TO_LE(val) ((guint16) (val))
|
||||
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
||||
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
||||
|
||||
#define GINT32_TO_LE(val) ((gint32) (val))
|
||||
#define GUINT32_TO_LE(val) ((guint32) (val))
|
||||
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
||||
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
||||
|
||||
#define GINT64_TO_LE(val) ((gint64) (val))
|
||||
#define GUINT64_TO_LE(val) ((guint64) (val))
|
||||
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
||||
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
||||
|
||||
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
||||
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
||||
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
||||
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
||||
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
||||
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
||||
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
||||
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
||||
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
||||
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
||||
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
||||
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
||||
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
|
||||
#define GLIB_SYSDEF_POLLIN =1
|
||||
#define GLIB_SYSDEF_POLLOUT =4
|
||||
#define GLIB_SYSDEF_POLLPRI =2
|
||||
#define GLIB_SYSDEF_POLLHUP =16
|
||||
#define GLIB_SYSDEF_POLLERR =8
|
||||
#define GLIB_SYSDEF_POLLNVAL =32
|
||||
|
||||
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
||||
* warnings on platforms where usage of this macro is broken */
|
||||
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
||||
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
||||
#else
|
||||
#define G_MODULE_SUFFIX "so"
|
||||
#endif
|
||||
|
||||
typedef int GPid;
|
||||
#define G_PID_FORMAT "i"
|
||||
|
||||
#define GLIB_SYSDEF_AF_UNIX 1
|
||||
#define GLIB_SYSDEF_AF_INET 2
|
||||
#define GLIB_SYSDEF_AF_INET6 10
|
||||
|
||||
#define GLIB_SYSDEF_MSG_OOB 1
|
||||
#define GLIB_SYSDEF_MSG_PEEK 2
|
||||
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
||||
|
||||
#define G_DIR_SEPARATOR '/'
|
||||
#define G_DIR_SEPARATOR_S "/"
|
||||
#define G_SEARCHPATH_SEPARATOR ':'
|
||||
#define G_SEARCHPATH_SEPARATOR_S ":"
|
||||
|
||||
#undef G_HAVE_FREE_SIZED
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLIBCONFIG_H__ */
|
||||
@ -0,0 +1 @@
|
||||
module.exports = __dirname;
|
||||
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@img/sharp-libvips-linux-x64",
|
||||
"version": "1.2.4",
|
||||
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (glibc) x64",
|
||||
"author": "Lovell Fuller <npm@lovell.info>",
|
||||
"homepage": "https://sharp.pixelplumbing.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
||||
"directory": "npm/linux-x64"
|
||||
},
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"preferUnplugged": true,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"versions.json"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
"./lib": "./lib/index.js",
|
||||
"./package": "./package.json",
|
||||
"./versions": "./versions.json"
|
||||
},
|
||||
"config": {
|
||||
"glibc": ">=2.26"
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"libc": [
|
||||
"glibc"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
{
|
||||
"aom": "3.13.1",
|
||||
"archive": "3.8.2",
|
||||
"cairo": "1.18.4",
|
||||
"cgif": "0.5.0",
|
||||
"exif": "0.6.25",
|
||||
"expat": "2.7.3",
|
||||
"ffi": "3.5.2",
|
||||
"fontconfig": "2.17.1",
|
||||
"freetype": "2.14.1",
|
||||
"fribidi": "1.0.16",
|
||||
"glib": "2.86.1",
|
||||
"harfbuzz": "12.1.0",
|
||||
"heif": "1.20.2",
|
||||
"highway": "1.3.0",
|
||||
"imagequant": "2.4.1",
|
||||
"lcms": "2.17",
|
||||
"mozjpeg": "0826579",
|
||||
"pango": "1.57.0",
|
||||
"pixman": "0.46.4",
|
||||
"png": "1.6.50",
|
||||
"proxy-libintl": "0.5",
|
||||
"rsvg": "2.61.2",
|
||||
"spng": "0.7.4",
|
||||
"tiff": "4.7.1",
|
||||
"vips": "8.17.3",
|
||||
"webp": "1.6.0",
|
||||
"xml2": "2.15.1",
|
||||
"zlib-ng": "2.2.5"
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
# `@img/sharp-libvips-linuxmusl-x64`
|
||||
|
||||
Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64.
|
||||
|
||||
## Licensing
|
||||
|
||||
This software contains third-party libraries
|
||||
used under the terms of the following licences:
|
||||
|
||||
| Library | Used under the terms of |
|
||||
|---------------|-----------------------------------------------------------------------------------------------------------|
|
||||
| aom | BSD 2-Clause + [Alliance for Open Media Patent License 1.0](https://aomedia.org/license/patent-license/) |
|
||||
| cairo | Mozilla Public License 2.0 |
|
||||
| cgif | MIT Licence |
|
||||
| expat | MIT Licence |
|
||||
| fontconfig | [fontconfig Licence](https://gitlab.freedesktop.org/fontconfig/fontconfig/blob/main/COPYING) (BSD-like) |
|
||||
| freetype | [freetype Licence](https://git.savannah.gnu.org/cgit/freetype/freetype2.git/tree/docs/FTL.TXT) (BSD-like) |
|
||||
| fribidi | LGPLv3 |
|
||||
| glib | LGPLv3 |
|
||||
| harfbuzz | MIT Licence |
|
||||
| highway | Apache-2.0 License, BSD 3-Clause |
|
||||
| lcms | MIT Licence |
|
||||
| libarchive | BSD 2-Clause |
|
||||
| libexif | LGPLv3 |
|
||||
| libffi | MIT Licence |
|
||||
| libheif | LGPLv3 |
|
||||
| libimagequant | [BSD 2-Clause](https://github.com/lovell/libimagequant/blob/main/COPYRIGHT) |
|
||||
| libnsgif | MIT Licence |
|
||||
| libpng | [libpng License](https://github.com/pnggroup/libpng/blob/master/LICENSE) |
|
||||
| librsvg | LGPLv3 |
|
||||
| libspng | [BSD 2-Clause, libpng License](https://github.com/randy408/libspng/blob/master/LICENSE) |
|
||||
| libtiff | [libtiff License](https://gitlab.com/libtiff/libtiff/blob/master/LICENSE.md) (BSD-like) |
|
||||
| libvips | LGPLv3 |
|
||||
| libwebp | New BSD License |
|
||||
| libxml2 | MIT Licence |
|
||||
| mozjpeg | [zlib License, IJG License, BSD-3-Clause](https://github.com/mozilla/mozjpeg/blob/master/LICENSE.md) |
|
||||
| pango | LGPLv3 |
|
||||
| pixman | MIT Licence |
|
||||
| proxy-libintl | LGPLv3 |
|
||||
| zlib-ng | [zlib Licence](https://github.com/zlib-ng/zlib-ng/blob/develop/LICENSE.md) |
|
||||
|
||||
Use of libraries under the terms of the LGPLv3 is via the
|
||||
"any later version" clause of the LGPLv2 or LGPLv2.1.
|
||||
|
||||
Please report any errors or omissions via
|
||||
https://github.com/lovell/sharp-libvips/issues/new
|
||||
221
node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h
generated
vendored
221
node_modules/@img/sharp-libvips-linuxmusl-x64/lib/glib-2.0/include/glibconfig.h
generated
vendored
@ -0,0 +1,221 @@
|
||||
/* glibconfig.h
|
||||
*
|
||||
* This is a generated file. Please modify 'glibconfig.h.in'
|
||||
*/
|
||||
|
||||
#ifndef __GLIBCONFIG_H__
|
||||
#define __GLIBCONFIG_H__
|
||||
|
||||
#include <glib/gmacros.h>
|
||||
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#define GLIB_HAVE_ALLOCA_H
|
||||
|
||||
#define GLIB_STATIC_COMPILATION 1
|
||||
#define GOBJECT_STATIC_COMPILATION 1
|
||||
#define GIO_STATIC_COMPILATION 1
|
||||
#define GMODULE_STATIC_COMPILATION 1
|
||||
#define GI_STATIC_COMPILATION 1
|
||||
#define G_INTL_STATIC_COMPILATION 1
|
||||
#define FFI_STATIC_BUILD 1
|
||||
|
||||
/* Specifies that GLib's g_print*() functions wrap the
|
||||
* system printf functions. This is useful to know, for example,
|
||||
* when using glibc's register_printf_function().
|
||||
*/
|
||||
#define GLIB_USING_SYSTEM_PRINTF
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define G_MINFLOAT FLT_MIN
|
||||
#define G_MAXFLOAT FLT_MAX
|
||||
#define G_MINDOUBLE DBL_MIN
|
||||
#define G_MAXDOUBLE DBL_MAX
|
||||
#define G_MINSHORT SHRT_MIN
|
||||
#define G_MAXSHORT SHRT_MAX
|
||||
#define G_MAXUSHORT USHRT_MAX
|
||||
#define G_MININT INT_MIN
|
||||
#define G_MAXINT INT_MAX
|
||||
#define G_MAXUINT UINT_MAX
|
||||
#define G_MINLONG LONG_MIN
|
||||
#define G_MAXLONG LONG_MAX
|
||||
#define G_MAXULONG ULONG_MAX
|
||||
|
||||
typedef signed char gint8;
|
||||
typedef unsigned char guint8;
|
||||
|
||||
typedef signed short gint16;
|
||||
typedef unsigned short guint16;
|
||||
|
||||
#define G_GINT16_MODIFIER "h"
|
||||
#define G_GINT16_FORMAT "hi"
|
||||
#define G_GUINT16_FORMAT "hu"
|
||||
|
||||
|
||||
typedef signed int gint32;
|
||||
typedef unsigned int guint32;
|
||||
|
||||
#define G_GINT32_MODIFIER ""
|
||||
#define G_GINT32_FORMAT "i"
|
||||
#define G_GUINT32_FORMAT "u"
|
||||
|
||||
|
||||
#define G_HAVE_GINT64 1 /* deprecated, always true */
|
||||
|
||||
typedef signed long gint64;
|
||||
typedef unsigned long guint64;
|
||||
|
||||
#define G_GINT64_CONSTANT(val) (val##L)
|
||||
#define G_GUINT64_CONSTANT(val) (val##UL)
|
||||
|
||||
#define G_GINT64_MODIFIER "l"
|
||||
#define G_GINT64_FORMAT "li"
|
||||
#define G_GUINT64_FORMAT "lu"
|
||||
|
||||
|
||||
#define GLIB_SIZEOF_VOID_P 8
|
||||
#define GLIB_SIZEOF_LONG 8
|
||||
#define GLIB_SIZEOF_SIZE_T 8
|
||||
#define GLIB_SIZEOF_SSIZE_T 8
|
||||
|
||||
typedef signed long gssize;
|
||||
typedef unsigned long gsize;
|
||||
#define G_GSIZE_MODIFIER "l"
|
||||
#define G_GSSIZE_MODIFIER "l"
|
||||
#define G_GSIZE_FORMAT "lu"
|
||||
#define G_GSSIZE_FORMAT "li"
|
||||
|
||||
#define G_MAXSIZE G_MAXULONG
|
||||
#define G_MINSSIZE G_MINLONG
|
||||
#define G_MAXSSIZE G_MAXLONG
|
||||
|
||||
typedef gint64 goffset;
|
||||
#define G_MINOFFSET G_MININT64
|
||||
#define G_MAXOFFSET G_MAXINT64
|
||||
|
||||
#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER
|
||||
#define G_GOFFSET_FORMAT G_GINT64_FORMAT
|
||||
#define G_GOFFSET_CONSTANT(val) G_GINT64_CONSTANT(val)
|
||||
|
||||
#define G_POLLFD_FORMAT "%d"
|
||||
|
||||
#define GPOINTER_TO_INT(p) ((gint) (glong) (p))
|
||||
#define GPOINTER_TO_UINT(p) ((guint) (gulong) (p))
|
||||
|
||||
#define GINT_TO_POINTER(i) ((gpointer) (glong) (i))
|
||||
#define GUINT_TO_POINTER(u) ((gpointer) (gulong) (u))
|
||||
|
||||
typedef signed long gintptr;
|
||||
typedef unsigned long guintptr;
|
||||
|
||||
#define G_GINTPTR_MODIFIER "l"
|
||||
#define G_GINTPTR_FORMAT "li"
|
||||
#define G_GUINTPTR_FORMAT "lu"
|
||||
|
||||
#define GLIB_MAJOR_VERSION 2
|
||||
#define GLIB_MINOR_VERSION 86
|
||||
#define GLIB_MICRO_VERSION 1
|
||||
|
||||
#define G_OS_UNIX
|
||||
|
||||
#define G_VA_COPY va_copy
|
||||
|
||||
#define G_VA_COPY_AS_ARRAY 1
|
||||
|
||||
#define G_HAVE_ISO_VARARGS 1
|
||||
|
||||
/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
|
||||
* is passed ISO vararg support is turned off, and there is no work
|
||||
* around to turn it on, so we unconditionally turn it off.
|
||||
*/
|
||||
#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
|
||||
# undef G_HAVE_ISO_VARARGS
|
||||
#endif
|
||||
|
||||
#define G_HAVE_GROWING_STACK 0
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# define G_HAVE_GNUC_VARARGS 1
|
||||
#endif
|
||||
|
||||
#if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
|
||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
|
||||
#define G_GNUC_INTERNAL __hidden
|
||||
#elif defined (__GNUC__) && defined (G_HAVE_GNUC_VISIBILITY)
|
||||
#define G_GNUC_INTERNAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define G_GNUC_INTERNAL
|
||||
#endif
|
||||
|
||||
#define G_THREADS_ENABLED
|
||||
#define G_THREADS_IMPL_POSIX
|
||||
|
||||
#define G_ATOMIC_LOCK_FREE
|
||||
|
||||
#define GINT16_TO_LE(val) ((gint16) (val))
|
||||
#define GUINT16_TO_LE(val) ((guint16) (val))
|
||||
#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
|
||||
#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
|
||||
|
||||
#define GINT32_TO_LE(val) ((gint32) (val))
|
||||
#define GUINT32_TO_LE(val) ((guint32) (val))
|
||||
#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
|
||||
#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
|
||||
|
||||
#define GINT64_TO_LE(val) ((gint64) (val))
|
||||
#define GUINT64_TO_LE(val) ((guint64) (val))
|
||||
#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
|
||||
#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
|
||||
|
||||
#define GLONG_TO_LE(val) ((glong) GINT64_TO_LE (val))
|
||||
#define GULONG_TO_LE(val) ((gulong) GUINT64_TO_LE (val))
|
||||
#define GLONG_TO_BE(val) ((glong) GINT64_TO_BE (val))
|
||||
#define GULONG_TO_BE(val) ((gulong) GUINT64_TO_BE (val))
|
||||
#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
|
||||
#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
|
||||
#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
|
||||
#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
|
||||
#define GSIZE_TO_LE(val) ((gsize) GUINT64_TO_LE (val))
|
||||
#define GSSIZE_TO_LE(val) ((gssize) GINT64_TO_LE (val))
|
||||
#define GSIZE_TO_BE(val) ((gsize) GUINT64_TO_BE (val))
|
||||
#define GSSIZE_TO_BE(val) ((gssize) GINT64_TO_BE (val))
|
||||
#define G_BYTE_ORDER G_LITTLE_ENDIAN
|
||||
|
||||
#define GLIB_SYSDEF_POLLIN =1
|
||||
#define GLIB_SYSDEF_POLLOUT =4
|
||||
#define GLIB_SYSDEF_POLLPRI =2
|
||||
#define GLIB_SYSDEF_POLLHUP =16
|
||||
#define GLIB_SYSDEF_POLLERR =8
|
||||
#define GLIB_SYSDEF_POLLNVAL =32
|
||||
|
||||
/* No way to disable deprecation warnings for macros, so only emit deprecation
|
||||
* warnings on platforms where usage of this macro is broken */
|
||||
#if defined(__APPLE__) || defined(_MSC_VER) || defined(__CYGWIN__)
|
||||
#define G_MODULE_SUFFIX "so" GLIB_DEPRECATED_MACRO_IN_2_76
|
||||
#else
|
||||
#define G_MODULE_SUFFIX "so"
|
||||
#endif
|
||||
|
||||
typedef int GPid;
|
||||
#define G_PID_FORMAT "i"
|
||||
|
||||
#define GLIB_SYSDEF_AF_UNIX 1
|
||||
#define GLIB_SYSDEF_AF_INET 2
|
||||
#define GLIB_SYSDEF_AF_INET6 10
|
||||
|
||||
#define GLIB_SYSDEF_MSG_OOB 1
|
||||
#define GLIB_SYSDEF_MSG_PEEK 2
|
||||
#define GLIB_SYSDEF_MSG_DONTROUTE 4
|
||||
|
||||
#define G_DIR_SEPARATOR '/'
|
||||
#define G_DIR_SEPARATOR_S "/"
|
||||
#define G_SEARCHPATH_SEPARATOR ':'
|
||||
#define G_SEARCHPATH_SEPARATOR_S ":"
|
||||
|
||||
#undef G_HAVE_FREE_SIZED
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GLIBCONFIG_H__ */
|
||||
@ -0,0 +1 @@
|
||||
module.exports = __dirname;
|
||||
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@img/sharp-libvips-linuxmusl-x64",
|
||||
"version": "1.2.4",
|
||||
"description": "Prebuilt libvips and dependencies for use with sharp on Linux (musl) x64",
|
||||
"author": "Lovell Fuller <npm@lovell.info>",
|
||||
"homepage": "https://sharp.pixelplumbing.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/lovell/sharp-libvips.git",
|
||||
"directory": "npm/linuxmusl-x64"
|
||||
},
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"preferUnplugged": true,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"versions.json"
|
||||
],
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
"./lib": "./lib/index.js",
|
||||
"./package": "./package.json",
|
||||
"./versions": "./versions.json"
|
||||
},
|
||||
"config": {
|
||||
"musl": ">=1.2.2"
|
||||
},
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"libc": [
|
||||
"musl"
|
||||
],
|
||||
"cpu": [
|
||||
"x64"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
{
|
||||
"aom": "3.13.1",
|
||||
"archive": "3.8.2",
|
||||
"cairo": "1.18.4",
|
||||
"cgif": "0.5.0",
|
||||
"exif": "0.6.25",
|
||||
"expat": "2.7.3",
|
||||
"ffi": "3.5.2",
|
||||
"fontconfig": "2.17.1",
|
||||
"freetype": "2.14.1",
|
||||
"fribidi": "1.0.16",
|
||||
"glib": "2.86.1",
|
||||
"harfbuzz": "12.1.0",
|
||||
"heif": "1.20.2",
|
||||
"highway": "1.3.0",
|
||||
"imagequant": "2.4.1",
|
||||
"lcms": "2.17",
|
||||
"mozjpeg": "0826579",
|
||||
"pango": "1.57.0",
|
||||
"pixman": "0.46.4",
|
||||
"png": "1.6.50",
|
||||
"proxy-libintl": "0.5",
|
||||
"rsvg": "2.61.2",
|
||||
"spng": "0.7.4",
|
||||
"tiff": "4.7.1",
|
||||
"vips": "8.17.3",
|
||||
"webp": "1.6.0",
|
||||
"xml2": "2.15.1",
|
||||
"zlib-ng": "2.2.5"
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "nudt-compiler-cpp",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
{}
|
||||
@ -0,0 +1,95 @@
|
||||
#include "irgen/IRGen.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "SysYParser.h"
|
||||
#include "utils/Log.h"
|
||||
|
||||
// 内部辅助:不依赖类成员,只需 ConstEnv。
|
||||
namespace {
|
||||
|
||||
int EvalAddExp(SysYParser::AddExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env);
|
||||
int EvalMulExp(SysYParser::MulExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env);
|
||||
int EvalUnaryExp(SysYParser::UnaryExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env);
|
||||
|
||||
int EvalPrimary(SysYParser::PrimaryExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env) {
|
||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空主表达式"));
|
||||
if (ctx->number()) {
|
||||
if (!ctx->number()->ILITERAL())
|
||||
throw std::runtime_error(
|
||||
FormatError("consteval", "constExp 不支持浮点字面量"));
|
||||
return std::stoi(ctx->number()->getText());
|
||||
}
|
||||
if (ctx->exp()) return EvalAddExp(ctx->exp()->addExp(), env);
|
||||
if (ctx->lValue()) {
|
||||
if (!ctx->lValue()->ID())
|
||||
throw std::runtime_error(FormatError("consteval", "非法 lValue"));
|
||||
const std::string name = ctx->lValue()->ID()->getText();
|
||||
auto it = env.find(name);
|
||||
if (it == env.end())
|
||||
throw std::runtime_error(
|
||||
FormatError("consteval", "constExp 引用非 const 变量: " + name));
|
||||
return it->second;
|
||||
}
|
||||
throw std::runtime_error(FormatError("consteval", "不支持的主表达式形式"));
|
||||
}
|
||||
|
||||
int EvalUnaryExp(SysYParser::UnaryExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env) {
|
||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空一元表达式"));
|
||||
if (ctx->primaryExp()) return EvalPrimary(ctx->primaryExp(), env);
|
||||
if (ctx->unaryOp() && ctx->unaryExp()) {
|
||||
int v = EvalUnaryExp(ctx->unaryExp(), env);
|
||||
if (ctx->unaryOp()->SUB()) return -v;
|
||||
if (ctx->unaryOp()->ADD()) return v;
|
||||
if (ctx->unaryOp()->NOT()) return (v == 0) ? 1 : 0;
|
||||
}
|
||||
throw std::runtime_error(
|
||||
FormatError("consteval", "函数调用不能出现在 constExp 中"));
|
||||
}
|
||||
|
||||
int EvalMulExp(SysYParser::MulExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env) {
|
||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空乘法表达式"));
|
||||
if (ctx->mulExp()) {
|
||||
int lhs = EvalMulExp(ctx->mulExp(), env);
|
||||
int rhs = EvalUnaryExp(ctx->unaryExp(), env);
|
||||
if (ctx->MUL()) return lhs * rhs;
|
||||
if (ctx->DIV()) { if (!rhs) throw std::runtime_error("除以零"); return lhs / rhs; }
|
||||
if (ctx->MOD()) { if (!rhs) throw std::runtime_error("模零"); return lhs % rhs; }
|
||||
throw std::runtime_error(FormatError("consteval", "未知乘法运算符"));
|
||||
}
|
||||
return EvalUnaryExp(ctx->unaryExp(), env);
|
||||
}
|
||||
|
||||
int EvalAddExp(SysYParser::AddExpContext* ctx,
|
||||
const IRGenImpl::ConstEnv& env) {
|
||||
if (!ctx) throw std::runtime_error(FormatError("consteval", "空加法表达式"));
|
||||
if (ctx->addExp()) {
|
||||
int lhs = EvalAddExp(ctx->addExp(), env);
|
||||
int rhs = EvalMulExp(ctx->mulExp(), env);
|
||||
if (ctx->ADD()) return lhs + rhs;
|
||||
if (ctx->SUB()) return lhs - rhs;
|
||||
throw std::runtime_error(FormatError("consteval", "未知加法运算符"));
|
||||
}
|
||||
return EvalMulExp(ctx->mulExp(), env);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int IRGenImpl::EvalConstExpr(SysYParser::ConstExpContext* ctx) const {
|
||||
if (!ctx || !ctx->addExp())
|
||||
throw std::runtime_error(FormatError("consteval", "空 constExp"));
|
||||
return EvalAddExp(ctx->addExp(), const_env_);
|
||||
}
|
||||
|
||||
int IRGenImpl::EvalExpAsConst(SysYParser::ExpContext* ctx) const {
|
||||
if (!ctx || !ctx->addExp())
|
||||
throw std::runtime_error(FormatError("consteval", "空 exp"));
|
||||
return EvalAddExp(ctx->addExp(), const_env_);
|
||||
}
|
||||
Loading…
Reference in new issue