Website Summary Files Commits Branches @commit @diff @stats
path: root / website / content
diff options
context:
space:
mode:
Commit1f3fa95b394aade2b77b1343e87fc7b0496ddaf4 (patch)
Author
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-12-09 15:00:18 +0200
Committer
 Dimitar Trendafilov <dimitar@coherent-labs.com>
2018-12-09 15:00:18 +0200
Files99ade2b73da228a55ed963c79094a50ecaf706df /website/content
IPL-1f3fa95b394aade2b77b1343e87fc7b0496ddaf4.tar
IPL-1f3fa95b394aade2b77b1343e87fc7b0496ddaf4.tar.gz
IPL-1f3fa95b394aade2b77b1343e87fc7b0496ddaf4.zip
Parent492786a18fdc690fe2206cc18664a832ba83b8f7 (diff)
fixed for the objects slides
1 files changed, 13 insertions, 10 deletions
-rw-r--r--website/content/slides/08_vm_objects/_index.md23
diff --git a/website/content/slides/08_vm_objects/_index.md b/website/content/slides/08_vm_objects/_index.md
index fb5a220..44d43f8 100644
--- a/website/content/slides/08_vm_objects/_index.md
+++ b/website/content/slides/08_vm_objects/_index.md
@@ -34,6 +34,7 @@ JavaScript is dynamically typed, so inheritance is about properties
#### Property access
When looking-up a property in a object:
+
1. Look for the property in the object, if not found
2. Look for the property in the object's prototype, if not found
3. Look for the property in the object's prototype's prototype ...
@@ -42,7 +43,7 @@ When looking-up a property in a object:
Value GetProperty(object, name) {
Value result = object.GetProps().GetProperty(name);
- while (result == undefined || object.GetPrototype()) {
+ while (result == undefined && object.GetPrototype()) {
object = object.GetPrototype();
result = object.GetProps().GetProperty(name);
}
@@ -70,23 +71,25 @@ We need to map from string to a value.
---
### Settting a property?
-- Set on the object directly
+Set on the object directly
- void SetProperty(Object* object, StringValue* name, Value value) {
+ void SetProperty(Object* object, StringValue* name,
+ Value value)
+ {
object->GetProps().Set(name, value);
}
---
### Prototypes
-struct Object {
- Value GetProperty(StringValue* name);
- Object* GetPrototype() { return m_Prototype; }
- Properties& GetProps() { return m_OwnProps;}
+ struct Object {
+ Value GetProperty(StringValue* name);
+ Object* GetPrototype() { return m_Prototype; }
+ Properties& GetProps() { return m_OwnProps;}
- Object* m_Prototype;
- Properties m_OwnProps;
-};
+ Object* m_Prototype;
+ Properties m_OwnProps;
+ };
---
## Optimizations