Skip to content

Commit eaec415

Browse files
committed
save trig-const-folding should now work
1 parent eff0bda commit eaec415

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

‎src/main/java/com/github/gbenroscience/parser/MathExpression.java‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -452,27 +452,18 @@ private void refixCommas() {
452452
public DRG_MODE getDRG() {
453453
return DRG;
454454
}
455-
456-
/**
457-
* sets the DRG property
458-
*
459-
* @param DRG
460-
*/
455+
461456
public void setDRG(DRG_MODE DRG) {
462457
if (DRG != this.DRG) {
463-
for (int i = 0; i < cachedPostfix.length; i++) {
464-
Token t = cachedPostfix[i];
465-
if (t.kind == Token.METHOD) {
466-
if (t.name.endsWith("_deg") || t.name.endsWith("_rad") || t.name.endsWith("_grad")) {
467-
String name = t.name.substring(0, t.name.lastIndexOf("_"));
468-
t.name = Declarations.getTrigFuncDRGVariant(name, DRG);
469-
t.id = MethodRegistry.getMethodID(t.name);
470-
t.action = MethodRegistry.getAction(t.id);
471-
}
472-
}
458+
this.DRG = DRG;
459+
this.cachedPostfix = null; // Invalidate cache
460+
this.poolPointer = 0;
461+
462+
// Recompile for new mode if we have a valid expression
463+
if (scanner != null && !scanner.isEmpty() && correctFunction) {
464+
compileToPostfix();
473465
}
474466
}
475-
this.DRG = DRG;
476467
}
477468

478469
public void setDRG(int mode) {

0 commit comments

Comments
 (0)