Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Unified Diff: runtime/vm/kernel_to_il.h

Issue 2659363003: VM: [Kernel] Partial support for checked mode. (Closed)
Patch Set: Renamed Maybe* -> *InCheckedMode Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/kernel_to_il.h
diff --git a/runtime/vm/kernel_to_il.h b/runtime/vm/kernel_to_il.h
index 1f374f5aa453e6f085a97a1c150853a70f9c73ca..211a61b029c1c2bcb95dbd333bee407bf1cb6bba 100644
--- a/runtime/vm/kernel_to_il.h
+++ b/runtime/vm/kernel_to_il.h
@@ -474,6 +474,18 @@ class ConstantEvaluator : public ExpressionVisitor {
const Function& constructor,
const Object& argument);
+ void AssertBoolInCheckedMode() {
+ if (isolate_->type_checks() && !result_.IsBool()) {
+ translation_helper_.ReportError("Expected boolean expression.");
+ }
+ }
+
+ bool EvaluateBooleanExpression(Expression* expression) {
+ EvaluateExpression(expression);
+ AssertBoolInCheckedMode();
+ return result_.raw() == Bool::True().raw();
+ }
+
// TODO(27590): Instead of using [dart::kernel::TreeNode]s as keys we
// should use [TokenPosition]s as well as the existing functionality in
// `Parser::CacheConstantValue`.
@@ -628,7 +640,6 @@ class ScopeBuilder : public RecursiveVisitor {
void LookupCapturedVariableByName(LocalVariable** variable,
const dart::String& name);
-
struct DepthState {
explicit DepthState(intptr_t function)
: loop_(0),
@@ -868,6 +879,17 @@ class FlowGraphBuilder : public ExpressionVisitor, public StatementVisitor {
Fragment GuardFieldLength(const dart::Field& field, intptr_t deopt_id);
Fragment GuardFieldClass(const dart::Field& field, intptr_t deopt_id);
+ Fragment EvaluateAssertion();
+ Fragment CheckReturnTypeInCheckedMode();
+ Fragment CheckVariableTypeInCheckedMode(VariableDeclaration* variable);
+ Fragment CheckBooleanInCheckedMode();
+ Fragment CheckAssignableInCheckedMode(const dart::AbstractType& dst_type,
+ const dart::String& dst_name);
+
+ Fragment AssertBool();
+ Fragment AssertAssignable(const dart::AbstractType& dst_type,
+ const dart::String& dst_name);
+
dart::RawFunction* LookupMethodByMember(Member* target,
const dart::String& method_name);
« no previous file with comments | « no previous file | runtime/vm/kernel_to_il.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698