pattern: Added dollar operator assignment
This commit is contained in:
parent
48de158d7c
commit
a0a39f1c04
@ -2115,11 +2115,20 @@ namespace hex::pl {
|
||||
return this->m_rvalue;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::vector<PatternData *> createPatterns(Evaluator *evaluator) const override {
|
||||
this->execute(evaluator);
|
||||
|
||||
return { };
|
||||
}
|
||||
|
||||
FunctionResult execute(Evaluator *evaluator) const override {
|
||||
auto literal = dynamic_cast<ASTNodeLiteral *>(this->getRValue()->evaluate(evaluator));
|
||||
ON_SCOPE_EXIT { delete literal; };
|
||||
|
||||
evaluator->setVariable(this->getLValueName(), literal->getValue());
|
||||
if (this->getLValueName() == "$")
|
||||
evaluator->dataOffset() = Token::literalToUnsigned(literal->getValue());
|
||||
else
|
||||
evaluator->setVariable(this->getLValueName(), literal->getValue());
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -491,6 +491,8 @@ namespace hex::pl {
|
||||
|
||||
if (MATCHES(sequence(IDENTIFIER, OPERATOR_ASSIGNMENT)))
|
||||
statement = parseFunctionVariableAssignment();
|
||||
else if (MATCHES(sequence(OPERATOR_DOLLAR, OPERATOR_ASSIGNMENT)))
|
||||
statement = create(new ASTNodeAssignment("$", parseMathematicalExpression()));
|
||||
else if (MATCHES(oneOf(KEYWORD_RETURN, KEYWORD_BREAK, KEYWORD_CONTINUE)))
|
||||
statement = parseFunctionControlFlowStatement();
|
||||
else if (MATCHES(sequence(KEYWORD_IF, SEPARATOR_ROUNDBRACKETOPEN))) {
|
||||
@ -877,6 +879,8 @@ namespace hex::pl {
|
||||
member = new ASTNodeControlFlowStatement(ControlFlowStatement::Break, nullptr);
|
||||
else if (MATCHES(sequence(KEYWORD_CONTINUE)))
|
||||
member = new ASTNodeControlFlowStatement(ControlFlowStatement::Continue, nullptr);
|
||||
else if (MATCHES(sequence(OPERATOR_DOLLAR, OPERATOR_ASSIGNMENT)))
|
||||
member = create(new ASTNodeAssignment("$", parseMathematicalExpression()));
|
||||
else
|
||||
throwParseError("invalid struct member", 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user