Sat, 30 May 2015 14:14:36 +0200
fixed: comparison operator info has been incorrectly written to type field
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
4 | * Copyright 2015 Olaf Wintermann. All rights reserved. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include <stdio.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
30 | #include <stdlib.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | #include <string.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
32 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
33 | #include <ucx/utils.h> |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | #include "davqlexec.h" |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
35 | #include "utils.h" |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | DavQLResult* dav_statement_exec(DavSession *sn, DavQLStatement *st, ...) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | va_list ap; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | va_start(ap, st); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | DavQLResult *result = dav_statement_execv(sn, st, ap); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | va_end(ap); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
43 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | DavQLResult* dav_statement_execv(DavSession *sn, DavQLStatement *st, va_list ap) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
46 | DavQLResult *result = dav_session_malloc(sn, sizeof(DavQLResult)); |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
47 | result->result = NULL; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | result->status = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | // make sure the statement was successfully parsed |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | if(st->type == DAVQL_ERROR) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | // get path string |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | davqlerror_t error; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
57 | sstr_t path = dav_format_string(sn->mp->allocator, st->path, ap, &error); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | if(st->type == DAVQL_GET) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
60 | dav_exec_get(sn, st, path.ptr, ap); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | // TODO |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | return result; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
68 | sstr_t dav_format_string(UcxAllocator *a, sstr_t fstr, va_list ap, davqlerror_t *error) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
69 | UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | int placeholder = 0; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
72 | for(int i=0;i<fstr.length;i++) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
73 | char c = fstr.ptr[i]; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | if(placeholder) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | // no placeholder, %% transposes to % |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
77 | ucx_buffer_putc(buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | // detect placeholder type and insert arg |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | int err = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | switch(c) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | case 's': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | char *arg = va_arg(ap, char*); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
84 | ucx_buffer_puts(buf, arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | case 'd': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | int arg = va_arg(ap, int); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
89 | ucx_bprintf(buf, "%d", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
92 | case 'u': { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | unsigned int arg = va_arg(ap, unsigned int); |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
94 | ucx_bprintf(buf, "%u", arg); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | case 't': { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
98 | // time arguments not supported for strings |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
99 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
100 | break; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
101 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | default: { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | *error = DAVQL_UNKNOWN_FORMATCHAR; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | err = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
105 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
106 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | if(err) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
108 | ucx_buffer_free(buf); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
109 | sstr_t n; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
110 | n.ptr = NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
111 | n.length = 0; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
112 | return n; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | placeholder = 0; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | } else { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
117 | if(c == '%') { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
118 | placeholder = 1; |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | } else { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
120 | ucx_buffer_putc(buf, c); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | *error = DAVQL_OK; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
125 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
126 | return sstrdup_a(a, sstrn(buf->space, buf->size)); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
129 | void dav_exec_get(DavSession *sn, DavQLStatement *st, char* path, va_list ap) { |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | // execute a davql get statement |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
131 | UcxMempool *mp = ucx_mempool_new(128); |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | // TODO: get property list |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
135 | UcxBuffer *bcode = dav_compile_expr(mp->allocator, st->where, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
136 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
137 | print_bytecode(bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
138 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
139 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
140 | static int count_func_args(DavQLExpression *expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
141 | int count = 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
142 | DavQLExpression *arg = expr->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
143 | while(arg) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
144 | count++; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
145 | if(arg->op == DAVQL_ARGLIST) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
146 | arg = arg->right; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
147 | } else { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
148 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
149 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
150 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
151 | return count; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | } |
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
154 | static int add_cmd(UcxAllocator *a, UcxBuffer *bcode, DavQLExpression *expr, va_list ap) { |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
155 | if(!expr) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
156 | return 0; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
157 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
158 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
159 | int numcmd = 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
160 | DavQLCmd cmd; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
161 | memset(&cmd, sizeof(DavQLCmd), 0); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
162 | davqlerror_t error; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
164 | sstr_t src = expr->srctext; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
165 | switch(expr->type) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
166 | case DAVQL_NUMBER: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
167 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
168 | if(src.ptr[0] == '%') { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
169 | cmd.data.integer = va_arg(ap, int); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
170 | } else if(util_strtoint(src.ptr, &cmd.data.integer)) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
171 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
172 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
173 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
174 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
175 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
176 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
177 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
178 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
179 | case DAVQL_STRING: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
180 | cmd.type = DAVQL_CMD_STRING; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
181 | cmd.data.string = dav_format_string(a, src, ap, &error); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
182 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
183 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
184 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
185 | case DAVQL_TIMESTAMP: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
186 | if(src.ptr[0] == '%') { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
187 | cmd.data.timestamp = va_arg(ap, time_t); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
188 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
189 | } else { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
190 | // error |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
191 | return -1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
192 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
193 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
194 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
195 | case DAVQL_IDENTIFIER: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
196 | sstr_t propertyname = sstrchr(src, ':'); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
197 | cmd.type = DAVQL_CMD_RES_IDENTIFIER; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
198 | if(propertyname.length > 0) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
199 | cmd.type = DAVQL_CMD_PROP_IDENTIFIER; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
200 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
201 | // TODO |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
202 | } else if(!sstrcmp(src, S("name"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
203 | cmd.data.resprop = DAVQL_RES_NAME; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
204 | } else if(!sstrcmp(src, S("path"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
205 | cmd.data.resprop = DAVQL_RES_PATH; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
206 | } else if(!sstrcmp(src, S("href"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
207 | cmd.data.resprop = DAVQL_RES_HREF; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
208 | } else if(!sstrcmp(src, S("contentlength"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
209 | cmd.data.resprop = DAVQL_RES_CONTENTLENGTH; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
210 | } else if(!sstrcmp(src, S("contenttype"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
211 | cmd.data.resprop = DAVQL_RES_CONTENTTYPE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
212 | } else if(!sstrcmp(src, S("creationdate"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
213 | cmd.data.resprop = DAVQL_RES_CREATIONDATE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
214 | } else if(!sstrcmp(src, S("lastmodified"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
215 | cmd.data.resprop = DAVQL_RES_LASTMODIFIED; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
216 | } else if(!sstrcmp(src, S("iscollection"))) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
217 | cmd.data.resprop = DAVQL_RES_ISCOLLECTION; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
218 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
219 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
220 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
221 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
222 | case DAVQL_UNARY: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
223 | numcmd += add_cmd(a, bcode, expr->left, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
224 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
225 | case DAVQL_ADD: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
226 | cmd.type = DAVQL_CMD_OP_UNARY_ADD; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
227 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
228 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
229 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
230 | cmd.type = DAVQL_CMD_OP_UNARY_SUB; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
231 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
232 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
233 | case DAVQL_NEG: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
234 | cmd.type = DAVQL_CMD_OP_UNARY_NEG; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
235 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
236 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
237 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
238 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
239 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
240 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
241 | case DAVQL_BINARY: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
242 | numcmd += add_cmd(a, bcode, expr->left, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
243 | numcmd += add_cmd(a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
244 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
245 | case DAVQL_ADD: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
246 | cmd.type = DAVQL_CMD_OP_BINARY_ADD; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
247 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
248 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
249 | case DAVQL_SUB: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
250 | cmd.type = DAVQL_CMD_OP_BINARY_SUB; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
251 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
252 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
253 | case DAVQL_MUL: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
254 | cmd.type = DAVQL_CMD_OP_BINARY_MUL; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
255 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
256 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
257 | case DAVQL_DIV: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
258 | cmd.type = DAVQL_CMD_OP_BINARY_DIV; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
259 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
260 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
261 | case DAVQL_AND: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
262 | cmd.type = DAVQL_CMD_OP_BINARY_AND; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
263 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
264 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
265 | case DAVQL_OR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
266 | cmd.type = DAVQL_CMD_OP_BINARY_OR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
267 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
268 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
269 | case DAVQL_XOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
270 | cmd.type = DAVQL_CMD_OP_BINARY_XOR; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
271 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
272 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
273 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
274 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
275 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
276 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
277 | case DAVQL_LOGICAL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
278 | if(expr->left && expr->right && expr->op != DAVQL_LOR) { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
279 | numcmd += add_cmd(a, bcode, expr->left, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
280 | numcmd += add_cmd(a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
281 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
282 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
283 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
284 | case DAVQL_NOT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
285 | numcmd += add_cmd(a, bcode, expr->left, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
286 | cmd.type = DAVQL_CMD_OP_LOGICAL_NOT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
287 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
288 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
289 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
290 | case DAVQL_LAND: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
291 | cmd.type = DAVQL_CMD_OP_LOGICAL_NOT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
292 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
293 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
294 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
295 | case DAVQL_LOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
296 | int nleft = add_cmd(a, bcode, expr->left, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
297 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
298 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR_L; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
299 | DavQLCmd *or_l = (DavQLCmd*)(bcode->space + bcode->pos); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
300 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
301 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
302 | int nright = add_cmd(a, bcode, expr->right, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
303 | or_l->data.integer = nright + 1; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
304 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
305 | cmd.type = DAVQL_CMD_OP_LOGICAL_OR; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
306 | cmd.data.integer = 0; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
307 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
308 | |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
309 | numcmd += nleft + nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
310 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
311 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
312 | case DAVQL_LXOR: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
313 | cmd.type = DAVQL_CMD_OP_LOGICAL_XOR; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
314 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
315 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
316 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
317 | case DAVQL_EQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
318 | cmd.type = DAVQL_CMD_OP_EQ; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
319 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
320 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
321 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
322 | case DAVQL_NEQ: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
323 | cmd.type = DAVQL_CMD_OP_NEQ; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
324 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
325 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
326 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
327 | case DAVQL_LT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
328 | cmd.type = DAVQL_CMD_OP_LT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
329 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
330 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
331 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
332 | case DAVQL_GT: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
333 | cmd.type = DAVQL_CMD_OP_GT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
334 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
335 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
336 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
337 | case DAVQL_LE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
338 | cmd.type = DAVQL_CMD_OP_LE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
339 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
340 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
341 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
342 | case DAVQL_GE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
343 | cmd.type = DAVQL_CMD_OP_GE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
344 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
345 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
346 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
347 | case DAVQL_LIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
348 | cmd.type = DAVQL_CMD_OP_LIKE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
349 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
350 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
351 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
352 | case DAVQL_UNLIKE: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
353 | cmd.type = DAVQL_CMD_OP_UNLIKE; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
354 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
355 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
356 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
357 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
358 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
359 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
360 | case DAVQL_FUNCCALL: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
361 | switch(expr->op) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
362 | case DAVQL_CALL: { |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
363 | int nright = add_cmd(a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
364 | // TODO: count args |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
365 | DavQLExpression *funcid = expr->left; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
366 | if(!funcid && funcid->type != DAVQL_IDENTIFIER) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
367 | // fail |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
368 | return -1; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
369 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
370 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
371 | // numargs |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
372 | cmd.type = DAVQL_CMD_INT; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
373 | cmd.data.integer = count_func_args(expr); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
374 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
375 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
376 | // TODO: resolve function name |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
377 | cmd.type = DAVQL_CMD_CALL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
378 | cmd.data.func = NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
379 | ucx_buffer_write(&cmd, sizeof(cmd), 1, bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
380 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
381 | numcmd = 2; |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
382 | numcmd += nright; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
383 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
384 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
385 | case DAVQL_ARGLIST: { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
386 | numcmd = 0; |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
387 | numcmd += add_cmd(a, bcode, expr->left, ap); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
388 | numcmd += add_cmd(a, bcode, expr->right, ap); |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
389 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
390 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
391 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
392 | break; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
393 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
394 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
395 | return numcmd; |
104
6fb4d24d9df9
added davqlexec source
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
396 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
397 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
398 | UcxBuffer* dav_compile_expr(UcxAllocator *a, DavQLExpression *lexpr, va_list ap) { |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
399 | UcxBuffer *bcode = ucx_buffer_new(NULL, 512, UCX_BUFFER_AUTOEXTEND); |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
400 | if(!bcode) { |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
401 | return NULL; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
402 | } |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
403 | |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
404 | if(add_cmd(a, bcode, lexpr, ap) <= 0) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
405 | ucx_buffer_free(bcode); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
406 | return NULL; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
407 | } |
123
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
408 | |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
409 | return bcode; |
806c4dccf2ae
added where clause compiler prototype
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
104
diff
changeset
|
410 | } |
124
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
411 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
412 | |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
413 | void print_bytecode(UcxBuffer *bcode) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
414 | bcode->pos = 0; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
415 | DavQLCmd cmd; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
416 | while(ucx_buffer_read(&cmd, sizeof(DavQLCmd), 1, bcode) == 1) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
417 | switch(cmd.type) { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
418 | case DAVQL_CMD_INT: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
419 | printf("int %ll\n", cmd.data.integer); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
420 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
421 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
422 | case DAVQL_CMD_STRING: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
423 | printf("string \"%.*s\"\n", cmd.data.string.length, cmd.data.string.ptr); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
424 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
425 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
426 | case DAVQL_CMD_TIMESTAMP: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
427 | printf("timestamp %d\n", cmd.data.timestamp); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
428 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
429 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
430 | case DAVQL_CMD_RES_IDENTIFIER: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
431 | char *rid[8] = {"name", "path", "href", "contentlength", "contenttype", "creationdate", "lastmodified", "iscollection"}; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
432 | printf("resprop %s\n", rid[cmd.data.resprop]); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
433 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
434 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
435 | case DAVQL_CMD_PROP_IDENTIFIER: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
436 | printf("property %s:%s\n", cmd.data.property.ns, cmd.data.property.name); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
437 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
438 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
439 | case DAVQL_CMD_OP_UNARY_ADD: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
440 | printf("uadd\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
441 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
442 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
443 | case DAVQL_CMD_OP_UNARY_SUB: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
444 | printf("usub\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
445 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
446 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
447 | case DAVQL_CMD_OP_UNARY_NEG: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
448 | printf("uneg\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
449 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
450 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
451 | case DAVQL_CMD_OP_BINARY_ADD: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
452 | printf("add\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
453 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
454 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
455 | case DAVQL_CMD_OP_BINARY_SUB: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
456 | printf("sub\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
457 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
458 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
459 | case DAVQL_CMD_OP_BINARY_MUL: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
460 | printf("mul\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
461 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
462 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
463 | case DAVQL_CMD_OP_BINARY_DIV: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
464 | printf("div\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
465 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
466 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
467 | case DAVQL_CMD_OP_BINARY_AND: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
468 | printf("and\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
469 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
470 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
471 | case DAVQL_CMD_OP_BINARY_OR: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
472 | printf("or\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
473 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
474 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
475 | case DAVQL_CMD_OP_BINARY_XOR: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
476 | printf("xor\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
477 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
478 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
479 | case DAVQL_CMD_OP_LOGICAL_NOT: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
480 | printf("not\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
481 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
482 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
483 | case DAVQL_CMD_OP_LOGICAL_AND: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
484 | printf("land\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
485 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
486 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
487 | case DAVQL_CMD_OP_LOGICAL_OR_L: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
488 | printf("or_l %d\n", cmd.data.integer); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
489 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
490 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
491 | case DAVQL_CMD_OP_LOGICAL_OR: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
492 | printf("or\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
493 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
494 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
495 | case DAVQL_CMD_OP_LOGICAL_XOR: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
496 | printf("lxor\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
497 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
498 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
499 | case DAVQL_CMD_OP_EQ: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
500 | printf("eq\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
501 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
502 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
503 | case DAVQL_CMD_OP_NEQ: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
504 | printf("neq\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
505 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
506 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
507 | case DAVQL_CMD_OP_LT: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
508 | printf("lt\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
509 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
510 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
511 | case DAVQL_CMD_OP_GT: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
512 | printf("gt\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
513 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
514 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
515 | case DAVQL_CMD_OP_LE: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
516 | printf("le\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
517 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
518 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
519 | case DAVQL_CMD_OP_GE: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
520 | printf("ge\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
521 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
522 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
523 | case DAVQL_CMD_OP_LIKE: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
524 | printf("like\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
525 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
526 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
527 | case DAVQL_CMD_OP_UNLIKE: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
528 | printf("unlike\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
529 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
530 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
531 | case DAVQL_CMD_CALL: { |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
532 | printf("call %x\n", cmd.data.func); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
533 | break; |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
534 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
535 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
536 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
537 | printf("\n"); |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
538 | } |
41939c8f3f9c
expression compiler generates byte code
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
123
diff
changeset
|
539 |