| 1 | /** |
|---|
| 2 | * obj_list.c -> Part of Crules Programming language |
|---|
| 3 | * |
|---|
| 4 | * Crules is the legal property of its developers. Please refer to the |
|---|
| 5 | * COPYRIGHT file distributed with this source distribution. |
|---|
| 6 | * |
|---|
| 7 | * This program is free software: you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * This program is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 19 | **/ |
|---|
| 20 | |
|---|
| 21 | #ifdef HAVE_CONFIG_H |
|---|
| 22 | # include "config.h" |
|---|
| 23 | #else |
|---|
| 24 | # define CMAKE 1 |
|---|
| 25 | # include "config.h.cmake" |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | #include <stdio.h> |
|---|
| 29 | #include <stdlib.h> |
|---|
| 30 | #include <string.h> |
|---|
| 31 | |
|---|
| 32 | #include <crules/crules.h> |
|---|
| 33 | #include <crules/opcodes.h> |
|---|
| 34 | #include <crules/symbols.h> |
|---|
| 35 | #include <crules/objects.h> |
|---|
| 36 | #include <crules/backend.h> |
|---|
| 37 | #include <crules/runtime.h> |
|---|
| 38 | #include <crules/garbage.h> |
|---|
| 39 | #include <crules/operators.h> |
|---|
| 40 | |
|---|
| 41 | typedef struct crl_list_t { |
|---|
| 42 | long int size, length; |
|---|
| 43 | crl_symbol_obj **array; |
|---|
| 44 | } crl_list_t ; |
|---|
| 45 | |
|---|
| 46 | crl_symbol_obj * |
|---|
| 47 | crl_obj_list_init( crl_symbol_obj * caller, |
|---|
| 48 | crl_type_obj_def_t ** def ) |
|---|
| 49 | { |
|---|
| 50 | return NULL; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | crl_symbol_obj * |
|---|
| 54 | crl_obj_list_push( crl_symbol_obj * caller, |
|---|
| 55 | crl_symbol_obj * self, |
|---|
| 56 | crl_context_table * context ) |
|---|
| 57 | { |
|---|
| 58 | return NULL; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | crl_symbol_obj * |
|---|
| 62 | crl_obj_list_pop( crl_symbol_obj * caller, |
|---|
| 63 | crl_symbol_obj * self, |
|---|
| 64 | crl_context_table * context ) |
|---|
| 65 | { |
|---|
| 66 | return NULL; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | crl_symbol_obj * |
|---|
| 70 | crl_obj_list_remove( crl_symbol_obj * caller, |
|---|
| 71 | crl_symbol_obj * self, |
|---|
| 72 | crl_context_table * context ) |
|---|
| 73 | { |
|---|
| 74 | return NULL; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | crl_symbol_obj * |
|---|
| 78 | crl_obj_list_append( crl_symbol_obj * caller, |
|---|
| 79 | crl_symbol_obj * self, |
|---|
| 80 | crl_context_table * context ) |
|---|
| 81 | { |
|---|
| 82 | return NULL; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | crl_symbol_obj * |
|---|
| 86 | crl_obj_list_length( crl_symbol_obj * caller, |
|---|
| 87 | crl_symbol_obj * self, |
|---|
| 88 | crl_context_table * context ) |
|---|
| 89 | { |
|---|
| 90 | return NULL; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | bool crl_obj_list_print( crl_list_t * list ) |
|---|
| 94 | { |
|---|
| 95 | return true; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | void crl_obj_list_destroy( crl_list_t * list ) |
|---|
| 99 | { |
|---|
| 100 | return; |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | struct crl_number_prot_t list_module_binary_ops = { |
|---|
| 104 | false, |
|---|
| 105 | NULL, |
|---|
| 106 | NULL, |
|---|
| 107 | NULL, |
|---|
| 108 | NULL, |
|---|
| 109 | NULL, |
|---|
| 110 | NULL, |
|---|
| 111 | NULL, |
|---|
| 112 | NULL, |
|---|
| 113 | NULL, |
|---|
| 114 | NULL, |
|---|
| 115 | NULL, |
|---|
| 116 | NULL, |
|---|
| 117 | NULL, |
|---|
| 118 | }; |
|---|
| 119 | |
|---|
| 120 | struct crl_builtin_function_def_t list_module_function_table[] = { |
|---|
| 121 | { "push", 1, &crl_obj_list_push }, |
|---|
| 122 | { "pop", 0, &crl_obj_list_pop }, |
|---|
| 123 | { "remove", 1, &crl_obj_list_remove }, |
|---|
| 124 | { "append", 1, &crl_obj_list_append }, |
|---|
| 125 | { "length", 0, &crl_obj_list_length }, |
|---|
| 126 | { NULL, 0, NULL }, |
|---|
| 127 | } ; |
|---|
| 128 | |
|---|
| 129 | struct crl_builtin_member_def_t list_module_member_table[] = { |
|---|
| 130 | { 0, NULL }, |
|---|
| 131 | } ; |
|---|
| 132 | |
|---|
| 133 | struct crl_type_obj_def_t list_object = { |
|---|
| 134 | "List", |
|---|
| 135 | sizeof( crl_list_t ), |
|---|
| 136 | &crl_obj_list_init, |
|---|
| 137 | &crl_obj_list_destroy, |
|---|
| 138 | &crl_obj_list_print, |
|---|
| 139 | NULL, |
|---|
| 140 | &list_module_binary_ops, |
|---|
| 141 | list_module_member_table, |
|---|
| 142 | list_module_function_table, |
|---|
| 143 | } ; |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | bool crl_obj_list_module_init( crl_context_table * context ) |
|---|
| 147 | { |
|---|
| 148 | return true; |
|---|
| 149 | } |
|---|