further Arguments optimizations
This commit is contained in:
parent
c0eba1ecf0
commit
382532e0e1
@ -74,7 +74,7 @@ data class ArgsDeclaration(val params: List<Item>, val endTokenType: Token.Type)
|
|||||||
fun processEllipsis(index: Int, toFromIndex: Int) {
|
fun processEllipsis(index: Int, toFromIndex: Int) {
|
||||||
val a = params[index]
|
val a = params[index]
|
||||||
val l = if (index > toFromIndex) ObjList()
|
val l = if (index > toFromIndex) ObjList()
|
||||||
else ObjList(fromArgs.values.subList(index, toFromIndex + 1).toMutableList())
|
else ObjList(fromArgs.list.subList(index, toFromIndex + 1).toMutableList())
|
||||||
assign(a, l)
|
assign(a, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,12 +28,8 @@ suspend fun Collection<ParsedArgument>.toArguments(context: Context): Arguments
|
|||||||
|
|
||||||
data class Arguments(val list: List<Obj>) : List<Obj> by list {
|
data class Arguments(val list: List<Obj>) : List<Obj> by list {
|
||||||
|
|
||||||
data class Info(val value: Obj, val pos: Pos)
|
fun firstAndOnly(pos: Pos = Pos.UNKNOWN): Obj {
|
||||||
|
if (list.size != 1) throw ScriptError(pos, "expected one argument, got ${list.size}")
|
||||||
val values = list
|
|
||||||
|
|
||||||
fun firstAndOnly(): Obj {
|
|
||||||
if (list.size != 1) throw IllegalArgumentException("Expected one argument, got ${list.size}")
|
|
||||||
return list.first()
|
return list.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ class Compiler(
|
|||||||
val context = closure!!.copy(pos, args)
|
val context = closure!!.copy(pos, args)
|
||||||
if (argsDeclaration == null) {
|
if (argsDeclaration == null) {
|
||||||
// no args: automatic var 'it'
|
// no args: automatic var 'it'
|
||||||
val l = args.values
|
val l = args.list
|
||||||
val itValue: Obj = when (l.size) {
|
val itValue: Obj = when (l.size) {
|
||||||
// no args: it == void
|
// no args: it == void
|
||||||
0 -> ObjVoid
|
0 -> ObjVoid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user