private ScriptVarLink Base(ref bool execute) { ScriptVarLink a = Ternary(ref execute); if (_currentLexer.TokenType == (ScriptLex.LexTypes) '=' || _currentLexer.TokenType == ScriptLex.LexTypes.PlusEqual || _currentLexer.TokenType == ScriptLex.LexTypes.MinusEqual) { if (execute && a.Owned) { if (a.Name.Length > 0) { ScriptVarLink aReal = Root.AddChildNoDup(a.Name, a.Var); a = aReal; } else { // Hit an unknow error here #if !WINDOWS_UWP System.Diagnostics.Trace.TraceWarning("Trying to assign to an unnamed type..."); #endif } } ScriptLex.LexTypes op = _currentLexer.TokenType; _currentLexer.Match(op); ScriptVarLink b = Base(ref execute); if (execute) { switch (op) { case (ScriptLex.LexTypes) '=': a.ReplaceWith(b); break; case ScriptLex.LexTypes.PlusEqual: { ScriptVar res = a.Var.MathsOp(b.Var, (ScriptLex.LexTypes) '+'); a.ReplaceWith(res); } break; case ScriptLex.LexTypes.MinusEqual: { ScriptVar res = a.Var.MathsOp(b.Var, (ScriptLex.LexTypes) '-'); a.ReplaceWith(res); } break; default: throw new ScriptException("Base broke"); } } } return(a); }
private ScriptVarLink Base(ref bool execute) { var leftHandSide = Ternary(ref execute); if (currentLexer.TokenType == (ScriptLex.LexTypes) '=' || currentLexer.TokenType == ScriptLex.LexTypes.PlusEqual || currentLexer.TokenType == ScriptLex.LexTypes.MinusEqual || currentLexer.TokenType == ScriptLex.LexTypes.SlashEqual || currentLexer.TokenType == ScriptLex.LexTypes.PercentEqual) { if (execute && leftHandSide.Owned == false) { if (leftHandSide.Name.Length > 0) { var leftHandSideReal = Root.AddChildNoDup(leftHandSide.Name, leftHandSide.Var); leftHandSide = leftHandSideReal; } else { //?wtf? System.Diagnostics.Trace.TraceWarning("Trying to assign to an unnamed type..."); } } var op = currentLexer.TokenType; currentLexer.Match(op); var rightHandSide = Base(ref execute); if (execute) { switch (op) { case (ScriptLex.LexTypes) '=': { leftHandSide.ReplaceWith(rightHandSide); } break; case ScriptLex.LexTypes.PlusEqual: { var res = leftHandSide.Var.MathsOp(rightHandSide.Var, (ScriptLex.LexTypes) '+'); leftHandSide.ReplaceWith(res); } break; case ScriptLex.LexTypes.MinusEqual: { var res = leftHandSide.Var.MathsOp(rightHandSide.Var, (ScriptLex.LexTypes) '-'); leftHandSide.ReplaceWith(res); } break; case ScriptLex.LexTypes.SlashEqual: { var res = leftHandSide.Var.MathsOp(rightHandSide.Var, (ScriptLex.LexTypes) '/'); leftHandSide.ReplaceWith(res); } break; case ScriptLex.LexTypes.PercentEqual: { var res = leftHandSide.Var.MathsOp(rightHandSide.Var, (ScriptLex.LexTypes) '%'); leftHandSide.ReplaceWith(res); } break; default: throw new ScriptException("Base broke"); } } } return(leftHandSide); }