Line data Source code
1 : /*
2 : * SPDX-License-Identifier: MPL-2.0
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * Copyright 2024 MonetDB Foundation;
9 : * Copyright August 2008 - 2023 MonetDB B.V.;
10 : * Copyright 1997 - July 2008 CWI.
11 : */
12 :
13 : /*
14 : * Martin Kersten
15 : * Language Extensions
16 : * Iterators over scalar ranges are often needed, also at the MAL level.
17 : * The barrier and control primitives are sufficient to mimic them directly.
18 : *
19 : * The modules located in the kernel directory should not
20 : * rely on the MAL datastructures. That's why we have to deal with
21 : * some bat operations here and delegate the signature to the
22 : * proper module upon loading.
23 : *
24 : * Running a script is typically used to initialize a context.
25 : * Therefore we need access to the runtime context.
26 : * For the call variants we have
27 : * to determine an easy way to exchange the parameter/return values.
28 : */
29 :
30 : #include "monetdb_config.h"
31 : #include "mal.h"
32 : #include "mal_module.h"
33 : #include "mal_session.h"
34 : #include "mal_resolve.h"
35 : #include "mal_client.h"
36 : #include "mal_interpreter.h"
37 : #include "mal_dataflow.h"
38 :
39 : static str
40 155188 : MALstartDataflow(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
41 : {
42 155188 : bit *ret = getArgReference_bit(stk, pci, 0);
43 155188 : int pc = getPC(mb, pci);
44 :
45 155190 : if (pc < 0 || pc > pci->jump)
46 0 : throw(MAL, "language.dataflow", "Illegal statement range");
47 155191 : *ret = 0; /* continue at end of block */
48 155191 : return runMALdataflow(cntxt, mb, pc, pci->jump, stk);
49 : }
50 :
51 : static str
52 2225159 : MALpass(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
53 : {
54 2225159 : (void) cntxt;
55 2225159 : (void) mb;
56 2225159 : (void) stk;
57 2225159 : (void) pci;
58 2225159 : return MAL_SUCCEED;
59 : }
60 :
61 : #include "mel.h"
62 : mel_func language_init_funcs[] = {
63 : pattern("language", "dataflow", MALstartDataflow, false, "The current guarded block is executed using dataflow control. ", args(1,1, arg("",bit))),
64 : pattern("language", "pass", MALpass, false, "Cheap instruction to discard storage while retaining the dataflow dependency", args(0,1, argany("v",1))),
65 : pattern("language", "block", deblockdataflow, false, "Block on availability of all variables w, and then pass on v", args(1,3, arg("",int),arg("v",int),varargany("w",0))),
66 : { .imp=NULL }
67 : };
68 : #include "mal_import.h"
69 : #ifdef _MSC_VER
70 : #undef read
71 : #pragma section(".CRT$XCU",read)
72 : #endif
73 323 : LIB_STARTUP_FUNC(init_language_mal)
74 323 : { mal_module("language", NULL, language_init_funcs); }
|