Implement multiplication and division
This commit is contained in:
		
							parent
							
								
									2586a3a17b
								
							
						
					
					
						commit
						063ac0946e
					
				@ -3248,6 +3248,12 @@ fn TypeIndex compute_type_integer_binary(Thread* thread, NodeIndex node_index)
 | 
			
		||||
            case NODE_INTEGER_SUBSTRACT:
 | 
			
		||||
                result = left_value - right_value;
 | 
			
		||||
                break;
 | 
			
		||||
            case NODE_INTEGER_MULTIPLY:
 | 
			
		||||
                result = left_value * right_value;
 | 
			
		||||
                break;
 | 
			
		||||
            case NODE_INTEGER_SIGNED_DIVIDE:
 | 
			
		||||
                result = left_value * right_value;
 | 
			
		||||
                break;
 | 
			
		||||
            case NODE_INTEGER_AND:
 | 
			
		||||
                result = left_value & right_value;
 | 
			
		||||
                break;
 | 
			
		||||
@ -3321,6 +3327,12 @@ global const NodeVirtualTable node_functions[NODE_COUNT] = {
 | 
			
		||||
    [NODE_INTEGER_SUBSTRACT] = {
 | 
			
		||||
        .compute_type = &compute_type_integer_binary,
 | 
			
		||||
    },
 | 
			
		||||
    [NODE_INTEGER_SIGNED_DIVIDE] = {
 | 
			
		||||
        .compute_type = &compute_type_integer_binary,
 | 
			
		||||
    },
 | 
			
		||||
    [NODE_INTEGER_MULTIPLY] = {
 | 
			
		||||
        .compute_type = &compute_type_integer_binary,
 | 
			
		||||
    },
 | 
			
		||||
    [NODE_INTEGER_AND] = {
 | 
			
		||||
        .compute_type = &compute_type_integer_binary,
 | 
			
		||||
    },
 | 
			
		||||
@ -4384,10 +4396,10 @@ fn NodeIndex analyze_multiplication(Thread* thread, Parser* parser, FunctionBuil
 | 
			
		||||
        switch (src.pointer[parser->i])
 | 
			
		||||
        {
 | 
			
		||||
            case '*':
 | 
			
		||||
                node_id = NODE_INTEGER_ADD;
 | 
			
		||||
                node_id = NODE_INTEGER_MULTIPLY;
 | 
			
		||||
                break;
 | 
			
		||||
            case '/':
 | 
			
		||||
                node_id = NODE_INTEGER_SUBSTRACT;
 | 
			
		||||
                node_id = NODE_INTEGER_SIGNED_DIVIDE;
 | 
			
		||||
                break;
 | 
			
		||||
            case '%':
 | 
			
		||||
                todo();
 | 
			
		||||
 | 
			
		||||
@ -11,6 +11,8 @@ no_optimization_flags=""
 | 
			
		||||
test_names=(
 | 
			
		||||
    "first"
 | 
			
		||||
    "add_sub"
 | 
			
		||||
    "mul"
 | 
			
		||||
    "div"
 | 
			
		||||
    "and"
 | 
			
		||||
    "or"
 | 
			
		||||
    "xor"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								tests/div.nat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/div.nat
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
fn main() s32
 | 
			
		||||
{
 | 
			
		||||
    return 0 / 1;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										4
									
								
								tests/mul.nat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/mul.nat
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
fn main() s32
 | 
			
		||||
{
 | 
			
		||||
    return 1 * 0;
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user