summaryrefslogtreecommitdiffstats
path: root/src/scopes.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2012-03-05 14:35:55 +0000
committerBen Murdoch <benm@google.com>2012-04-11 15:40:15 +0100
commitc7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9 (patch)
tree6f84ef396408af3c9f08eaac783ecf1a957b0fee /src/scopes.cc
parent592a9fc1d8ea420377a2e7efd0600e20b058be2b (diff)
downloadandroid_external_v8-c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9.tar.gz
android_external_v8-c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9.tar.bz2
android_external_v8-c7cc028aaeedbbfa11c11d0b7b243b3d9e837ed9.zip
Merge V8 at 3.8.9.11
Bug: 5688872 Change-Id: Ie3b1dd67a730ec5e82686b7b37dba26f6a9bb24f
Diffstat (limited to 'src/scopes.cc')
-rw-r--r--src/scopes.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/scopes.cc b/src/scopes.cc
index ad8b6a5e..a7ff2878 100644
--- a/src/scopes.cc
+++ b/src/scopes.cc
@@ -31,6 +31,7 @@
#include "bootstrapper.h"
#include "compiler.h"
+#include "messages.h"
#include "scopeinfo.h"
#include "allocation-inl.h"
@@ -282,8 +283,25 @@ bool Scope::Analyze(CompilationInfo* info) {
}
#endif
+ if (FLAG_harmony_scoping) {
+ VariableProxy* proxy = scope->CheckAssignmentToConst();
+ if (proxy != NULL) {
+ // Found an assignment to const. Throw a syntax error.
+ MessageLocation location(info->script(),
+ proxy->position(),
+ proxy->position());
+ Isolate* isolate = info->isolate();
+ Factory* factory = isolate->factory();
+ Handle<JSArray> array = factory->NewJSArray(0);
+ Handle<Object> result =
+ factory->NewSyntaxError("harmony_const_assign", array);
+ isolate->Throw(*result, &location);
+ return false;
+ }
+ }
+
info->SetScope(scope);
- return true; // Can not fail.
+ return true;
}
@@ -552,6 +570,29 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
}
+VariableProxy* Scope::CheckAssignmentToConst() {
+ // Check this scope.
+ if (is_extended_mode()) {
+ for (int i = 0; i < unresolved_.length(); i++) {
+ ASSERT(unresolved_[i]->var() != NULL);
+ if (unresolved_[i]->var()->is_const_mode() &&
+ unresolved_[i]->IsLValue()) {
+ return unresolved_[i];
+ }
+ }
+ }
+
+ // Check inner scopes.
+ for (int i = 0; i < inner_scopes_.length(); i++) {
+ VariableProxy* proxy = inner_scopes_[i]->CheckAssignmentToConst();
+ if (proxy != NULL) return proxy;
+ }
+
+ // No assignments to const found.
+ return NULL;
+}
+
+
void Scope::CollectStackAndContextLocals(ZoneList<Variable*>* stack_locals,
ZoneList<Variable*>* context_locals) {
ASSERT(stack_locals != NULL);