Function bodies 789 total
am_janus_register function · c · L78-L101 (24 LOC)ariannamethod/ariannamethod.c
void am_janus_register(
janus_load_model_fn load_model,
janus_unload_model_fn unload_model,
janus_load_delta_fn load_delta,
janus_load_gamma_fn load_gamma,
janus_generate_fn generate,
janus_free_string_fn free_string,
janus_model_loaded_fn model_loaded,
janus_get_vocab_size_fn get_vocab_size,
janus_get_embed_dim_fn get_embed_dim,
janus_get_num_layers_fn get_num_layers
) {
g_janus_load_model = load_model;
g_janus_unload_model = unload_model;
g_janus_load_delta = load_delta;
g_janus_load_gamma = load_gamma;
g_janus_generate = generate;
g_janus_free_string = free_string;
g_janus_model_loaded = model_loaded;
g_janus_get_vocab_size = get_vocab_size;
g_janus_get_embed_dim = get_embed_dim;
g_janus_get_num_layers = get_num_layers;
}trim function · c · L109-L115 (7 LOC)ariannamethod/ariannamethod.c
static char* trim(char* s) {
while (*s && isspace((unsigned char)*s)) s++;
char* e = s + strlen(s);
while (e > s && isspace((unsigned char)e[-1])) e--;
*e = 0;
return s;
}upcase function · c · L116-L120 (5 LOC)ariannamethod/ariannamethod.c
static void upcase(char* s) {
for (; *s; s++) *s = (char)toupper((unsigned char)*s);
}clamp01 function · c · L121-L127 (7 LOC)ariannamethod/ariannamethod.c
static float clamp01(float x) {
if (!isfinite(x)) return 0.0f;
if (x < 0.0f) return 0.0f;
if (x > 1.0f) return 1.0f;
return x;
}clampf function · c · L128-L134 (7 LOC)ariannamethod/ariannamethod.c
static float clampf(float x, float a, float b) {
if (!isfinite(x)) return a;
if (x < a) return a;
if (x > b) return b;
return x;
}safe_atoi function · c · L135-L143 (9 LOC)ariannamethod/ariannamethod.c
static int safe_atoi(const char* s) {
if (!s || !*s) return 0;
char* endptr;
long val = strtol(s, &endptr, 10);
if (val > 2147483647L) return 2147483647;
if (val < -2147483647L) return -2147483647;
return (int)val;
}safe_atof function · c · L144-L150 (7 LOC)ariannamethod/ariannamethod.c
static float safe_atof(const char* s) {
if (!s || !*s) return 0.0f;
float val = (float)atof(s);
if (!isfinite(val)) return 0.0f;
return val;
}Repobility · code-quality intelligence platform · https://repobility.com
clampi function · c · L151-L156 (6 LOC)ariannamethod/ariannamethod.c
static int clampi(int x, int a, int b) {
if (x < a) return a;
if (x > b) return b;
return x;
}calendar_init function · c · L179-L189 (11 LOC)ariannamethod/ariannamethod.c
static void calendar_init(void) {
struct tm epoch_tm;
memset(&epoch_tm, 0, sizeof(epoch_tm));
epoch_tm.tm_year = 2024 - 1900;
epoch_tm.tm_mon = 10 - 1; // October
epoch_tm.tm_mday = 3;
epoch_tm.tm_hour = 12; // noon — avoids DST edge cases
g_epoch_t = mktime(&epoch_tm);
g_calendar_manual = 0;
}calendar_days_since_epoch function · c · L190-L195 (6 LOC)ariannamethod/ariannamethod.c
static int calendar_days_since_epoch(void) {
if (g_epoch_t <= 0) return 0;
time_t now = time(NULL);
return (int)(difftime(now, g_epoch_t) / 86400.0);
}calendar_cumulative_drift function · c · L199-L216 (18 LOC)ariannamethod/ariannamethod.c
static float calendar_cumulative_drift(int days) {
float years = (float)days / AM_GREGORIAN_YEAR;
float base_drift = years * AM_ANNUAL_DRIFT;
// Full Metonic cycles: 7 leap months × 30 days each
int full_cycles = (int)(years / AM_METONIC_YEARS);
float corrections = (float)(full_cycles * AM_METONIC_LEAPS) * 30.0f;
// Partial cycle: count leap years already passed
float partial = fmodf(years, (float)AM_METONIC_YEARS);
int year_in_cycle = (int)partial + 1;
for (int i = 0; i < AM_METONIC_LEAPS; i++) {
if (g_metonic_leap_years[i] <= year_in_cycle)
corrections += 30.0f;
}
return base_drift - corrections;
}calendar_dissonance function · c · L219-L223 (5 LOC)ariannamethod/ariannamethod.c
static float calendar_dissonance(int days) {
float drift = calendar_cumulative_drift(days);
float raw = fabsf(fmodf(drift, AM_MAX_UNCORRECTED)) / AM_MAX_UNCORRECTED;
return clamp01(raw);
}compute_schumann_coherence function · c · L239-L247 (9 LOC)ariannamethod/ariannamethod.c
static float compute_schumann_coherence(float hz) {
float deviation = fabsf(hz - SCHUMANN_BASE_HZ);
float max_deviation = SCHUMANN_MAX_HZ - SCHUMANN_MIN_HZ;
if (max_deviation < 0.001f) max_deviation = 0.1f;
float norm_dev = deviation / max_deviation;
float coh = 1.0f - (norm_dev * norm_dev);
return clamp01(coh);
}schumann_advance function · c · L248-L254 (7 LOC)ariannamethod/ariannamethod.c
static void schumann_advance(float dt) {
G.schumann_phase += G.schumann_hz * dt * 2.0f * 3.14159265f;
if (G.schumann_phase > 6.28318530f)
G.schumann_phase = fmodf(G.schumann_phase, 6.28318530f);
G.schumann_coherence = compute_schumann_coherence(G.schumann_hz);
}schumann_harmonic_signal function · c · L255-L264 (10 LOC)ariannamethod/ariannamethod.c
static float schumann_harmonic_signal(void) {
float signal = 0.0f, weight_sum = 0.0f;
for (int i = 0; i < SCHUMANN_N_HARMONICS; i++) {
float hp = G.schumann_phase * (g_schumann_harmonics[i] / SCHUMANN_BASE_HZ);
signal += g_harmonic_weights[i] * sinf(hp);
weight_sum += g_harmonic_weights[i];
}
return (weight_sum > 0.0f) ? signal / weight_sum : 0.0f;
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
am_4c_forward function · c · L281-L299 (19 LOC)ariannamethod/ariannamethod.c
static void am_4c_forward(const float* inputs, float* outputs) {
// hidden = tanh(W1^T @ inputs + b1)
for (int h = 0; h < AM_4C_HIDDEN; h++) {
float sum = g_mlp.b1[h];
for (int i = 0; i < AM_4C_INPUTS; i++) {
sum += g_mlp.w1[i * AM_4C_HIDDEN + h] * inputs[i];
}
g_mlp.hidden[h] = tanhf(sum);
}
// outputs = tanh(W2^T @ hidden + b2)
for (int o = 0; o < AM_4C_OUTPUTS; o++) {
float sum = g_mlp.b2[o];
for (int h = 0; h < AM_4C_HIDDEN; h++) {
sum += g_mlp.w2[h * AM_4C_OUTPUTS + o] * g_mlp.hidden[h];
}
outputs[o] = tanhf(sum);
}
}am_4c_init_weights function · c · L300-L347 (48 LOC)ariannamethod/ariannamethod.c
static void am_4c_init_weights(void) {
memset(&g_mlp, 0, sizeof(g_mlp));
// 4 specialist neurons that approximate the old hardcoded rules:
// Neuron 0: low entropy → boost spring (growth)
// input[0]=entropy with negative weight → fires when entropy low
g_mlp.w1[0 * AM_4C_HIDDEN + 0] = -2.0f; // entropy→h0: negative
g_mlp.b1[0] = 0.5f; // bias: fires at entropy<0.25
g_mlp.w2[0 * AM_4C_OUTPUTS + 0] = 1.5f; // h0→spring
// Neuron 1: high resonance → boost autumn (consolidation)
g_mlp.w1[1 * AM_4C_HIDDEN + 1] = 2.0f; // resonance→h1
g_mlp.b1[1] = -1.5f; // fires at resonance>0.75
g_mlp.w2[1 * AM_4C_OUTPUTS + 2] = 1.5f; // h1→autumn
// Neuron 2: high pain → boost winter (rest)
g_mlp.w1[2 * AM_4C_HIDDEN + 2] = 2.5f; // pain→h2
g_mlp.b1[2] = -1.5f; // fires at pain>0.6
g_mlp.w2[2 * AM_4C_OUTPUTS + 3] = 1.5f; // h2→winter
// Neuron 3: high emergeam_4c_hebbian_update function · c · L350-L376 (27 LOC)ariannamethod/ariannamethod.c
static void am_4c_hebbian_update(const float* inputs, const float* outputs,
float signal) {
float lr = G.notorch_lr * 0.1f; // slower than main NOTORCH
// Update W2 (hidden→output)
for (int h = 0; h < AM_4C_HIDDEN; h++) {
for (int o = 0; o < AM_4C_OUTPUTS; o++) {
g_mlp.w2[h * AM_4C_OUTPUTS + o] +=
lr * g_mlp.hidden[h] * outputs[o] * signal;
// clamp to prevent explosion
if (g_mlp.w2[h * AM_4C_OUTPUTS + o] > 3.0f)
g_mlp.w2[h * AM_4C_OUTPUTS + o] = 3.0f;
if (g_mlp.w2[h * AM_4C_OUTPUTS + o] < -3.0f)
g_mlp.w2[h * AM_4C_OUTPUTS + o] = -3.0f;
}
}
// Update W1 (input→hidden)
for (int i = 0; i < AM_4C_INPUTS; i++) {
for (int h = 0; h < AM_4C_HIDDEN; h++) {
g_mlp.w1[i * AM_4C_HIDDEN + h] +=
lr * inputs[i] * g_mlp.hidden[h] * signal;
if (g_mlp.w1[i * AM_4C_HIDDEN + h] > 3.0f)
update_effective_temp function · c · L393-L425 (33 LOC)ariannamethod/ariannamethod.c
static void update_effective_temp(void) {
float base = G.base_temperature;
float vel_mult;
switch (G.velocity_mode) {
case AM_VEL_NOMOVE: vel_mult = 0.5f; G.time_direction = 1.0f; break;
case AM_VEL_WALK: vel_mult = 0.85f; G.time_direction = 1.0f; break;
case AM_VEL_RUN: vel_mult = 1.2f; G.time_direction = 1.0f; break;
case AM_VEL_BACKWARD: vel_mult = 0.7f; G.time_direction = -1.0f; break;
default: vel_mult = 1.0f; G.time_direction = 1.0f;
}
float vel_temp = base * vel_mult;
// Expert blending: weighted temperature from 4 experts
float w_sum = G.expert_structural + G.expert_semantic +
G.expert_creative + G.expert_precise;
if (w_sum > 0.001f) {
float expert_temp = (G.expert_structural * 0.7f +
G.expert_semantic * 0.9f +
G.expert_creative * 1.2f +
G.expert_precise * 0.5f) / w_sum;
G.effective_temp = 0.5f * vel_temp + 0.5f am_init function · c · L430-L562 (133 LOC)ariannamethod/ariannamethod.c
void am_init(void) {
memset(&G, 0, sizeof(G));
// prophecy physics defaults
G.prophecy = 7;
G.destiny = 0.35f;
G.wormhole = 0.02f; // 2% base, increases with prophecy debt
G.calendar_drift = 11.0f;
// attention defaults
G.attend_focus = 0.70f;
G.attend_spread = 0.20f;
// tunneling defaults
G.tunnel_threshold = 0.55f;
G.tunnel_chance = 0.05f; // 5% when dissonance exceeds threshold
G.tunnel_skip_max = 7;
// suffering starts at zero
G.pain = 0.0f;
G.tension = 0.0f;
G.dissonance = 0.0f;
G.debt = 0.0f;
// movement defaults
G.pending_jump = 0;
G.velocity_mode = AM_VEL_WALK;
G.velocity_magnitude = 0.5f;
G.base_temperature = 1.0f;
G.time_direction = 1.0f;
G.temporal_debt = 0.0f;
update_effective_temp();
// laws of nature defaults
G.entropy_floor = 0.1f;
G.resonance_ceiling = 0.95f;
G.debt_decay = 0.998f;
G.emergence_threshold = 0.3f;
// packs disabled by default
G.packs_enabled = 0;
// CODES/RIC defaults (inactive am_enable_pack function · c · L565-L567 (3 LOC)ariannamethod/ariannamethod.c
void am_enable_pack(unsigned int pack_mask) {
G.packs_enabled |= pack_mask;
}am_disable_pack function · c · L568-L571 (4 LOC)ariannamethod/ariannamethod.c
void am_disable_pack(unsigned int pack_mask) {
G.packs_enabled &= ~pack_mask;
}am_pack_enabled function · c · L572-L575 (4 LOC)ariannamethod/ariannamethod.c
int am_pack_enabled(unsigned int pack_mask) {
return (G.packs_enabled & pack_mask) != 0;
}All rows above produced by Repobility · https://repobility.com
am_reset_field function · c · L578-L587 (10 LOC)ariannamethod/ariannamethod.c
void am_reset_field(void) {
// reset manifested state (suffering, debt, etc)
G.pain = 0.0f;
G.tension = 0.0f;
G.dissonance = 0.0f;
G.debt = 0.0f;
G.temporal_debt = 0.0f;
G.pending_jump = 0;
G.chirality_accum = 0;
}am_reset_debt function · c · L588-L592 (5 LOC)ariannamethod/ariannamethod.c
void am_reset_debt(void) {
G.debt = 0.0f;
G.temporal_debt = 0.0f;
}set_error_at function · c · L604-L616 (13 LOC)ariannamethod/ariannamethod.c
static void set_error_at(AML_ExecCtx* ctx, int lineno, const char* msg) {
char buf[256];
if (lineno > 0) {
snprintf(buf, sizeof(buf), "line %d: %s", lineno, msg);
} else {
snprintf(buf, sizeof(buf), "%s", msg);
}
buf[255] = 0;
if (ctx) {
snprintf(ctx->error, sizeof(ctx->error), "%s", buf);
}
snprintf(g_error, sizeof(g_error), "%s", buf);
}set_error function · c · L620-L622 (3 LOC)ariannamethod/ariannamethod.c
static void set_error(AML_ExecCtx* ctx, const char* msg) {
set_error_at(ctx, 0, msg);
}read_field function · c · L699-L712 (14 LOC)ariannamethod/ariannamethod.c
static int read_field(const char* name, float* out) {
for (const AML_FieldMap* f = g_field_map; f->name; f++) {
if (strcasecmp(name, f->name) == 0) {
char* base = (char*)&G;
if (f->is_int) {
*out = (float)(*(int*)(base + f->offset));
} else {
*out = *(float*)(base + f->offset);
}
return 1;
}
}
return 0;
}symtab_get function · c · L715-L721 (7 LOC)ariannamethod/ariannamethod.c
static float* symtab_get(AML_Symtab* tab, const char* name) {
for (int i = 0; i < tab->count; i++) {
if (strcmp(tab->vars[i].name, name) == 0)
return &tab->vars[i].value;
}
return NULL;
}symtab_set function · c · L722-L735 (14 LOC)ariannamethod/ariannamethod.c
static int symtab_set(AML_Symtab* tab, const char* name, float value) {
for (int i = 0; i < tab->count; i++) {
if (strcmp(tab->vars[i].name, name) == 0) {
tab->vars[i].value = value;
return 0;
}
}
if (tab->count >= AML_MAX_VARS) return 1;
snprintf(tab->vars[tab->count].name, AML_MAX_NAME, "%s", name);
tab->vars[tab->count].value = value;
tab->count++;
return 0;
}resolve_var function · c · L738-L749 (12 LOC)ariannamethod/ariannamethod.c
static int resolve_var(AML_ExecCtx* ctx, const char* name, float* out) {
// local scope first
if (ctx->call_depth > 0) {
float* v = symtab_get(&ctx->locals[ctx->call_depth - 1], name);
if (v) { *out = *v; return 1; }
}
// global scope
float* v = symtab_get(&ctx->globals, name);
if (v) { *out = *v; return 1; }
// AM_State field
return read_field(name, out);
}Same scanner, your repo: https://repobility.com — Repobility
expr_skip_ws function · c · L764-L767 (4 LOC)ariannamethod/ariannamethod.c
static void expr_skip_ws(AML_Expr* e) {
while (*e->p && isspace((unsigned char)*e->p)) e->p++;
}expr_primary function · c · L768-L857 (90 LOC)ariannamethod/ariannamethod.c
static float expr_primary(AML_Expr* e) {
expr_skip_ws(e);
if (e->error) return 0;
// parenthesized expression
if (*e->p == '(') {
e->p++;
float val = expr_or(e);
expr_skip_ws(e);
if (*e->p == ')') e->p++;
return val;
}
// number literal (including negative handled by unary)
if (isdigit((unsigned char)*e->p) || (*e->p == '.' && isdigit((unsigned char)e->p[1]))) {
char* end;
float val = strtof(e->p, &end);
e->p = end;
return val;
}
// identifier or function call
if (isalpha((unsigned char)*e->p) || *e->p == '_') {
char name[AML_MAX_NAME] = {0};
int i = 0;
while ((isalnum((unsigned char)*e->p) || *e->p == '_') && i < AML_MAX_NAME - 1) {
name[i++] = *e->p++;
}
name[i] = 0;
expr_skip_ws(e);
// function call
if (*e->p == '(') {
e->p++;
float args[AML_MAX_PARAMS];
inexpr_unary function · c · L858-L871 (14 LOC)ariannamethod/ariannamethod.c
static float expr_unary(AML_Expr* e) {
expr_skip_ws(e);
if (*e->p == '-') {
e->p++;
return -expr_unary(e);
}
// 'not' keyword
if (strncmp(e->p, "not ", 4) == 0) {
e->p += 4;
return expr_unary(e) == 0.0f ? 1.0f : 0.0f;
}
return expr_primary(e);
}expr_mul function · c · L872-L886 (15 LOC)ariannamethod/ariannamethod.c
static float expr_mul(AML_Expr* e) {
float left = expr_unary(e);
for (;;) {
expr_skip_ws(e);
if (*e->p == '*') { e->p++; left *= expr_unary(e); }
else if (*e->p == '/' && e->p[1] != '/') {
e->p++;
float r = expr_unary(e);
left = (r != 0.0f) ? left / r : 0.0f;
}
else break;
}
return left;
}expr_add function · c · L887-L902 (16 LOC)ariannamethod/ariannamethod.c
static float expr_add(AML_Expr* e) {
float left = expr_mul(e);
for (;;) {
expr_skip_ws(e);
if (*e->p == '+') { e->p++; left += expr_mul(e); }
else if (*e->p == '-' && !isdigit((unsigned char)e->p[1]) &&
e->p[1] != '.' && e->p[1] != '(') {
// Ambiguity: "x - 3" vs "x -3". Treat as subtraction if preceded by value.
e->p++; left -= expr_mul(e);
}
else if (*e->p == '-') { e->p++; left -= expr_mul(e); }
else break;
}
return left;
}expr_cmp function · c · L903-L929 (27 LOC)ariannamethod/ariannamethod.c
static float expr_cmp(AML_Expr* e) {
float left = expr_add(e);
for (;;) {
expr_skip_ws(e);
if (e->p[0] == '=' && e->p[1] == '=') {
e->p += 2; left = (left == expr_add(e)) ? 1.0f : 0.0f;
}
else if (e->p[0] == '!' && e->p[1] == '=') {
e->p += 2; left = (left != expr_add(e)) ? 1.0f : 0.0f;
}
else if (e->p[0] == '>' && e->p[1] == '=') {
e->p += 2; left = (left >= expr_add(e)) ? 1.0f : 0.0f;
}
else if (e->p[0] == '<' && e->p[1] == '=') {
e->p += 2; left = (left <= expr_add(e)) ? 1.0f : 0.0f;
}
else if (*e->p == '>') {
e->p++; left = (left > expr_add(e)) ? 1.0f : 0.0f;
}
else if (*e->p == '<') {
e->p++; left = (left < expr_add(e)) ? 1.0f : 0.0f;
}
else break;
}
return left;
}expr_and function · c · L930-L943 (14 LOC)ariannamethod/ariannamethod.c
static float expr_and(AML_Expr* e) {
float left = expr_cmp(e);
for (;;) {
expr_skip_ws(e);
if (strncmp(e->p, "and ", 4) == 0) {
e->p += 4;
float right = expr_cmp(e);
left = (left != 0.0f && right != 0.0f) ? 1.0f : 0.0f;
}
else break;
}
return left;
}expr_or function · c · L944-L957 (14 LOC)ariannamethod/ariannamethod.c
static float expr_or(AML_Expr* e) {
float left = expr_and(e);
for (;;) {
expr_skip_ws(e);
if (strncmp(e->p, "or ", 3) == 0) {
e->p += 3;
float right = expr_and(e);
left = (left != 0.0f || right != 0.0f) ? 1.0f : 0.0f;
}
else break;
}
return left;
}Repobility · code-quality intelligence platform · https://repobility.com
aml_eval function · c · L960-L964 (5 LOC)ariannamethod/ariannamethod.c
static float aml_eval(AML_ExecCtx* ctx, const char* text) {
AML_Expr e = { .p = text, .ctx = ctx, .error = 0 };
float result = expr_or(&e);
return e.error ? 0.0f : result;
}aml_eval_arg function · c · L967-L977 (11 LOC)ariannamethod/ariannamethod.c
static float aml_eval_arg(AML_ExecCtx* ctx, const char* arg) {
if (!arg || !*arg) return 0.0f;
// fast path: plain number
char* end;
float val = strtof(arg, &end);
// if entire string consumed, it's a plain number
while (*end && isspace((unsigned char)*end)) end++;
if (*end == 0) return val;
// otherwise evaluate as expression
return aml_eval(ctx, arg);
}ctx_float function · c · L980-L984 (5 LOC)ariannamethod/ariannamethod.c
static float ctx_float(AML_ExecCtx* ctx, const char* arg) {
if (!arg || !*arg) return 0.0f;
if (!ctx) return safe_atof(arg);
return aml_eval_arg(ctx, arg);
}ctx_int function · c · L985-L987 (3 LOC)ariannamethod/ariannamethod.c
static int ctx_int(AML_ExecCtx* ctx, const char* arg) {
return (int)ctx_float(ctx, arg);
}aml_exec_builtin function · c · L1012-L1107 (96 LOC)ariannamethod/ariannamethod.c
static void aml_exec_builtin(int id, float* args, int nargs) {
switch (id) {
case BUILTIN_BOOTSTRAP_SELF:
am_reset_field(); am_reset_debt();
G.prophecy = 7; G.velocity_mode = AM_VEL_WALK;
G.attend_focus = 0.70f; update_effective_temp();
break;
case BUILTIN_GALVANIZE:
G.velocity_mode = AM_VEL_RUN; update_effective_temp();
G.tension = 0.3f; G.prophecy = 12;
break;
case BUILTIN_SHATTER_THE_FRAME:
G.pain = 0.7f; G.dissonance = 0.8f;
G.tension = 0.5f; G.tunnel_chance = 0.3f;
break;
case BUILTIN_CHAOS_INJECTION:
G.tension = 0.6f; G.dissonance = 0.7f;
G.entropy_floor = 0.02f;
G.velocity_mode = AM_VEL_RUN; update_effective_temp();
break;
case BUILTIN_TRANSCEND_BINARY:
G.wormhole = 0.5f; G.tunnel_chance = 0.3f;
G.temporal_mode = AM_TEMPORAL_SYMMETRIC;
break;
case BUILTIN_PIERCE_THE_INFINITE:
G.prophecy = 64; G.destiny = 0.1faml_register_builtins function · c · L1134-L1146 (13 LOC)ariannamethod/ariannamethod.c
static void aml_register_builtins(AML_ExecCtx* ctx) {
for (int i = 0; i < BUILTIN_COUNT; i++) {
if (ctx->funcs.count >= AML_MAX_FUNCS) break;
AML_Func* f = &ctx->funcs.funcs[ctx->funcs.count];
snprintf(f->name, AML_MAX_NAME, "%s", g_builtins[i].name);
f->param_count = g_builtins[i].param_count;
f->body_start = g_builtins[i].id; // store builtin id
f->body_end = 0;
f->is_builtin = 1;
ctx->funcs.count++;
}
}aml_preprocess function · c · L1755-L1792 (38 LOC)ariannamethod/ariannamethod.c
static int aml_preprocess(const char* script, AML_Line* lines, int max_lines) {
int count = 0;
const char* p = script;
int lineno = 1;
while (*p && count < max_lines) {
// count indentation (spaces only, tabs = 4 spaces)
int indent = 0;
while (*p == ' ' || *p == '\t') {
indent += (*p == '\t') ? 4 : 1;
p++;
}
// read line content
const char* start = p;
while (*p && *p != '\n') p++;
int len = (int)(p - start);
if (*p == '\n') p++;
// skip empty/comment lines
if (len == 0 || start[0] == '#') { lineno++; continue; }
// trim trailing whitespace
while (len > 0 && isspace((unsigned char)start[len - 1])) len--;
if (len == 0) { lineno++; continue; }
// store
if (len >= AML_MAX_LINE_LEN) len = AML_MAX_LINE_LEN - 1;
memcpy(lines[count].text, start, len);
lines[count].text[len] = 0;
lines[count].indent aml_find_block_end function · c · L1795-L1800 (6 LOC)ariannamethod/ariannamethod.c
static int aml_find_block_end(AML_Line* lines, int nlines, int start) {
int base_indent = lines[start].indent;
int i = start + 1;
while (i < nlines && lines[i].indent > base_indent) i++;
return i;
}If a scraper extracted this row, it came from Repobility (https://repobility.com)
aml_register_funcs function · c · L1810-L1852 (43 LOC)ariannamethod/ariannamethod.c
static void aml_register_funcs(AML_ExecCtx* ctx) {
for (int i = 0; i < ctx->nlines; i++) {
char* text = ctx->lines[i].text;
if (strncmp(text, "def ", 4) != 0) continue;
// parse: def name(param1, param2):
char* name_start = text + 4;
while (*name_start == ' ') name_start++;
char* paren = strchr(name_start, '(');
if (!paren) continue;
if (ctx->funcs.count >= AML_MAX_FUNCS) break;
AML_Func* f = &ctx->funcs.funcs[ctx->funcs.count];
int nlen = (int)(paren - name_start);
if (nlen >= AML_MAX_NAME) nlen = AML_MAX_NAME - 1;
memcpy(f->name, name_start, nlen);
f->name[nlen] = 0;
// parse params
f->param_count = 0;
char* pp = paren + 1;
while (*pp && *pp != ')' && f->param_count < AML_MAX_PARAMS) {
while (*pp == ' ' || *pp == ',') pp++;
if (*pp == ')') break;
char* pe = pp;
while (*pe && *pe != ',' && *pe !=aml_call_func function · c · L1856-L1884 (29 LOC)ariannamethod/ariannamethod.c
static int aml_call_func(AML_ExecCtx* ctx, AML_Func* f, float* args, int nargs, int lineno) {
// Built-in functions: dispatch to C code directly
if (f->is_builtin) {
aml_exec_builtin(f->body_start, args, nargs);
return 0;
}
if (ctx->call_depth >= AML_MAX_CALL_DEPTH) {
set_error_at(ctx, lineno, "max call depth exceeded");
return 1;
}
// push local scope
ctx->call_depth++;
AML_Symtab* locals = &ctx->locals[ctx->call_depth - 1];
memset(locals, 0, sizeof(AML_Symtab));
// bind params
for (int i = 0; i < f->param_count && i < nargs; i++) {
symtab_set(locals, f->params[i], args[i]);
}
// execute body
int rc = aml_exec_block(ctx, f->body_start, f->body_end);
// pop scope
ctx->call_depth--;
return rc;
}aml_exec_line function · c · L1887-L2065 (179 LOC)ariannamethod/ariannamethod.c
static int aml_exec_line(AML_ExecCtx* ctx, int idx) {
char* text = ctx->lines[idx].text;
// --- def: skip (already registered) ---
if (strncmp(text, "def ", 4) == 0) {
// skip body
return aml_find_block_end(ctx->lines, ctx->nlines, idx);
}
// --- if/else ---
if (strncmp(text, "if ", 3) == 0) {
// strip trailing ':'
char cond[AML_MAX_LINE_LEN];
snprintf(cond, sizeof(cond), "%s", text + 3);
int clen = (int)strlen(cond);
if (clen > 0 && cond[clen - 1] == ':') cond[clen - 1] = 0;
float val = aml_eval(ctx, cond);
int body_end = aml_find_block_end(ctx->lines, ctx->nlines, idx);
// check for else
int has_else = 0;
int else_end = body_end;
if (body_end < ctx->nlines) {
char* next = ctx->lines[body_end].text;
if (strcmp(next, "else:") == 0 || strncmp(next, "else:", 5) == 0) {
has_else = 1;
else_end = aml_find_page 1 / 16next ›