Some more objects
This commit is contained in:
parent
66533d5c23
commit
fb9d0163ef
195
builtins.c
195
builtins.c
@ -29,111 +29,92 @@ const char _builtins_src[] = {
|
||||
0x5d,0x29,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,0x6e,0x72,0x65,
|
||||
0x70,0x72,0x3d,0x30,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x62,0x2b,
|
||||
0x22,0x5d,0x22,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x69,0x74,0x65,0x72,0x5f,
|
||||
0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x78,
|
||||
0x3d,0x30,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x6c,0x3d,0x73,0x65,0x6c,0x66,0x2e,
|
||||
0x5f,0x5f,0x6c,0x65,0x6e,0x5f,0x5f,0x28,0x29,0x0a,0x20,0x20,0x64,0x65,0x66,0x20,
|
||||
0x5f,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x69,0x66,0x20,0x78,0x3e,0x3d,0x6c,0x3a,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,0x20,0x20,
|
||||
0x20,0x6c,0x65,0x74,0x20,0x6f,0x3d,0x73,0x65,0x6c,0x66,0x5b,0x78,0x5d,0x0a,0x20,
|
||||
0x20,0x20,0x78,0x2b,0x2b,0x0a,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,
|
||||
0x6f,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,0x0a,0x63,0x6c,
|
||||
0x61,0x73,0x73,0x20,0x64,0x69,0x63,0x74,0x28,0x29,0x3a,0x0a,0x20,0x22,0x48,0x61,
|
||||
0x73,0x68,0x6d,0x61,0x70,0x20,0x6f,0x66,0x20,0x61,0x72,0x62,0x69,0x74,0x72,0x61,
|
||||
0x72,0x79,0x20,0x6b,0x65,0x79,0x73,0x20,0x74,0x6f,0x20,0x61,0x72,0x62,0x69,0x74,
|
||||
0x72,0x61,0x72,0x79,0x20,0x76,0x61,0x6c,0x75,0x65,0x73,0x2e,0x22,0x0a,0x20,0x64,
|
||||
0x65,0x66,0x20,0x5f,0x5f,0x73,0x74,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,
|
||||
0x3a,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,
|
||||
0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x29,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,
|
||||
0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,
|
||||
0x69,0x66,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,0x6e,0x72,0x65,0x70,0x72,
|
||||
0x3a,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x22,0x7b,0x2e,0x2e,0x2e,0x7d,0x22,
|
||||
0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,0x6e,0x72,0x65,0x70,0x72,
|
||||
0x20,0x3d,0x20,0x31,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x6f,0x75,0x74,0x20,0x3d,
|
||||
0x20,0x22,0x7b,0x22,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x66,0x69,0x72,0x73,0x74,
|
||||
0x20,0x3d,0x20,0x54,0x72,0x75,0x65,0x0a,0x20,0x20,0x66,0x6f,0x72,0x20,0x76,0x20,
|
||||
0x69,0x6e,0x20,0x73,0x65,0x6c,0x66,0x2e,0x6b,0x65,0x79,0x73,0x28,0x29,0x3a,0x0a,
|
||||
0x20,0x20,0x20,0x69,0x66,0x20,0x6e,0x6f,0x74,0x20,0x66,0x69,0x72,0x73,0x74,0x3a,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x20,0x2b,0x3d,0x20,0x22,0x2c,0x20,0x22,
|
||||
0x0a,0x20,0x20,0x20,0x66,0x69,0x72,0x73,0x74,0x20,0x3d,0x20,0x46,0x61,0x6c,0x73,
|
||||
0x65,0x0a,0x20,0x20,0x20,0x6f,0x75,0x74,0x20,0x2b,0x3d,0x20,0x76,0x2e,0x5f,0x5f,
|
||||
0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x29,0x20,0x2b,0x20,0x22,0x3a,0x20,0x22,0x20,
|
||||
0x2b,0x20,0x73,0x65,0x6c,0x66,0x5b,0x76,0x5d,0x2e,0x5f,0x5f,0x72,0x65,0x70,0x72,
|
||||
0x5f,0x5f,0x28,0x29,0x0a,0x20,0x20,0x6f,0x75,0x74,0x20,0x2b,0x3d,0x20,0x22,0x7d,
|
||||
0x22,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,0x6e,0x72,0x65,0x70,
|
||||
0x72,0x20,0x3d,0x20,0x30,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,
|
||||
0x75,0x74,0x0a,0x20,0x64,0x65,0x66,0x20,0x6b,0x65,0x79,0x73,0x28,0x73,0x65,0x6c,
|
||||
0x66,0x29,0x3a,0x0a,0x20,0x20,0x22,0x52,0x65,0x74,0x75,0x72,0x6e,0x73,0x20,0x61,
|
||||
0x6e,0x20,0x69,0x74,0x65,0x72,0x61,0x62,0x6c,0x65,0x20,0x6f,0x66,0x20,0x74,0x68,
|
||||
0x65,0x20,0x6b,0x65,0x79,0x73,0x20,0x69,0x6e,0x20,0x74,0x68,0x69,0x73,0x20,0x64,
|
||||
0x69,0x63,0x74,0x69,0x6f,0x6e,0x61,0x72,0x79,0x2e,0x22,0x0a,0x20,0x20,0x63,0x6c,
|
||||
0x61,0x73,0x73,0x20,0x4b,0x65,0x79,0x49,0x74,0x65,0x72,0x61,0x74,0x6f,0x72,0x28,
|
||||
0x29,0x3a,0x0a,0x20,0x20,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x69,0x6e,0x69,0x74,
|
||||
0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x2c,0x74,0x29,0x3a,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x73,0x65,0x6c,0x66,0x2e,0x74,0x3d,0x74,0x0a,0x20,0x20,0x20,0x64,0x65,0x66,0x20,
|
||||
0x5f,0x5f,0x69,0x74,0x65,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x6c,0x65,0x74,0x20,0x69,0x3d,0x30,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x6c,0x65,0x74,0x20,0x63,0x3d,0x73,0x65,0x6c,0x66,0x2e,0x74,0x2e,0x63,0x61,0x70,
|
||||
0x61,0x63,0x69,0x74,0x79,0x28,0x29,0x0a,0x20,0x20,0x20,0x20,0x64,0x65,0x66,0x20,
|
||||
0x5f,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x6c,0x65,0x74,0x20,0x6f,0x3d,
|
||||
0x4e,0x6f,0x6e,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x77,0x68,0x69,0x6c,0x65,0x20,
|
||||
0x6f,0x3d,0x3d,0x4e,0x6f,0x6e,0x65,0x20,0x61,0x6e,0x64,0x20,0x69,0x3c,0x63,0x3a,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x3d,0x73,0x65,0x6c,0x66,0x2e,0x74,0x2e,
|
||||
0x5f,0x6b,0x65,0x79,0x5f,0x61,0x74,0x5f,0x69,0x6e,0x64,0x65,0x78,0x28,0x69,0x29,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x2b,0x2b,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x69,0x66,0x20,0x6f,0x3d,0x3d,0x4e,0x6f,0x6e,0x65,0x3a,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,0x20,0x20,0x20,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,
|
||||
0x75,0x72,0x6e,0x20,0x5f,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x4b,
|
||||
0x65,0x79,0x49,0x74,0x65,0x72,0x61,0x74,0x6f,0x72,0x28,0x73,0x65,0x6c,0x66,0x29,
|
||||
0x0a,0x0a,0x63,0x6c,0x61,0x73,0x73,0x20,0x72,0x61,0x6e,0x67,0x65,0x3a,0x0a,0x20,
|
||||
0x22,0x48,0x65,0x6c,0x70,0x66,0x75,0x6c,0x20,0x69,0x74,0x65,0x72,0x61,0x62,0x6c,
|
||||
0x65,0x2e,0x22,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x69,0x6e,0x69,0x74,0x5f,
|
||||
0x5f,0x28,0x73,0x65,0x6c,0x66,0x2c,0x20,0x6d,0x69,0x6e,0x2c,0x20,0x6d,0x61,0x78,
|
||||
0x29,0x3a,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x6d,0x69,0x6e,0x20,0x3d,0x20,
|
||||
0x6d,0x69,0x6e,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x6d,0x61,0x78,0x20,0x3d,
|
||||
0x20,0x6d,0x61,0x78,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x69,0x74,0x65,0x72,
|
||||
0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,
|
||||
0x69,0x3d,0x73,0x65,0x6c,0x66,0x2e,0x6d,0x69,0x6e,0x0a,0x20,0x20,0x6c,0x65,0x74,
|
||||
0x20,0x6c,0x3d,0x73,0x65,0x6c,0x66,0x2e,0x6d,0x61,0x78,0x0a,0x20,0x20,0x64,0x65,
|
||||
0x66,0x20,0x5f,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x69,0x66,0x20,0x69,0x3e,0x3d,
|
||||
0x6c,0x3a,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,
|
||||
0x20,0x20,0x20,0x6c,0x65,0x74,0x20,0x6f,0x3d,0x69,0x0a,0x20,0x20,0x20,0x69,0x2b,
|
||||
0x2b,0x0a,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x0a,0x20,0x20,
|
||||
0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,0x0a,0x63,0x6c,0x61,0x73,0x73,0x20,
|
||||
0x48,0x65,0x6c,0x70,0x65,0x72,0x28,0x29,0x3a,0x0a,0x20,0x27,0x27,0x27,0x59,0x6f,
|
||||
0x75,0x20,0x73,0x65,0x65,0x6d,0x20,0x74,0x6f,0x20,0x61,0x6c,0x72,0x65,0x61,0x64,
|
||||
0x79,0x20,0x6b,0x6e,0x6f,0x77,0x20,0x68,0x6f,0x77,0x20,0x74,0x6f,0x20,0x75,0x73,
|
||||
0x65,0x20,0x74,0x68,0x69,0x73,0x2e,0x27,0x27,0x27,0x0a,0x20,0x64,0x65,0x66,0x20,
|
||||
0x5f,0x5f,0x63,0x61,0x6c,0x6c,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x2c,0x6f,0x62,
|
||||
0x6a,0x3d,0x4e,0x6f,0x6e,0x65,0x29,0x3a,0x0a,0x20,0x20,0x69,0x66,0x20,0x6f,0x62,
|
||||
0x6a,0x3a,0x0a,0x20,0x20,0x20,0x74,0x72,0x79,0x3a,0x0a,0x20,0x20,0x20,0x20,0x70,
|
||||
0x72,0x69,0x6e,0x74,0x20,0x6f,0x62,0x6a,0x2e,0x5f,0x5f,0x64,0x6f,0x63,0x5f,0x5f,
|
||||
0x0a,0x20,0x20,0x20,0x65,0x78,0x63,0x65,0x70,0x74,0x3a,0x0a,0x20,0x20,0x20,0x20,
|
||||
0x74,0x72,0x79,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,
|
||||
0x6f,0x62,0x6a,0x2e,0x5f,0x5f,0x63,0x6c,0x61,0x73,0x73,0x5f,0x5f,0x2e,0x5f,0x5f,
|
||||
0x64,0x6f,0x63,0x5f,0x5f,0x0a,0x20,0x20,0x20,0x20,0x65,0x78,0x63,0x65,0x70,0x74,
|
||||
0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,0x22,0x4e,0x6f,
|
||||
0x20,0x64,0x6f,0x63,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x61,0x76,0x61,0x69,0x61,
|
||||
0x6c,0x62,0x6c,0x65,0x20,0x66,0x6f,0x72,0x22,0x2c,0x20,0x6f,0x62,0x6a,0x0a,0x20,
|
||||
0x20,0x65,0x6c,0x73,0x65,0x3a,0x0a,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,
|
||||
0x22,0x28,0x49,0x6e,0x74,0x65,0x72,0x61,0x63,0x74,0x69,0x76,0x65,0x20,0x68,0x65,
|
||||
0x6c,0x70,0x20,0x69,0x73,0x20,0x6e,0x6f,0x74,0x20,0x79,0x65,0x74,0x20,0x61,0x76,
|
||||
0x61,0x69,0x6c,0x61,0x62,0x6c,0x65,0x29,0x22,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,
|
||||
0x5f,0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,
|
||||
0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x27,0x54,0x79,0x70,0x65,0x20,0x68,0x65,
|
||||
0x6c,0x70,0x28,0x29,0x20,0x66,0x6f,0x72,0x20,0x6d,0x6f,0x72,0x65,0x20,0x68,0x65,
|
||||
0x6c,0x70,0x2c,0x20,0x6f,0x72,0x20,0x68,0x65,0x6c,0x70,0x28,0x6f,0x62,0x6a,0x29,
|
||||
0x20,0x74,0x6f,0x20,0x64,0x65,0x73,0x63,0x72,0x69,0x62,0x65,0x20,0x61,0x6e,0x20,
|
||||
0x6f,0x62,0x6a,0x65,0x63,0x74,0x2e,0x27,0x0a,0x0a,0x6c,0x65,0x74,0x20,0x68,0x65,
|
||||
0x6c,0x70,0x20,0x3d,0x20,0x48,0x65,0x6c,0x70,0x65,0x72,0x28,0x29,0x0a,0x0a,0x65,
|
||||
0x78,0x70,0x6f,0x72,0x74,0x20,0x6c,0x69,0x73,0x74,0x2c,0x64,0x69,0x63,0x74,0x2c,
|
||||
0x72,0x61,0x6e,0x67,0x65,0x2c,0x68,0x65,0x6c,0x70,0x0a,0x0a,0x5f,0x5f,0x62,0x75,
|
||||
0x69,0x6c,0x74,0x69,0x6e,0x73,0x5f,0x5f,0x2e,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x5f,
|
||||
0x70,0x61,0x74,0x68,0x73,0x20,0x3d,0x20,0x5b,0x22,0x2e,0x2f,0x22,0x2c,0x22,0x2e,
|
||||
0x2f,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x73,0x2f,0x22,0x2c,0x22,0x2f,0x68,0x6f,0x6d,
|
||||
0x65,0x2f,0x6b,0x6c,0x61,0x6e,0x67,0x65,0x2f,0x50,0x72,0x6f,0x6a,0x65,0x63,0x74,
|
||||
0x73,0x2f,0x6b,0x75,0x72,0x6f,0x6b,0x6f,0x2f,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x73,
|
||||
0x2f,0x22,0x2c,0x22,0x2f,0x75,0x73,0x72,0x2f,0x73,0x68,0x61,0x72,0x65,0x2f,0x6b,
|
||||
0x75,0x72,0x6f,0x6b,0x6f,0x2f,0x22,0x5d,0x0a,0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,
|
||||
0x20,0x6f,0x62,0x6a,0x65,0x63,0x74,0x28,0x29,0x0a,
|
||||
0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||
0x6e,0x20,0x5f,0x5f,0x62,0x75,0x69,0x6c,0x74,0x69,0x6e,0x73,0x5f,0x5f,0x2e,0x6c,
|
||||
0x69,0x73,0x74,0x69,0x74,0x65,0x72,0x61,0x74,0x6f,0x72,0x28,0x73,0x65,0x6c,0x66,
|
||||
0x29,0x0a,0x0a,0x63,0x6c,0x61,0x73,0x73,0x20,0x64,0x69,0x63,0x74,0x28,0x29,0x3a,
|
||||
0x0a,0x20,0x22,0x48,0x61,0x73,0x68,0x6d,0x61,0x70,0x20,0x6f,0x66,0x20,0x61,0x72,
|
||||
0x62,0x69,0x74,0x72,0x61,0x72,0x79,0x20,0x6b,0x65,0x79,0x73,0x20,0x74,0x6f,0x20,
|
||||
0x61,0x72,0x62,0x69,0x74,0x72,0x61,0x72,0x79,0x20,0x76,0x61,0x6c,0x75,0x65,0x73,
|
||||
0x2e,0x22,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x73,0x74,0x72,0x5f,0x5f,0x28,
|
||||
0x73,0x65,0x6c,0x66,0x29,0x3a,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x65,
|
||||
0x6c,0x66,0x2e,0x5f,0x5f,0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x29,0x0a,0x20,0x64,
|
||||
0x65,0x66,0x20,0x5f,0x5f,0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,
|
||||
0x29,0x3a,0x0a,0x20,0x20,0x69,0x66,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,
|
||||
0x6e,0x72,0x65,0x70,0x72,0x3a,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x22,0x7b,
|
||||
0x2e,0x2e,0x2e,0x7d,0x22,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,0x69,
|
||||
0x6e,0x72,0x65,0x70,0x72,0x20,0x3d,0x20,0x31,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,
|
||||
0x6f,0x75,0x74,0x20,0x3d,0x20,0x22,0x7b,0x22,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,
|
||||
0x66,0x69,0x72,0x73,0x74,0x20,0x3d,0x20,0x54,0x72,0x75,0x65,0x0a,0x20,0x20,0x66,
|
||||
0x6f,0x72,0x20,0x76,0x20,0x69,0x6e,0x20,0x73,0x65,0x6c,0x66,0x2e,0x6b,0x65,0x79,
|
||||
0x73,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x69,0x66,0x20,0x6e,0x6f,0x74,0x20,0x66,
|
||||
0x69,0x72,0x73,0x74,0x3a,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x20,0x2b,0x3d,
|
||||
0x20,0x22,0x2c,0x20,0x22,0x0a,0x20,0x20,0x20,0x66,0x69,0x72,0x73,0x74,0x20,0x3d,
|
||||
0x20,0x46,0x61,0x6c,0x73,0x65,0x0a,0x20,0x20,0x20,0x6f,0x75,0x74,0x20,0x2b,0x3d,
|
||||
0x20,0x76,0x2e,0x5f,0x5f,0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x29,0x20,0x2b,0x20,
|
||||
0x22,0x3a,0x20,0x22,0x20,0x2b,0x20,0x73,0x65,0x6c,0x66,0x5b,0x76,0x5d,0x2e,0x5f,
|
||||
0x5f,0x72,0x65,0x70,0x72,0x5f,0x5f,0x28,0x29,0x0a,0x20,0x20,0x6f,0x75,0x74,0x20,
|
||||
0x2b,0x3d,0x20,0x22,0x7d,0x22,0x0a,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x5f,0x5f,
|
||||
0x69,0x6e,0x72,0x65,0x70,0x72,0x20,0x3d,0x20,0x30,0x0a,0x20,0x20,0x72,0x65,0x74,
|
||||
0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x0a,0x20,0x64,0x65,0x66,0x20,0x6b,0x65,0x79,
|
||||
0x73,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x22,0x52,0x65,0x74,0x75,
|
||||
0x72,0x6e,0x73,0x20,0x61,0x6e,0x20,0x69,0x74,0x65,0x72,0x61,0x62,0x6c,0x65,0x20,
|
||||
0x6f,0x66,0x20,0x74,0x68,0x65,0x20,0x6b,0x65,0x79,0x73,0x20,0x69,0x6e,0x20,0x74,
|
||||
0x68,0x69,0x73,0x20,0x64,0x69,0x63,0x74,0x69,0x6f,0x6e,0x61,0x72,0x79,0x2e,0x22,
|
||||
0x0a,0x20,0x20,0x63,0x6c,0x61,0x73,0x73,0x20,0x4b,0x65,0x79,0x49,0x74,0x65,0x72,
|
||||
0x61,0x74,0x6f,0x72,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x64,0x65,0x66,0x20,0x5f,
|
||||
0x5f,0x69,0x6e,0x69,0x74,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x2c,0x74,0x29,0x3a,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x73,0x65,0x6c,0x66,0x2e,0x74,0x3d,0x74,0x0a,0x20,0x20,
|
||||
0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x69,0x74,0x65,0x72,0x5f,0x5f,0x28,0x73,0x65,
|
||||
0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x20,0x20,0x6c,0x65,0x74,0x20,0x69,0x3d,0x30,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x6c,0x65,0x74,0x20,0x63,0x3d,0x73,0x65,0x6c,0x66,0x2e,
|
||||
0x74,0x2e,0x63,0x61,0x70,0x61,0x63,0x69,0x74,0x79,0x28,0x29,0x0a,0x20,0x20,0x20,
|
||||
0x20,0x64,0x65,0x66,0x20,0x5f,0x28,0x29,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x6c,
|
||||
0x65,0x74,0x20,0x6f,0x3d,0x4e,0x6f,0x6e,0x65,0x0a,0x20,0x20,0x20,0x20,0x20,0x77,
|
||||
0x68,0x69,0x6c,0x65,0x20,0x6f,0x3d,0x3d,0x4e,0x6f,0x6e,0x65,0x20,0x61,0x6e,0x64,
|
||||
0x20,0x69,0x3c,0x63,0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x6f,0x3d,0x73,0x65,
|
||||
0x6c,0x66,0x2e,0x74,0x2e,0x5f,0x6b,0x65,0x79,0x5f,0x61,0x74,0x5f,0x69,0x6e,0x64,
|
||||
0x65,0x78,0x28,0x69,0x29,0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x2b,0x2b,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,0x6f,0x3d,0x3d,0x4e,0x6f,0x6e,0x65,0x3a,
|
||||
0x0a,0x20,0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,
|
||||
0x20,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x0a,0x20,0x20,
|
||||
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x5f,0x0a,0x20,0x20,0x72,0x65,0x74,
|
||||
0x75,0x72,0x6e,0x20,0x4b,0x65,0x79,0x49,0x74,0x65,0x72,0x61,0x74,0x6f,0x72,0x28,
|
||||
0x73,0x65,0x6c,0x66,0x29,0x0a,0x0a,0x63,0x6c,0x61,0x73,0x73,0x20,0x48,0x65,0x6c,
|
||||
0x70,0x65,0x72,0x28,0x29,0x3a,0x0a,0x20,0x27,0x27,0x27,0x59,0x6f,0x75,0x20,0x73,
|
||||
0x65,0x65,0x6d,0x20,0x74,0x6f,0x20,0x61,0x6c,0x72,0x65,0x61,0x64,0x79,0x20,0x6b,
|
||||
0x6e,0x6f,0x77,0x20,0x68,0x6f,0x77,0x20,0x74,0x6f,0x20,0x75,0x73,0x65,0x20,0x74,
|
||||
0x68,0x69,0x73,0x2e,0x27,0x27,0x27,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x63,
|
||||
0x61,0x6c,0x6c,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x2c,0x6f,0x62,0x6a,0x3d,0x4e,
|
||||
0x6f,0x6e,0x65,0x29,0x3a,0x0a,0x20,0x20,0x69,0x66,0x20,0x6f,0x62,0x6a,0x3a,0x0a,
|
||||
0x20,0x20,0x20,0x74,0x72,0x79,0x3a,0x0a,0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,
|
||||
0x74,0x20,0x6f,0x62,0x6a,0x2e,0x5f,0x5f,0x64,0x6f,0x63,0x5f,0x5f,0x0a,0x20,0x20,
|
||||
0x20,0x65,0x78,0x63,0x65,0x70,0x74,0x3a,0x0a,0x20,0x20,0x20,0x20,0x74,0x72,0x79,
|
||||
0x3a,0x0a,0x20,0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,0x6f,0x62,0x6a,
|
||||
0x2e,0x5f,0x5f,0x63,0x6c,0x61,0x73,0x73,0x5f,0x5f,0x2e,0x5f,0x5f,0x64,0x6f,0x63,
|
||||
0x5f,0x5f,0x0a,0x20,0x20,0x20,0x20,0x65,0x78,0x63,0x65,0x70,0x74,0x3a,0x0a,0x20,
|
||||
0x20,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,0x22,0x4e,0x6f,0x20,0x64,0x6f,
|
||||
0x63,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x61,0x76,0x61,0x69,0x61,0x6c,0x62,0x6c,
|
||||
0x65,0x20,0x66,0x6f,0x72,0x22,0x2c,0x20,0x6f,0x62,0x6a,0x0a,0x20,0x20,0x65,0x6c,
|
||||
0x73,0x65,0x3a,0x0a,0x20,0x20,0x20,0x70,0x72,0x69,0x6e,0x74,0x20,0x22,0x28,0x49,
|
||||
0x6e,0x74,0x65,0x72,0x61,0x63,0x74,0x69,0x76,0x65,0x20,0x68,0x65,0x6c,0x70,0x20,
|
||||
0x69,0x73,0x20,0x6e,0x6f,0x74,0x20,0x79,0x65,0x74,0x20,0x61,0x76,0x61,0x69,0x6c,
|
||||
0x61,0x62,0x6c,0x65,0x29,0x22,0x0a,0x20,0x64,0x65,0x66,0x20,0x5f,0x5f,0x72,0x65,
|
||||
0x70,0x72,0x5f,0x5f,0x28,0x73,0x65,0x6c,0x66,0x29,0x3a,0x0a,0x20,0x20,0x72,0x65,
|
||||
0x74,0x75,0x72,0x6e,0x20,0x27,0x54,0x79,0x70,0x65,0x20,0x68,0x65,0x6c,0x70,0x28,
|
||||
0x29,0x20,0x66,0x6f,0x72,0x20,0x6d,0x6f,0x72,0x65,0x20,0x68,0x65,0x6c,0x70,0x2c,
|
||||
0x20,0x6f,0x72,0x20,0x68,0x65,0x6c,0x70,0x28,0x6f,0x62,0x6a,0x29,0x20,0x74,0x6f,
|
||||
0x20,0x64,0x65,0x73,0x63,0x72,0x69,0x62,0x65,0x20,0x61,0x6e,0x20,0x6f,0x62,0x6a,
|
||||
0x65,0x63,0x74,0x2e,0x27,0x0a,0x0a,0x6c,0x65,0x74,0x20,0x68,0x65,0x6c,0x70,0x20,
|
||||
0x3d,0x20,0x48,0x65,0x6c,0x70,0x65,0x72,0x28,0x29,0x0a,0x0a,0x65,0x78,0x70,0x6f,
|
||||
0x72,0x74,0x20,0x6c,0x69,0x73,0x74,0x2c,0x64,0x69,0x63,0x74,0x2c,0x68,0x65,0x6c,
|
||||
0x70,0x0a,0x0a,0x5f,0x5f,0x62,0x75,0x69,0x6c,0x74,0x69,0x6e,0x73,0x5f,0x5f,0x2e,
|
||||
0x6d,0x6f,0x64,0x75,0x6c,0x65,0x5f,0x70,0x61,0x74,0x68,0x73,0x20,0x3d,0x20,0x5b,
|
||||
0x22,0x2e,0x2f,0x22,0x2c,0x22,0x2e,0x2f,0x6d,0x6f,0x64,0x75,0x6c,0x65,0x73,0x2f,
|
||||
0x22,0x2c,0x22,0x2f,0x68,0x6f,0x6d,0x65,0x2f,0x6b,0x6c,0x61,0x6e,0x67,0x65,0x2f,
|
||||
0x50,0x72,0x6f,0x6a,0x65,0x63,0x74,0x73,0x2f,0x6b,0x75,0x72,0x6f,0x6b,0x6f,0x2f,
|
||||
0x6d,0x6f,0x64,0x75,0x6c,0x65,0x73,0x2f,0x22,0x2c,0x22,0x2f,0x75,0x73,0x72,0x2f,
|
||||
0x73,0x68,0x61,0x72,0x65,0x2f,0x6b,0x75,0x72,0x6f,0x6b,0x6f,0x2f,0x22,0x5d,0x0a,
|
||||
0x0a,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x62,0x6a,0x65,0x63,0x74,0x28,0x29,
|
||||
0x0a,
|
||||
0x00 };
|
||||
|
28
builtins.krk
28
builtins.krk
@ -18,15 +18,7 @@ class list():
|
||||
self.__inrepr=0
|
||||
return b+"]"
|
||||
def __iter__(self):
|
||||
let x=0
|
||||
let l=self.__len__()
|
||||
def _():
|
||||
if x>=l:
|
||||
return _
|
||||
let o=self[x]
|
||||
x++
|
||||
return o
|
||||
return _
|
||||
return __builtins__.listiterator(self)
|
||||
|
||||
class dict():
|
||||
"Hashmap of arbitrary keys to arbitrary values."
|
||||
@ -63,22 +55,6 @@ class dict():
|
||||
return _
|
||||
return KeyIterator(self)
|
||||
|
||||
class range:
|
||||
"Helpful iterable."
|
||||
def __init__(self, min, max):
|
||||
self.min = min
|
||||
self.max = max
|
||||
def __iter__(self):
|
||||
let i=self.min
|
||||
let l=self.max
|
||||
def _():
|
||||
if i>=l:
|
||||
return _
|
||||
let o=i
|
||||
i++
|
||||
return o
|
||||
return _
|
||||
|
||||
class Helper():
|
||||
'''You seem to already know how to use this.'''
|
||||
def __call__(self,obj=None):
|
||||
@ -97,7 +73,7 @@ class Helper():
|
||||
|
||||
let help = Helper()
|
||||
|
||||
export list,dict,range,help
|
||||
export list,dict,help
|
||||
|
||||
__builtins__.module_paths = ["./","./modules/","/home/klange/Projects/kuroko/modules/","/usr/share/kuroko/"]
|
||||
|
||||
|
12
object.c
12
object.c
@ -118,6 +118,18 @@ KrkInstance * krk_newInstance(KrkClass * _class) {
|
||||
KrkInstance * instance = ALLOCATE_OBJECT(KrkInstance, OBJ_INSTANCE);
|
||||
instance->_class = _class;
|
||||
krk_initTable(&instance->fields);
|
||||
|
||||
instance->_getter = NULL;
|
||||
instance->_setter = NULL;
|
||||
|
||||
KrkValue tmp;
|
||||
if (krk_tableGet(&_class->methods, vm.specialMethodNames[METHOD_GET], &tmp)) {
|
||||
instance->_getter = AS_OBJECT(tmp);
|
||||
}
|
||||
if (krk_tableGet(&_class->methods, vm.specialMethodNames[METHOD_SET], &tmp)) {
|
||||
instance->_setter = AS_OBJECT(tmp);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
2
object.h
2
object.h
@ -89,6 +89,8 @@ typedef struct {
|
||||
KrkObj obj;
|
||||
KrkClass * _class;
|
||||
KrkTable fields;
|
||||
KrkObj * _getter;
|
||||
KrkObj * _setter;
|
||||
} KrkInstance;
|
||||
|
||||
typedef struct {
|
||||
|
174
vm.c
174
vm.c
@ -326,7 +326,7 @@ static KrkValue _list_init(int argc, KrkValue argv[]) {
|
||||
*/
|
||||
static KrkValue _list_get(int argc, KrkValue argv[]) {
|
||||
if (argc < 2 || !IS_INTEGER(argv[1])) {
|
||||
krk_runtimeError(vm.exceptions.argumentError, "wrong number or type of arguments");
|
||||
krk_runtimeError(vm.exceptions.argumentError, "wrong number or type of arguments in get %d, (%s, %s)", argc, krk_typeName(argv[0]), krk_typeName(argv[1]));
|
||||
return NONE_VAL();
|
||||
}
|
||||
KrkValue _list_internal;
|
||||
@ -344,7 +344,7 @@ static KrkValue _list_get(int argc, KrkValue argv[]) {
|
||||
*/
|
||||
static KrkValue _list_set(int argc, KrkValue argv[]) {
|
||||
if (argc < 3 || !IS_INTEGER(argv[1])) {
|
||||
krk_runtimeError(vm.exceptions.argumentError, "wrong number or type of arguments");
|
||||
krk_runtimeError(vm.exceptions.argumentError, "wrong number or type of arguments in set %d, (%s, %s, %s)", argc, krk_typeName(argv[0]), krk_typeName(argv[1]), krk_typeName(argv[2]));
|
||||
return NONE_VAL();
|
||||
}
|
||||
KrkValue _list_internal;
|
||||
@ -1893,6 +1893,117 @@ static KrkValue _repr(int argc, KrkValue argv[]) {
|
||||
return krk_callSimple(krk_peek(0), 0);
|
||||
}
|
||||
|
||||
static KrkValue _listiter_init(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
KrkValue _list = argv[1];
|
||||
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("l")), _list);
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("i")), INTEGER_VAL(0));
|
||||
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
static KrkValue _listiter_call(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
KrkValue _list;
|
||||
KrkValue _counter;
|
||||
KrkValue _list_internal;
|
||||
|
||||
if (!krk_tableGet(&self->fields, OBJECT_VAL(S("l")), &_list)) goto _corrupt;
|
||||
if (!krk_tableGet(&self->fields, OBJECT_VAL(S("i")), &_counter)) goto _corrupt;
|
||||
if (!krk_tableGet(&AS_INSTANCE(_list)->fields, vm.specialMethodNames[METHOD_LIST_INT], &_list_internal)) goto _corrupt;
|
||||
|
||||
if ((size_t)AS_INTEGER(_counter) >= AS_LIST(_list_internal)->count) {
|
||||
return argv[0];
|
||||
} else {
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("i")), INTEGER_VAL(AS_INTEGER(_counter)+1));
|
||||
return AS_LIST(_list_internal)->values[AS_INTEGER(_counter)];
|
||||
}
|
||||
|
||||
_corrupt:
|
||||
krk_runtimeError(vm.exceptions.typeError, "Corrupt list iterator");
|
||||
return NONE_VAL();
|
||||
}
|
||||
|
||||
static KrkValue _range_init(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
if (argc < 2 || argc > 3) {
|
||||
krk_runtimeError(vm.exceptions.argumentError, "range expected at least 1 and and at most 2 arguments");
|
||||
return NONE_VAL();
|
||||
}
|
||||
KrkValue min = INTEGER_VAL(0);
|
||||
KrkValue max;
|
||||
if (argc == 2) {
|
||||
max = argv[1];
|
||||
} else {
|
||||
min = argv[1];
|
||||
max = argv[2];
|
||||
}
|
||||
if (!IS_INTEGER(min)) {
|
||||
krk_runtimeError(vm.exceptions.typeError, "range: expected int, but got '%s'", krk_typeName(min));
|
||||
return NONE_VAL();
|
||||
}
|
||||
if (!IS_INTEGER(max)) {
|
||||
krk_runtimeError(vm.exceptions.typeError, "range: expected int, but got '%s'", krk_typeName(max));
|
||||
return NONE_VAL();
|
||||
}
|
||||
|
||||
/* Add them to ourselves */
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("min")), min);
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("max")), max);
|
||||
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
static KrkValue _range_repr(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
|
||||
KrkValue min, max;
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("min")), &min);
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("max")), &max);
|
||||
|
||||
krk_push(OBJECT_VAL(S("range({},{})")));
|
||||
KrkValue output = _string_format(3, (KrkValue[]){krk_peek(0), min, max}, 0);
|
||||
krk_pop();
|
||||
return output;
|
||||
}
|
||||
|
||||
static KrkValue _rangeiterator_init(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("i")), argv[1]);
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("m")), argv[2]);
|
||||
return argv[0];
|
||||
}
|
||||
|
||||
static KrkValue _rangeiterator_call(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
KrkValue i, m;
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("i")), &i);
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("m")), &m);
|
||||
if (AS_INTEGER(i) >= AS_INTEGER(m)) {
|
||||
return argv[0];
|
||||
} else {
|
||||
krk_tableSet(&self->fields, OBJECT_VAL(S("i")), INTEGER_VAL(AS_INTEGER(i)+1));
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
static KrkValue _range_iter(int argc, KrkValue argv[]) {
|
||||
KrkInstance * self = AS_INSTANCE(argv[0]);
|
||||
KrkValue min, max;
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("min")), &min);
|
||||
krk_tableGet(&self->fields, OBJECT_VAL(S("max")), &max);
|
||||
|
||||
KrkInstance * output = krk_newInstance(vm.baseClasses.rangeiteratorClass);
|
||||
|
||||
krk_push(OBJECT_VAL(output));
|
||||
_rangeiterator_init(3, (KrkValue[]){krk_peek(0), min, max});
|
||||
krk_pop();
|
||||
|
||||
return OBJECT_VAL(output);
|
||||
}
|
||||
|
||||
|
||||
void krk_initVM(int flags) {
|
||||
vm.flags = flags;
|
||||
KRK_PAUSE_GC();
|
||||
@ -2031,6 +2142,20 @@ void krk_initVM(int flags) {
|
||||
/* __builtins__.set_tracing is namespaced */
|
||||
krk_defineNative(&vm.builtins->fields, "set_tracing", krk_set_tracing);
|
||||
|
||||
ADD_BASE_CLASS(vm.baseClasses.listiteratorClass, "listiterator", vm.objectClass);
|
||||
krk_defineNative(&vm.baseClasses.listiteratorClass->methods, ".__init__", _listiter_init);
|
||||
krk_defineNative(&vm.baseClasses.listiteratorClass->methods, ".__call__", _listiter_call);
|
||||
|
||||
ADD_BASE_CLASS(vm.baseClasses.rangeClass, "range", vm.objectClass);
|
||||
krk_attachNamedObject(&vm.globals, "range", (KrkObj*)vm.baseClasses.rangeClass);
|
||||
krk_defineNative(&vm.baseClasses.rangeClass->methods, ".__init__", _range_init);
|
||||
krk_defineNative(&vm.baseClasses.rangeClass->methods, ".__iter__", _range_iter);
|
||||
krk_defineNative(&vm.baseClasses.rangeClass->methods, ".__repr__", _range_repr);
|
||||
|
||||
ADD_BASE_CLASS(vm.baseClasses.rangeiteratorClass, "rangeiterator", vm.objectClass);
|
||||
krk_defineNative(&vm.baseClasses.rangeiteratorClass->methods, ".__init__", _rangeiterator_init);
|
||||
krk_defineNative(&vm.baseClasses.rangeiteratorClass->methods, ".__call__", _rangeiterator_call);
|
||||
|
||||
/**
|
||||
* Read the managed code builtins module, which contains the base
|
||||
* definitions for collections so we can pull them into the global
|
||||
@ -2719,25 +2844,40 @@ static KrkValue run() {
|
||||
break;
|
||||
}
|
||||
case OP_INVOKE_GETTER: {
|
||||
krk_swap(1);
|
||||
valueGetProperty(AS_STRING(vm.specialMethodNames[METHOD_GET]));
|
||||
krk_swap(1);
|
||||
switch (krk_callValue(krk_peek(1),1,1)) {
|
||||
case 2: break;
|
||||
case 1: krk_push(krk_runNext()); break;
|
||||
default: krk_runtimeError(vm.exceptions.typeError, "Invalid method call."); goto _finishException;
|
||||
if (0 && IS_INSTANCE(krk_peek(1)) && AS_INSTANCE(krk_peek(1))->_getter) {
|
||||
krk_push(krk_peek(1));
|
||||
krk_swap(1);
|
||||
krk_push(krk_callSimple(OBJECT_VAL(AS_INSTANCE(krk_peek(2))->_getter), 2));
|
||||
} else {
|
||||
krk_swap(1);
|
||||
valueGetProperty(AS_STRING(vm.specialMethodNames[METHOD_GET]));
|
||||
krk_swap(1);
|
||||
switch (krk_callValue(krk_peek(1),1,1)) {
|
||||
case 2: break;
|
||||
case 1: krk_push(krk_runNext()); break;
|
||||
default: krk_runtimeError(vm.exceptions.typeError, "Invalid method call."); goto _finishException;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case OP_INVOKE_SETTER: {
|
||||
krk_push(krk_peek(2)); /* object to top */
|
||||
valueGetProperty(AS_STRING(vm.specialMethodNames[METHOD_SET]));
|
||||
krk_swap(3);
|
||||
krk_pop();
|
||||
switch (krk_callValue(krk_peek(2),2,1)) {
|
||||
case 2: break;
|
||||
case 1: krk_push(krk_runNext()); break;
|
||||
default: krk_runtimeError(vm.exceptions.typeError, "Invalid method call."); goto _finishException;
|
||||
if (0 && IS_INSTANCE(krk_peek(2)) && AS_INSTANCE(krk_peek(2))->_setter) {
|
||||
krk_push(krk_peek(2));
|
||||
krk_swap(1);
|
||||
KrkValue result = krk_callSimple(OBJECT_VAL(AS_INSTANCE(krk_peek(3))->_setter), 3);
|
||||
dumpStack(frame);
|
||||
fprintf(stderr, "Returning result\n");
|
||||
krk_push(result);
|
||||
} else {
|
||||
krk_push(krk_peek(2)); /* object to top */
|
||||
valueGetProperty(AS_STRING(vm.specialMethodNames[METHOD_SET]));
|
||||
krk_swap(3);
|
||||
krk_pop();
|
||||
switch (krk_callValue(krk_peek(2),2,1)) {
|
||||
case 2: break;
|
||||
case 1: krk_push(krk_runNext()); break;
|
||||
default: krk_runtimeError(vm.exceptions.typeError, "Invalid method call."); goto _finishException;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
5
vm.h
5
vm.h
@ -85,6 +85,11 @@ typedef struct {
|
||||
KrkClass * strClass; /* String */
|
||||
KrkClass * functionClass; /* Functions, Closures */
|
||||
KrkClass * methodClass; /* BoundMethod */
|
||||
|
||||
/* Other useful stuff */
|
||||
KrkClass * listiteratorClass;
|
||||
KrkClass * rangeClass;
|
||||
KrkClass * rangeiteratorClass;
|
||||
} baseClasses;
|
||||
|
||||
KrkValue currentException;
|
||||
|
Loading…
Reference in New Issue
Block a user