mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
moved Ownership to borrow
This commit is contained in:
parent
a11d94aee2
commit
b28b32cdc4
8 changed files with 23 additions and 19 deletions
|
@ -9,7 +9,8 @@ use roc_collections::all::{MutMap, MutSet};
|
|||
use roc_error_macros::internal_error;
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_mono::{
|
||||
ir::{JoinPointId, Ownership, Param},
|
||||
borrow::Ownership,
|
||||
ir::{JoinPointId, Param},
|
||||
layout::{Builtin, Layout, STLayoutInterner, TagIdIntType, UnionLayout},
|
||||
};
|
||||
use roc_target::TargetInfo;
|
||||
|
|
|
@ -2,8 +2,7 @@ use std::collections::HashMap;
|
|||
use std::hash::Hash;
|
||||
|
||||
use crate::ir::{
|
||||
Expr, HigherOrderLowLevel, JoinPointId, Ownership, Param, PassedFunction, Proc, ProcLayout,
|
||||
Stmt,
|
||||
Expr, HigherOrderLowLevel, JoinPointId, Param, PassedFunction, Proc, ProcLayout, Stmt,
|
||||
};
|
||||
use crate::layout::Layout;
|
||||
use bumpalo::collections::Vec;
|
||||
|
@ -16,6 +15,12 @@ use roc_module::symbol::Symbol;
|
|||
pub(crate) const OWNED: bool = false;
|
||||
pub(crate) const BORROWED: bool = true;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Ownership {
|
||||
Owned,
|
||||
Borrowed,
|
||||
}
|
||||
|
||||
/// For reference-counted types (lists, (big) strings, recursive tags), owning a value
|
||||
/// means incrementing its reference count. Hence, we prefer borrowing for these types
|
||||
fn should_borrow_layout(layout: &Layout) -> bool {
|
||||
|
@ -107,7 +112,7 @@ pub struct ParamOffset(usize);
|
|||
|
||||
impl From<ParamOffset> for usize {
|
||||
fn from(id: ParamOffset) -> Self {
|
||||
id.0 as usize
|
||||
id.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,7 +426,7 @@ impl<'a> BorrowInfState<'a> {
|
|||
start: ParamOffset,
|
||||
length: usize,
|
||||
) {
|
||||
let index: usize = start.into();
|
||||
let ParamOffset(index) = start;
|
||||
let ps = &mut param_map.declarations[index..][..length];
|
||||
|
||||
for p in ps.iter_mut() {
|
||||
|
|
|
@ -3,8 +3,9 @@ use roc_intern::Interner;
|
|||
use roc_module::low_level::LowLevel;
|
||||
use roc_module::symbol::{IdentIds, Symbol};
|
||||
|
||||
use crate::borrow::Ownership;
|
||||
use crate::ir::{
|
||||
BranchInfo, Call, CallType, Expr, JoinPointId, Literal, Ownership, Param, Stmt, UpdateModeId,
|
||||
BranchInfo, Call, CallType, Expr, JoinPointId, Literal, Param, Stmt, UpdateModeId,
|
||||
};
|
||||
use crate::layout::{Builtin, InLayout, Layout, STLayoutInterner, TagIdIntType, UnionLayout};
|
||||
|
||||
|
|
|
@ -7,10 +7,10 @@ use roc_module::low_level::{LowLevel, LowLevel::*};
|
|||
use roc_module::symbol::{IdentIds, Symbol};
|
||||
use roc_target::PtrWidth;
|
||||
|
||||
use crate::borrow::Ownership;
|
||||
use crate::code_gen_help::let_lowlevel;
|
||||
use crate::ir::{
|
||||
BranchInfo, Call, CallType, Expr, JoinPointId, Literal, ModifyRc, Ownership, Param, Stmt,
|
||||
UpdateModeId,
|
||||
BranchInfo, Call, CallType, Expr, JoinPointId, Literal, ModifyRc, Param, Stmt, UpdateModeId,
|
||||
};
|
||||
use crate::layout::{Builtin, InLayout, Layout, STLayoutInterner, TagIdIntType, UnionLayout};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use crate::borrow::Ownership;
|
||||
use crate::ir::{
|
||||
build_list_index_probe, BranchInfo, Call, CallType, DestructType, Env, Expr, JoinPointId,
|
||||
ListIndex, Literal, Ownership, Param, Pattern, Procs, Stmt,
|
||||
ListIndex, Literal, Param, Pattern, Procs, Stmt,
|
||||
};
|
||||
use crate::layout::{Builtin, Layout, LayoutCache, LayoutInterner, TagIdIntType, UnionLayout};
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::borrow::{ParamMap, BORROWED, OWNED};
|
||||
use crate::borrow::{Ownership, ParamMap, BORROWED, OWNED};
|
||||
use crate::ir::{
|
||||
CallType, Expr, HigherOrderLowLevel, JoinPointId, ModifyRc, Ownership, Param, Proc, ProcLayout,
|
||||
Stmt, UpdateModeIds,
|
||||
CallType, Expr, HigherOrderLowLevel, JoinPointId, ModifyRc, Param, Proc, ProcLayout, Stmt,
|
||||
UpdateModeIds,
|
||||
};
|
||||
use crate::layout::{Layout, STLayoutInterner};
|
||||
use bumpalo::collections::Vec;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#![allow(clippy::manual_map)]
|
||||
|
||||
use crate::borrow::Ownership;
|
||||
use crate::layout::{
|
||||
self, Builtin, ClosureCallOptions, ClosureRepresentation, EnumDispatch, LambdaName, LambdaSet,
|
||||
Layout, LayoutCache, LayoutProblem, Niche, RawFunctionLayout, STLayoutInterner, TagIdIntType,
|
||||
|
@ -1523,12 +1524,6 @@ impl<'a, 'i> Env<'a, 'i> {
|
|||
#[derive(Clone, Debug, PartialEq, Copy, Eq, Hash)]
|
||||
pub struct JoinPointId(pub Symbol);
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Ownership {
|
||||
Owned,
|
||||
Borrowed,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct Param<'a> {
|
||||
pub symbol: Symbol,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#![allow(clippy::manual_map)]
|
||||
|
||||
use crate::ir::{CallType, Expr, JoinPointId, Ownership, Param, Stmt};
|
||||
use crate::borrow::Ownership;
|
||||
use crate::ir::{CallType, Expr, JoinPointId, Param, Stmt};
|
||||
use crate::layout::{LambdaName, Layout};
|
||||
use bumpalo::collections::Vec;
|
||||
use bumpalo::Bump;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue