Browse Source

cargo fmt

master
Alison Watson 5 months ago
parent
commit
c0565b3f5d
6 changed files with 27 additions and 26 deletions
  1. +1
    -1
      source/framework/hal/sdl.rs
  2. +1
    -1
      source/framework/render.rs
  3. +3
    -3
      source/framework/vire/compiler.rs
  4. +5
    -6
      source/framework/vire/compiler/function.rs
  5. +11
    -11
      source/framework/vire/compiler/llvm.rs
  6. +6
    -4
      source/framework/vire/compiler/types.rs

+ 1
- 1
source/framework/hal/sdl.rs View File

@@ -1,5 +1,5 @@
use bitflags::bitflags;
use crate::ffi::Bool;
use bitflags::bitflags;
use std::os::raw;

pub const WINDOW_POS_UNDEF: raw::c_int = 0x1FFF0000;


+ 1
- 1
source/framework/render.rs View File

@@ -9,7 +9,7 @@ pub(self) use self::conf::Conf;
pub(self) use crate::{
data::{self, uniforms::Uniforms, vertex::Vertex},
hal::win::Window,
types::{sparse, stkvec, StkVec},
types::{stkvec, StkVec},
};
pub(self) use ash::{
extensions::khr,


+ 3
- 3
source/framework/vire/compiler.rs View File

@@ -1,8 +1,8 @@
pub mod function;
pub mod nat;
pub mod types;
#[doc(hidden)]
pub mod llvm;
pub mod nat;
pub mod types;

pub(self) use self::{function::*, types::*};
pub(self) use super::parser::Datum;
@@ -132,7 +132,7 @@ unsafe fn jit_engine(

if res.is_true() {
Err(Err::JitInit(
ffi::cstr_from_ptr(msg).unwrap_or("Couldn't parse error").to_owned()
ffi::cstr_from_ptr(msg).unwrap_or("Couldn't parse error").to_owned(),
))
} else {
Ok(jit)


+ 5
- 6
source/framework/vire/compiler/function.rs View File

@@ -31,7 +31,7 @@ impl<'a> IncompleteFunction<'a> {
}

pub fn compile(
&mut self, datum: &Datum
&mut self, datum: &Datum,
) -> Result<(*mut llvm::Type, *mut llvm::Value), Err> {
if !self.in_context {
return Err(Err::Context);
@@ -61,10 +61,8 @@ impl<'a> IncompleteFunction<'a> {
| Datum::Symb(name) => {
// TODO: must support more than global function symbols
let name = CString::new(name.as_bytes()).unwrap().into_raw();
let func = llvm::module_get_named_function(
self.contx.modul,
name,
);
let func =
llvm::module_get_named_function(self.contx.modul, name);
CString::from_raw(name);
Ok((llvm::value_type(func), func))
}
@@ -144,7 +142,8 @@ impl<'a> IncompleteFunction<'a> {
!llvm::value_verify_func(
self.value,
llvm::VerifierFailureAction::PrintMessage,
).is_true()
)
.is_true()
};

// it's okay if the sender errors because the receiver will only


+ 11
- 11
source/framework/vire/compiler/llvm.rs View File

@@ -55,23 +55,23 @@ extern "C" {

#[link_name = "LLVMAppendBasicBlockInContext"]
pub fn context_append_basic_block(
contx: *mut Context, func: *mut Value, name: *const raw::c_char
contx: *mut Context, func: *mut Value, name: *const raw::c_char,
) -> *mut BasicBlock;

// modules
#[link_name = "LLVMModuleCreateWithNameInContext"]
pub fn module_new_with_name_in_context(
module_id: *const raw::c_char, contx: *mut Context
module_id: *const raw::c_char, contx: *mut Context,
) -> *mut Module;

#[link_name = "LLVMAddFunction"]
pub fn module_add_function(
modul: *mut Module, name: *const raw::c_char, func_ty: *mut Type
modul: *mut Module, name: *const raw::c_char, func_ty: *mut Type,
) -> *mut Value;

#[link_name = "LLVMGetNamedFunction"]
pub fn module_get_named_function(
modul: *mut Module, name: *const raw::c_char
modul: *mut Module, name: *const raw::c_char,
) -> *mut Value;

// builders
@@ -84,7 +84,7 @@ extern "C" {
#[link_name = "LLVMBuildCall2"]
pub fn builder_call(
build: *mut Builder, ftyp: *mut Type, func: *mut Value,
args: *mut *mut Value, count: raw::c_uint, name: *const raw::c_char
args: *mut *mut Value, count: raw::c_uint, name: *const raw::c_char,
) -> *mut Value;

#[link_name = "LLVMBuildRetVoid"]
@@ -101,7 +101,7 @@ extern "C" {
pub fn engine_new_mcjit_compiler_for_module(
engin: *mut *mut ExecutionEngine, modul: *mut Module,
options: *mut McJitCompilerOptions, size_of_options: libc::size_t,
out_error: *mut *mut raw::c_char
out_error: *mut *mut raw::c_char,
) -> Bool;

#[link_name = "LLVMDisposeExecutionEngine"]
@@ -109,12 +109,12 @@ extern "C" {

#[link_name = "LLVMAddGlobalMapping"]
pub fn engine_add_global_mapping(
engin: *mut ExecutionEngine, value: *mut Value, addr: *mut raw::c_void
engin: *mut ExecutionEngine, value: *mut Value, addr: *mut raw::c_void,
);

#[link_name = "LLVMGetFunctionAddress"]
pub fn engine_get_function_address(
engin: *mut ExecutionEngine, name: *const raw::c_char
engin: *mut ExecutionEngine, name: *const raw::c_char,
) -> u64;

// types
@@ -127,7 +127,7 @@ extern "C" {
#[link_name = "LLVMFunctionType"]
pub fn type_function(
retn: *mut Type, params: *mut *mut Type, count: raw::c_uint,
is_var_arg: Bool
is_var_arg: Bool,
) -> *mut Type;

#[link_name = "LLVMVoidType"]
@@ -154,7 +154,7 @@ extern "C" {

#[link_name = "LLVMConstInt"]
pub fn value_const_int(
ty: *mut Type, num: libc::c_ulonglong, sign_extend: Bool
ty: *mut Type, num: libc::c_ulonglong, sign_extend: Bool,
) -> *mut Value;

#[link_name = "LLVMTypeOf"]
@@ -162,7 +162,7 @@ extern "C" {

#[link_name = "LLVMVerifyFunction"]
pub fn value_verify_func(
func: *mut Value, action: VerifierFailureAction
func: *mut Value, action: VerifierFailureAction,
) -> Bool;

// errors


+ 6
- 4
source/framework/vire/compiler/types.rs View File

@@ -87,10 +87,12 @@ impl BasicType {
| Basic::Void => llvm::type_void(),
| Basic::Bool => llvm::type_int1(),
| Basic::Q8_0 | Basic::Q8_0U => llvm::type_int8(),
| Basic::Q16_0 | Basic::Q16_0U
| Basic::Q16 | Basic::Q16U => llvm::type_int16(),
| Basic::Q32_0 | Basic::Q32_0U
| Basic::Q24_8 | Basic::Q24_8U => llvm::type_int32(),
| Basic::Q16_0 | Basic::Q16_0U | Basic::Q16 | Basic::Q16U => {
llvm::type_int16()
}
| Basic::Q32_0 | Basic::Q32_0U | Basic::Q24_8 | Basic::Q24_8U => {
llvm::type_int32()
}
| Basic::Q64_0 | Basic::Q64_0U => llvm::type_int64(),
}
};


Loading…
Cancel
Save