Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public virtual void Accept(FloatExpression expr) => Update(expr);
Ejemplo n.º 4
0
 public override void Accept(FloatExpression expr)
 {
     base.Accept(expr);
     CompileFloatExpression(expr);
 }