void CompileFloatExpression(FloatExpression expr) { // Create a constant real // For the moment, doubles are used everywhere and cast // to float if requested. // That way we should not lose any information. var val = LLVM.ConstReal(LLVM.DoubleType(), expr.Value); Stack.Push(Symbol.CreateAnonymous(val)); }
FloatExpression ParseFloat() { var expr = FloatExpression.Create(unit.Location); var literal = unit.Expect(LoreToken.FloatLiteral).Value; // Try parsing the string double floatval; try { floatval = double.Parse(literal, NumberStyles.Float, NumberFormatInfo.InvariantInfo); } catch (Exception e) { throw LoreException.Create(unit.Location).Describe($"Failed to parse float literal: ${e.Message}"); } // Set the value and return expr.SetValue(floatval); return(expr); }
public virtual void Accept(FloatExpression expr) => Update(expr);
public override void Accept(FloatExpression expr) { base.Accept(expr); CompileFloatExpression(expr); }