-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Object a common superclass of all classes.
- Loading branch information
Showing
14 changed files
with
243 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ffle/part_13/nodes/exprs/functions/built_in/methods/HasOwnPropertyMethodBodyExprNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.endoflineblog.truffle.part_13.nodes.exprs.functions.built_in.methods; | ||
|
||
import com.endoflineblog.truffle.part_13.nodes.exprs.functions.built_in.BuiltInFunctionBodyExprNode; | ||
import com.endoflineblog.truffle.part_13.nodes.exprs.strings.ReadTruffleStringPropertyNode; | ||
import com.endoflineblog.truffle.part_13.runtime.EasyScriptTruffleStrings; | ||
import com.oracle.truffle.api.dsl.Fallback; | ||
import com.oracle.truffle.api.dsl.Specialization; | ||
import com.oracle.truffle.api.library.CachedLibrary; | ||
import com.oracle.truffle.api.object.DynamicObject; | ||
import com.oracle.truffle.api.object.DynamicObjectLibrary; | ||
import com.oracle.truffle.api.strings.TruffleString; | ||
|
||
public abstract class HasOwnPropertyMethodBodyExprNode extends BuiltInFunctionBodyExprNode { | ||
@Specialization(limit = "2") | ||
protected boolean hasOwnPropertyDynamicObject( | ||
DynamicObject self, Object property, | ||
@CachedLibrary("self") DynamicObjectLibrary dynamicObjectLibrary) { | ||
return dynamicObjectLibrary.containsKey(self, EasyScriptTruffleStrings.toString(property)); | ||
} | ||
|
||
@Specialization | ||
protected boolean hasOwnPropertyTruffleString( | ||
@SuppressWarnings("unused") TruffleString self, | ||
Object property) { | ||
// strings only have the 'length' property | ||
return ReadTruffleStringPropertyNode.LENGTH_PROP.equals(EasyScriptTruffleStrings.toString(property)); | ||
} | ||
|
||
@Fallback | ||
protected boolean hasOwnPropertyPrimitive( | ||
@SuppressWarnings("unused") Object self, | ||
@SuppressWarnings("unused") Object property) { | ||
// primitives don't own any properties | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.