From ff53669ed918c87d15ddea2d07fda84d4c8eff5d Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 28 Jun 2017 11:39:40 -0700 Subject: Store integer literals at high precision in AST The lexer was creating an `unsigned long long` value, and then the AST was storing it in an `int`. This change makes both use a `long long`. This is obviously still a stopgap until I can get arbitrary precisions in here. --- source/slang/emit.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source/slang/emit.cpp') diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 9a1d44641..dc7c68aa4 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -197,6 +197,14 @@ static void emitName(EmitContext* context, String const& name) emitName(context, name, CodePosition()); } +static void Emit(EmitContext* context, IntegerLiteralValue value) +{ + char buffer[32]; + sprintf(buffer, "%lld", value); + Emit(context, buffer); +} + + static void Emit(EmitContext* context, UInt value) { char buffer[32]; @@ -923,7 +931,7 @@ static void EmitExprWithPrecedence(EmitContext* context, RefPtrIntValue); + Emit(context, litExpr->integerValue); Emit(context, suffix); break; @@ -945,12 +953,12 @@ static void EmitExprWithPrecedence(EmitContext* context, RefPtrFloatValue); + Emit(context, litExpr->floatingPointValue); Emit(context, suffix); break; case ConstantExpressionSyntaxNode::ConstantType::Bool: - Emit(context, litExpr->IntValue ? "true" : "false"); + Emit(context, litExpr->integerValue ? "true" : "false"); break; case ConstantExpressionSyntaxNode::ConstantType::String: emitStringLiteral(context, litExpr->stringValue); -- cgit v1.2.3