remove dbg msg, reduce precision in eval_expr(), add expr() resolution at end of translate()

This commit is contained in:
stefan schippers 2025-02-06 10:39:50 +01:00
parent 7926a833be
commit 53fda635c9
3 changed files with 11 additions and 3 deletions

View File

@ -93,7 +93,7 @@ exp: NUM { $$ = $1;}
static void get_expr(double x)
{
char xx[100];
my_snprintf(xx, S(xx), "%.16g", x);
my_snprintf(xx, S(xx), "%.15g", x);
my_mstrcat(_ALLOC_ID_, &ret, xx, NULL);
strptr = str;
}

View File

@ -4488,7 +4488,7 @@ const char *translate(int inst, const char* s)
}
if(strstr(value1, "expr(") == value1) {
char *ptr = strrchr(value1 + 5, ')');
dbg(0, "translate(): expr():%s\n", value1);
dbg(1, "translate(): expr():%s\n", value1);
*ptr = '\0';
my_strdup2(_ALLOC_ID_, &value1, eval_expr(
translate3(value1 + 5, 1, xctx->inst[inst].prop_ptr, xctx->sym[xctx->inst[inst].ptr].templ, NULL)));
@ -4514,11 +4514,18 @@ const char *translate(int inst, const char* s)
} /* while(1) */
dbg(2, "translate(): returning %s\n", result);
my_free(_ALLOC_ID_, &token);
/* if result is like: 'tcleval(some_string)' pass it thru tcl evaluation so expressions
* can be calculated */
my_strdup2(_ALLOC_ID_, &translated_tok, spice_get_node(tcl_hook2(result)));
if(strstr(translated_tok, "expr(") == translated_tok) {
char *ptr = strrchr(translated_tok + 5, ')');
dbg(1, "translate(): expr():%s\n", translated_tok);
*ptr = '\0';
my_strdup2(_ALLOC_ID_, &translated_tok, eval_expr(
translate3(translated_tok + 5, 1, xctx->inst[inst].prop_ptr, xctx->sym[xctx->inst[inst].ptr].templ, NULL)));
}
return translated_tok;
}

View File

@ -59,3 +59,4 @@ T {@#3:net_name} 25 1.25 0 0 0.15 0.15 {layer=15 hide=instance}
T {tcleval(vgs=[to_eng \{@#1:spice_get_voltage - @#2:spice_get_voltage \}]
vds=[to_eng \{@#0:spice_get_voltage - @#2:spice_get_voltage \}])} 2.5 20 0 1 0.05 0.05 {layer=15 }
T {@spice_get_current} 35 20 0 0 0.15 0.15 {layer=17}
T {expr( @w + @l )} 50 -30 0 0 0.2 0.2 {}