aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/craftinginterpreters/lox/LoxInstance.java
diff options
context:
space:
mode:
authorGravatar Tom Willemse2021-04-11 19:55:24 -0700
committerGravatar Tom Willemse2021-04-11 19:55:24 -0700
commit591caeb216128675ce6b8ddafccb09df7f522145 (patch)
tree1f4192ef8c820d6674e8a318fbfb82e993937aac /src/com/craftinginterpreters/lox/LoxInstance.java
parent580a5acb580a858c8ffa705f5f64f095cb0b4b37 (diff)
downloadcrafting-interpreters-591caeb216128675ce6b8ddafccb09df7f522145.tar.gz
crafting-interpreters-591caeb216128675ce6b8ddafccb09df7f522145.zip
12.4 Methods on Classes
Diffstat (limited to 'src/com/craftinginterpreters/lox/LoxInstance.java')
-rw-r--r--src/com/craftinginterpreters/lox/LoxInstance.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/com/craftinginterpreters/lox/LoxInstance.java b/src/com/craftinginterpreters/lox/LoxInstance.java
index 4e5eb9e..20accaa 100644
--- a/src/com/craftinginterpreters/lox/LoxInstance.java
+++ b/src/com/craftinginterpreters/lox/LoxInstance.java
@@ -16,6 +16,10 @@ class LoxInstance {
return fields.get(name.lexeme);
}
+ LoxFunction method = klass.findMethod(name.lexeme);
+ if (method != null)
+ return method;
+
throw new RuntimeError(name, "Undefined proprety '" + name.lexeme + "'.");
}