Implements variable assignment evaluation

This commit is contained in:
2019-05-29 14:55:03 +02:00
parent 6185f755a4
commit f6cf4d96dd
11 changed files with 104 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ BoundScriptStatement *Binder::Bind(Script* script, ParsedScriptStatement *s, Bou
for (int i = 0; i < statements.size(); i++){
boundStatements[i] = binder.BindStatement(statements[i]);
}
return new BoundScriptStatement(boundStatements);
return new BoundScriptStatement(boundStatements, scriptScope->GetDeepestScope());
}
Binder::~Binder() {

View File

@@ -54,13 +54,19 @@ public:
};
class BoundScriptStatement : public BoundBlockStatement{
int _deepestScope;
public:
explicit BoundScriptStatement(vector<BoundStatement*> statements) : BoundBlockStatement(std::move(statements)){
explicit BoundScriptStatement(vector<BoundStatement*> statements, int deepestScope) : BoundBlockStatement(std::move(statements)){
_deepestScope = deepestScope;
}
BoundStatementKind GetKind() final{
return BoundStatementKind ::Script;
}
int GetDeepestScope(){
return _deepestScope;
}
};
class BoundExpressionStatement : public BoundStatement{
@@ -98,6 +104,14 @@ public:
BoundStatementKind GetKind() final{
return BoundStatementKind ::Assignment;
}
BoundVariableKey* GetKey(){
return _key;
}
BoundExpression* GetExpression(){
return _expression;
}
};
#endif //PORYGONLANG_BOUNDSTATEMENT_HPP

View File

@@ -28,6 +28,10 @@ public:
BoundVariable* GetVariable(int scope, int identifier);
VariableAssignment CreateExplicitLocal(int identifier, const ScriptType& type);
VariableAssignment AssignVariable(int identifier, const ScriptType& type);
int GetDeepestScope(){
return _deepestScope;
}
};