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) {
|
||||
val a = params[index]
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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 Info(val value: Obj, val pos: Pos)
|
||||
|
||||
val values = list
|
||||
|
||||
fun firstAndOnly(): Obj {
|
||||
if (list.size != 1) throw IllegalArgumentException("Expected one argument, got ${list.size}")
|
||||
fun firstAndOnly(pos: Pos = Pos.UNKNOWN): Obj {
|
||||
if (list.size != 1) throw ScriptError(pos, "expected one argument, got ${list.size}")
|
||||
return list.first()
|
||||
}
|
||||
|
||||
|
@ -379,7 +379,7 @@ class Compiler(
|
||||
val context = closure!!.copy(pos, args)
|
||||
if (argsDeclaration == null) {
|
||||
// no args: automatic var 'it'
|
||||
val l = args.values
|
||||
val l = args.list
|
||||
val itValue: Obj = when (l.size) {
|
||||
// no args: it == void
|
||||
0 -> ObjVoid
|
||||
|
Loading…
x
Reference in New Issue
Block a user