Make rune literal string value its value

This commit is contained in:
Sauyon Lee
2020-02-10 12:45:13 -08:00
parent ae96bd88bc
commit 74bb4f707d
2 changed files with 7 additions and 1 deletions

View File

@@ -220,7 +220,11 @@ class ImagLit extends @imaglit, BasicLit { }
/**
* A character literal.
*/
class CharLit extends @charlit, BasicLit { }
class CharLit extends @charlit, BasicLit {
// use the constant value of the literal as the string value, as the value we get from the
// compiler is an integer, meaning we would not otherwise have a string value for rune literals
override string getStringValue() { result = this.getValue() }
}
/**
* A string literal.

View File

@@ -18,7 +18,9 @@
| consts.go:32:29:32:36 | ...-... | 2.3 - 9.7i | (2.3 + -9.7i), (2589569785738035/1125899906842624 + -2730307274093363/281474976710656i) |
| consts.go:32:33:32:36 | 9.7i | 9.7i | (0 + 9.7i), (0 + 97/10i) |
| consts.go:33:3:33:5 | 'a' | 'a' | 97, 97 |
| consts.go:33:3:33:5 | 'a' | 'a' | a |
| consts.go:33:8:33:13 | '\\x8b' | '\\x8b' | 139, 139 |
| consts.go:33:8:33:13 | '\\x8b' | '\\x8b' | \ufffd |
| consts.go:33:16:33:38 | 3.141592653589793238462 | 3.141592653589793238462 | 3.141593, 1570796326794896619231/500000000000000000000 |
| consts.go:33:16:33:40 | ...*... | 3.141592653589793238462 * 8 | 25.132741, 884279719003555/35184372088832 |
| consts.go:33:40:33:40 | 8 | 8 | 8, 8 |