interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / src / omega_resolve_osc.c

43 lines · 1653 bytes Raw Blame History
1/* SPDX-License-Identifier: Apache-2.0
2 * Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* omega_resolve_osc.c -- see omega_resolve_osc.h. */
18#include "omega_resolve_osc.h"
19
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24int omega_osc_import_hook(void *ctx, const OscImport *imports, uint32_t n, uint32_t *bad, char *why, size_t why_cap)
25{
26 OmegaOscImports *h = ctx;
27 const char **names = calloc(n ? n : 1, sizeof *names);
28 if (!names) { snprintf(why, why_cap, "NOMEM: out of memory"); return OMEGA_RES_NOMEM; }
29 for (uint32_t i = 0; i < n; i++) names[i] = imports[i].name;
30 omega_closure_free(&h->closure);
31 h->resolved = 0;
32 h->n_imports = n;
33 int rc = omega_resolve_imports(&h->resolver, h->lock, names, n, &h->closure, &h->err);
34 free(names);
35 if (rc) {
36 *bad = UINT32_MAX;
37 for (uint32_t i = 0; i < n; i++) if (strcmp(imports[i].name, h->err.subject) == 0) *bad = i;
38 snprintf(why, why_cap, "%s: %s", omega_resolve_code_name(h->err.code), h->err.message);
39 return rc;
40 }
41 h->resolved = 1;
42 return 0;
43}