Uh, that's not quite what Python is doing, but...
This commit is contained in:
parent
d550c1be6b
commit
ff38f7cc61
@ -528,7 +528,13 @@ static void get_(int canAssign) {
|
||||
expression();
|
||||
emitByte(OP_INVOKE_SETSLICE);
|
||||
} else if (canAssign && matchAssignment()) {
|
||||
error("operator-assignment not supported on slice");
|
||||
/* o s e */
|
||||
emitBytes(OP_DUP, 2); /* o s e o */
|
||||
emitBytes(OP_DUP, 2); /* o s e o s */
|
||||
emitBytes(OP_DUP, 2); /* o s e o s e */
|
||||
emitByte(OP_INVOKE_GETSLICE); /* o s e v */
|
||||
assignmentValue();
|
||||
emitByte(OP_INVOKE_SETSLICE);
|
||||
} else if (inDel && matchEndOfDel()) {
|
||||
emitByte(OP_INVOKE_DELSLICE);
|
||||
inDel = 2;
|
||||
|
@ -355,6 +355,15 @@ KRK_METHOD(list,sort,{
|
||||
qsort(self->values.values, self->values.count, sizeof(KrkValue), _list_sorter);
|
||||
})
|
||||
|
||||
KRK_METHOD(list,__add__,{
|
||||
METHOD_TAKES_EXACTLY(1);
|
||||
if (!IS_list(argv[1])) return TYPE_ERROR(list,argv[1]);
|
||||
|
||||
KrkValue outList = krk_list_of(self->values.count, self->values.values); /* copy */
|
||||
FUNC_NAME(list,extend)(2,(KrkValue[]){outList,argv[1]},0); /* extend */
|
||||
return outList;
|
||||
})
|
||||
|
||||
FUNC_SIG(listiterator,__init__);
|
||||
|
||||
KRK_METHOD(list,__iter__,{
|
||||
@ -437,6 +446,7 @@ void _createAndBind_listClass(void) {
|
||||
BIND_METHOD(list,__setslice__);
|
||||
BIND_METHOD(list,__iter__);
|
||||
BIND_METHOD(list,__mul__);
|
||||
BIND_METHOD(list,__add__);
|
||||
BIND_METHOD(list,append);
|
||||
BIND_METHOD(list,extend);
|
||||
BIND_METHOD(list,pop);
|
||||
|
Loading…
Reference in New Issue
Block a user