Renamed to blob

This commit is contained in:
Rafał Grodziński
2025-08-05 12:45:44 +09:00
parent 0a08aaa7b2
commit 5e65c66d3a
10 changed files with 35 additions and 36 deletions

View File

@@ -16,7 +16,7 @@
#include "Parser/Statement/StatementFunction.h" #include "Parser/Statement/StatementFunction.h"
#include "Parser/Statement/StatementRawFunction.h" #include "Parser/Statement/StatementRawFunction.h"
#include "Parser/Statement/StatementType.h" #include "Parser/Statement/StatementBlob.h"
#include "Parser/Statement/StatementVariable.h" #include "Parser/Statement/StatementVariable.h"
#include "Parser/Statement/StatementAssignment.h" #include "Parser/Statement/StatementAssignment.h"
#include "Parser/Statement/StatementReturn.h" #include "Parser/Statement/StatementReturn.h"
@@ -69,8 +69,8 @@ void ModuleBuilder::buildStatement(shared_ptr<Statement> statement) {
case StatementKind::RAW_FUNCTION: case StatementKind::RAW_FUNCTION:
buildRawFunction(dynamic_pointer_cast<StatementRawFunction>(statement)); buildRawFunction(dynamic_pointer_cast<StatementRawFunction>(statement));
break; break;
case StatementKind::TYPE: case StatementKind::BLOB:
buildType(dynamic_pointer_cast<StatementType>(statement)); buildType(dynamic_pointer_cast<StatementBlob>(statement));
break; break;
case StatementKind::VARIABLE: case StatementKind::VARIABLE:
buildVarDeclaration(dynamic_pointer_cast<StatementVariable>(statement)); buildVarDeclaration(dynamic_pointer_cast<StatementVariable>(statement));
@@ -164,7 +164,7 @@ void ModuleBuilder::buildRawFunction(shared_ptr<StatementRawFunction> statement)
return; return;
} }
void ModuleBuilder::buildType(shared_ptr<StatementType> statement) { void ModuleBuilder::buildType(shared_ptr<StatementBlob> statement) {
llvm::StructType *structType = llvm::StructType::create(*context, statement->getIdentifier()); llvm::StructType *structType = llvm::StructType::create(*context, statement->getIdentifier());
vector<llvm::Type *> elements; vector<llvm::Type *> elements;
structType->setBody(elements, false); structType->setBody(elements, false);

View File

@@ -29,7 +29,7 @@ enum class ExpressionBinaryOperation;
class Statement; class Statement;
class StatementFunction; class StatementFunction;
class StatementRawFunction; class StatementRawFunction;
class StatementType; class StatementBlob;
class StatementVariable; class StatementVariable;
class StatementAssignment; class StatementAssignment;
class StatementReturn; class StatementReturn;
@@ -71,7 +71,7 @@ private:
void buildStatement(shared_ptr<Statement> statement); void buildStatement(shared_ptr<Statement> statement);
void buildFunction(shared_ptr<StatementFunction> statement); void buildFunction(shared_ptr<StatementFunction> statement);
void buildRawFunction(shared_ptr<StatementRawFunction> statement); void buildRawFunction(shared_ptr<StatementRawFunction> statement);
void buildType(shared_ptr<StatementType> statement); void buildType(shared_ptr<StatementBlob> statement);
void buildVarDeclaration(shared_ptr<StatementVariable> statement); void buildVarDeclaration(shared_ptr<StatementVariable> statement);
void buildAssignment(shared_ptr<StatementAssignment> statement); void buildAssignment(shared_ptr<StatementAssignment> statement);
void buildBlock(shared_ptr<StatementBlock> statement); void buildBlock(shared_ptr<StatementBlock> statement);

View File

@@ -12,7 +12,7 @@
#include "Parser/Statement/StatementVariable.h" #include "Parser/Statement/StatementVariable.h"
#include "Parser/Statement/StatementFunction.h" #include "Parser/Statement/StatementFunction.h"
#include "Parser/Statement/StatementRawFunction.h" #include "Parser/Statement/StatementRawFunction.h"
#include "Parser/Statement/StatementType.h" #include "Parser/Statement/StatementBlob.h"
#include "Parser/Statement/StatementBlock.h" #include "Parser/Statement/StatementBlock.h"
#include "Parser/Statement/StatementAssignment.h" #include "Parser/Statement/StatementAssignment.h"
#include "Parser/Statement/StatementReturn.h" #include "Parser/Statement/StatementReturn.h"
@@ -241,8 +241,8 @@ string Logger::toString(shared_ptr<Statement> statement) {
return toString(dynamic_pointer_cast<StatementFunction>(statement)); return toString(dynamic_pointer_cast<StatementFunction>(statement));
case StatementKind::RAW_FUNCTION: case StatementKind::RAW_FUNCTION:
return toString(dynamic_pointer_cast<StatementRawFunction>(statement)); return toString(dynamic_pointer_cast<StatementRawFunction>(statement));
case StatementKind::TYPE: case StatementKind::BLOB:
return toString(dynamic_pointer_cast<StatementType>(statement)); return toString(dynamic_pointer_cast<StatementBlob>(statement));
case StatementKind::BLOCK: case StatementKind::BLOCK:
return toString(dynamic_pointer_cast<StatementBlock>(statement)); return toString(dynamic_pointer_cast<StatementBlock>(statement));
case StatementKind::ASSIGNMENT: case StatementKind::ASSIGNMENT:
@@ -303,10 +303,10 @@ string Logger::toString(shared_ptr<StatementRawFunction> statement) {
return text; return text;
} }
string Logger::toString(shared_ptr<StatementType> statement) { string Logger::toString(shared_ptr<StatementBlob> statement) {
string text; string text;
text += format("TYPE(\"{}\"):\n", statement->getIdentifier()); text += format("BLOB(\"{}\"):\n", statement->getIdentifier());
return text; return text;
} }

View File

@@ -12,7 +12,7 @@ class StatementMetaExternFunction;
class StatementVariable; class StatementVariable;
class StatementFunction; class StatementFunction;
class StatementRawFunction; class StatementRawFunction;
class StatementType; class StatementBlob;
class StatementBlock; class StatementBlock;
class StatementAssignment; class StatementAssignment;
class StatementReturn; class StatementReturn;
@@ -45,7 +45,7 @@ private:
static string toString(shared_ptr<StatementVariable> statement); static string toString(shared_ptr<StatementVariable> statement);
static string toString(shared_ptr<StatementFunction> statement); static string toString(shared_ptr<StatementFunction> statement);
static string toString(shared_ptr<StatementRawFunction> statement); static string toString(shared_ptr<StatementRawFunction> statement);
static string toString(shared_ptr<StatementType> statement); static string toString(shared_ptr<StatementBlob> statement);
static string toString(shared_ptr<StatementBlock> statement); static string toString(shared_ptr<StatementBlock> statement);
static string toString(shared_ptr<StatementAssignment> statement); static string toString(shared_ptr<StatementAssignment> statement);
static string toString(shared_ptr<StatementReturn> statement); static string toString(shared_ptr<StatementReturn> statement);

View File

@@ -18,7 +18,7 @@
#include "Parser/Statement/StatementFunction.h" #include "Parser/Statement/StatementFunction.h"
#include "Parser/Statement/StatementRawFunction.h" #include "Parser/Statement/StatementRawFunction.h"
#include "Parser/Statement/StatementType.h" #include "Parser/Statement/StatementBlob.h"
#include "Parser/Statement/StatementVariable.h" #include "Parser/Statement/StatementVariable.h"
#include "Parser/Statement/StatementAssignment.h" #include "Parser/Statement/StatementAssignment.h"
#include "Parser/Statement/StatementReturn.h" #include "Parser/Statement/StatementReturn.h"
@@ -81,7 +81,7 @@ shared_ptr<Statement> Parser::nextStatement() {
if (statement != nullptr || errors.size() > errorsCount) if (statement != nullptr || errors.size() > errorsCount)
return statement; return statement;
statement = matchStatementType(); statement = matchStatementBlob();
if (statement != nullptr || errors.size() > errorsCount) if (statement != nullptr || errors.size() > errorsCount)
return statement; return statement;
@@ -491,7 +491,7 @@ shared_ptr<Statement> Parser::matchStatementRawFunction() {
return make_shared<StatementRawFunction>(name, constraints, arguments, returnType, rawSource); return make_shared<StatementRawFunction>(name, constraints, arguments, returnType, rawSource);
} }
shared_ptr<Statement> Parser::matchStatementType() { shared_ptr<Statement> Parser::matchStatementBlob() {
ParseeResultsGroup resultsGroup; ParseeResultsGroup resultsGroup;
string identifier; string identifier;
@@ -535,7 +535,7 @@ shared_ptr<Statement> Parser::matchStatementType() {
return nullptr; return nullptr;
} }
return make_shared<StatementType>(identifier, variables); return make_shared<StatementBlob>(identifier, variables);
} }
shared_ptr<Statement> Parser::matchStatementBlock(vector<TokenKind> terminalTokenKinds) { shared_ptr<Statement> Parser::matchStatementBlock(vector<TokenKind> terminalTokenKinds) {

View File

@@ -31,7 +31,7 @@ private:
shared_ptr<Statement> matchStatementVariable(); shared_ptr<Statement> matchStatementVariable();
shared_ptr<Statement> matchStatementFunction(); shared_ptr<Statement> matchStatementFunction();
shared_ptr<Statement> matchStatementRawFunction(); shared_ptr<Statement> matchStatementRawFunction();
shared_ptr<Statement> matchStatementType(); shared_ptr<Statement> matchStatementBlob();
shared_ptr<Statement> matchStatementBlock(vector<TokenKind> terminalTokenKinds); shared_ptr<Statement> matchStatementBlock(vector<TokenKind> terminalTokenKinds);
shared_ptr<Statement> matchStatementAssignment(); shared_ptr<Statement> matchStatementAssignment();

View File

@@ -15,7 +15,7 @@ enum class StatementKind {
ASSIGNMENT, ASSIGNMENT,
REPEAT, REPEAT,
META_EXTERN_FUNCTION, META_EXTERN_FUNCTION,
TYPE BLOB
}; };
class Statement { class Statement {

View File

@@ -0,0 +1,14 @@
#include "StatementBlob.h"
#include "Parser/ValueType.h"
StatementBlob::StatementBlob(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables):
Statement(StatementKind::BLOB), identifier(identifier), variables(variables) { }
string StatementBlob::getIdentifier() {
return identifier;
}
vector<pair<string, shared_ptr<ValueType>>> StatementBlob::getVariables() {
return variables;
}

View File

@@ -3,16 +3,15 @@
#include "Statement.h" #include "Statement.h"
class StatementVariable;
class ValueType; class ValueType;
class StatementType: public Statement { class StatementBlob: public Statement {
private: private:
string identifier; string identifier;
vector<pair<string, shared_ptr<ValueType>>> variables; vector<pair<string, shared_ptr<ValueType>>> variables;
public: public:
StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables); StatementBlob(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables);
string getIdentifier(); string getIdentifier();
vector<pair<string, shared_ptr<ValueType>>> getVariables(); vector<pair<string, shared_ptr<ValueType>>> getVariables();
}; };

View File

@@ -1,14 +0,0 @@
#include "StatementType.h"
#include "Parser/ValueType.h"
StatementType::StatementType(string identifier, vector<pair<string, shared_ptr<ValueType>>> variables):
Statement(StatementKind::TYPE), identifier(identifier), variables(variables) { }
string StatementType::getIdentifier() {
return identifier;
}
vector<pair<string, shared_ptr<ValueType>>> StatementType::getVariables() {
return variables;
}