character literal returns a number literal

This commit is contained in:
Andrew Kelley 2016-01-22 23:24:09 -07:00
parent e269caae02
commit bfceb18631
4 changed files with 14 additions and 25 deletions

View File

@ -3648,7 +3648,8 @@ static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import,
return_type = analyze_string_literal_expr(g, import, context, expected_type, node);
break;
case NodeTypeCharLiteral:
return_type = g->builtin_types.entry_u8;
return_type = resolve_expr_const_val_as_unsigned_num_lit(g, node, expected_type,
node->data.char_literal.value);
break;
case NodeTypeBoolLiteral:
return_type = resolve_expr_const_val_as_bool(g, node, node->data.bool_literal.value);

View File

@ -1828,12 +1828,6 @@ static LLVMValueRef gen_var_decl_expr(CodeGen *g, AstNode *node) {
get_resolved_expr(node)->block_context, false, &init_val);
}
static LLVMValueRef gen_error_literal(CodeGen *g, AstNode *node) {
assert(node->type == NodeTypeErrorLiteral);
zig_panic("TODO gen_error_literal");
}
static LLVMValueRef gen_symbol(CodeGen *g, AstNode *node) {
assert(node->type == NodeTypeSymbol);
VariableTableEntry *variable = node->data.symbol_expr.variable;
@ -1953,12 +1947,6 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
return gen_slice_expr(g, node);
case NodeTypeFieldAccessExpr:
return gen_field_access_expr(g, node, false);
case NodeTypeNullLiteral:
// caught by constant expression eval codegen
zig_unreachable();
case NodeTypeUndefinedLiteral:
// caught by constant expression eval codegen
zig_unreachable();
case NodeTypeIfBoolExpr:
return gen_if_bool_expr(g, node);
case NodeTypeIfVarExpr:
@ -1969,10 +1957,6 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
return gen_for_expr(g, node);
case NodeTypeAsmExpr:
return gen_asm_expr(g, node);
case NodeTypeErrorLiteral:
return gen_error_literal(g, node);
case NodeTypeCharLiteral:
return LLVMConstInt(LLVMInt8Type(), node->data.char_literal.value, false);
case NodeTypeSymbol:
return gen_symbol(g, node);
case NodeTypeBlock:
@ -2000,9 +1984,13 @@ static LLVMValueRef gen_expr(CodeGen *g, AstNode *node) {
return gen_container_init_expr(g, node);
case NodeTypeSwitchExpr:
return gen_switch_expr(g, node);
case NodeTypeErrorLiteral:
case NodeTypeNumberLiteral:
case NodeTypeBoolLiteral:
case NodeTypeStringLiteral:
case NodeTypeCharLiteral:
case NodeTypeNullLiteral:
case NodeTypeUndefinedLiteral:
// caught by constant expression eval codegen
zig_unreachable();
case NodeTypeRoot:

View File

@ -1,16 +1,16 @@
// Mersenne Twister
const ARRAY_SIZE : i16 = 624;
const ARRAY_SIZE = 624;
/// Use `rand_init` to initialize this state.
pub struct Rand {
array: [ARRAY_SIZE]u32,
index: @typeof(ARRAY_SIZE),
index: isize,
/// Initialize random state with the given seed.
pub fn init(r: &Rand, seed: u32) => {
r.index = 0;
r.array[0] = seed;
var i : @typeof(ARRAY_SIZE) = 1;
var i : isize = 1;
var prev_value: u64 = seed;
while (i < ARRAY_SIZE) {
r.array[i] = u32((prev_value ^ (prev_value << 30)) * 0x6c078965 + u32(i));

View File

@ -1,9 +1,9 @@
import "syscall.zig";
import "errno.zig";
pub const stdin_fileno : isize = 0;
pub const stdout_fileno : isize = 1;
pub const stderr_fileno : isize = 2;
pub const stdin_fileno = 0;
pub const stdout_fileno = 1;
pub const stderr_fileno = 2;
/*
pub var stdin = InStream {
@ -34,8 +34,8 @@ pub %.BadPerm;
pub %.PipeFail;
*/
//const buffer_size = 4 * 1024;
const max_u64_base10_digits: isize = 20;
const buffer_size = 4 * 1024;
const max_u64_base10_digits = 20;
/*
pub struct OutStream {