From 3a7a3a6e9c258b41f3b0f254c02d77ea25dc4413 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 2 Mar 2021 13:55:43 +0100 Subject: [PATCH] lang: Add `dataSize` function to get size of loaded data --- plugins/builtin/source/content/lang_builtin_functions.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/builtin/source/content/lang_builtin_functions.cpp b/plugins/builtin/source/content/lang_builtin_functions.cpp index e9272fb08..53fd02a2b 100644 --- a/plugins/builtin/source/content/lang_builtin_functions.cpp +++ b/plugins/builtin/source/content/lang_builtin_functions.cpp @@ -195,6 +195,11 @@ namespace hex::plugin::builtin { return new ASTNodeIntegerLiteral({ Token::ValueType::Unsigned64Bit, u64(result) }); }); + + /* dataSize() */ + ContentRegistry::PatternLanguageFunctions::add("dataSize", ContentRegistry::PatternLanguageFunctions::NoParameters, [](auto &ctx, auto params) -> ASTNode* { + return new ASTNodeIntegerLiteral({ Token::ValueType::Unsigned64Bit, u64(SharedData::currentProvider->getActualSize()) }); + }); } } \ No newline at end of file