-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb79a6f
commit 8dd9c48
Showing
5 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use crate::prelude::*; | ||
use crate::code_gen; | ||
|
||
pub type ResourceId = usize; | ||
|
||
pub struct Resources { | ||
pub members: Vec<Resource>, | ||
} | ||
|
||
impl Resources { | ||
pub fn new() -> Self { | ||
Self { | ||
members: Vec::new(), | ||
} | ||
} | ||
|
||
pub fn insert(&mut self, resource: Resource) -> ResourceId { | ||
let id = self.members.len(); | ||
self.members.push(resource); | ||
id | ||
} | ||
|
||
pub fn resource(&self, id: ResourceId) -> &Resource { | ||
&self.members[id] | ||
} | ||
|
||
pub fn resource_mut(&mut self, id: ResourceId) -> &mut Resource { | ||
&mut self.members[id] | ||
} | ||
} | ||
|
||
pub struct Resource { | ||
pub loc: CodeLoc, | ||
pub kind: ResourceKind, | ||
} | ||
|
||
impl Location for Resource { | ||
fn get_location(&self) -> CodeLoc { | ||
self.loc.clone() | ||
} | ||
} | ||
|
||
pub enum ResourceKind { | ||
Function { | ||
arguments: Vec<ScopeMemberId>, | ||
// argument_type_defs: Vec<Ast>, | ||
// argument_types: Vec<Option<TypeId>>, | ||
code: Ast, | ||
instructions: Option<(code_gen::Locals, Vec<code_gen::Instruction>)>, | ||
}, | ||
String(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{:main | ||
x := |x| x; | ||
x(6) | ||
x := { | ||
x + 5 | ||
}; | ||
x + 25 | ||
} |