-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marking TODOs for metaobject handling
- Loading branch information
AdrianTodt
committed
Sep 12, 2022
1 parent
cd50eb3
commit c7ce2ef
Showing
2 changed files
with
75 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
src/commonMain/kotlin/net/adriantodt/leanvm/runtimes/functions/FnCreateMetaObject.kt
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,31 @@ | ||
package net.adriantodt.leanvm.runtimes.functions | ||
|
||
import net.adriantodt.leanvm.types.LAny | ||
import net.adriantodt.leanvm.types.LNativeFunction | ||
import net.adriantodt.leanvm.types.LObject | ||
|
||
internal object FnCreateMetaObject : LNativeFunction("createMetaObject") { | ||
override fun run(thisValue: LAny?, args: List<LAny>): LAny { | ||
val value = if (thisValue != null) { | ||
// Called as an extension function. | ||
if (args.isNotEmpty()) { | ||
throw IllegalArgumentException("createMetaObject() takes no arguments.") | ||
} else { | ||
thisValue | ||
} | ||
} else { | ||
// Called as a static function. | ||
if (args.size != 1) { | ||
throw IllegalArgumentException("createMetaObject() takes exactly one argument.") | ||
} else { | ||
args[0] | ||
} | ||
} | ||
|
||
if (value !is LObject) { | ||
throw IllegalArgumentException("createMetaObject() can only be called on objects.") | ||
} | ||
|
||
TODO("Implement meta objects") | ||
} | ||
} |