sage::targets::c

Struct C

Source
pub struct C;
Expand description

The type for the C target which implements the Target trait. This allows the compiler to target the C language.

Trait Implementations§

Source§

impl Architecture for C

Source§

fn supports_input(&self, i: &Input) -> bool

Whether or not the target architecture supports the given input (mode + channel).
Source§

fn supports_output(&self, o: &Output) -> bool

Whether or not the target architecture supports the given output (mode + channel).
Source§

fn op(&mut self, op: &CoreOp) -> String

Compile a CoreOp instruction.
Source§

fn std_op(&mut self, op: &StandardOp) -> Result<String, String>

Compile a StandardOp instruction.
Source§

fn end(&mut self, matching: &CoreOp, fun: Option<usize>) -> String

Compile an End instruction (with the matching If or While or Function)
Source§

fn declare_proc(&mut self, label_id: usize) -> String

Compile the declaration of a procedure.
Source§

fn name(&self) -> &str

The name of the target architecture.
Source§

fn version(&self) -> &str

The version of the target architecture.
Source§

fn supports_floats(&self) -> bool

Whether or not the target architecture supports floating point.
Source§

fn get(&mut self, src: &Input) -> Result<String, String>

Get a value from the given input stream (mode + channel).
Source§

fn put(&mut self, dst: &Output) -> Result<String, String>

Put a value to the given output stream (mode + channel).
Source§

fn peek(&mut self) -> Result<String, String>

Peek a value from the device connected to the program.
Source§

fn poke(&mut self) -> Result<String, String>

Poke a value to the device connected to the program.
Source§

fn prelude(&self, is_core: bool) -> Option<String>

The code before the program starts.
Source§

fn post_funs(&self, funs: Vec<i32>) -> Option<String>

The code after the function definitions.
Source§

fn postop(&self) -> Option<String>

The code after each instruction.
Source§

fn postlude(&self, _is_core: bool) -> Option<String>

The code after the program ends.
Source§

fn pre_funs(&self, _funs: Vec<i32>) -> Option<String>

The code before the function definitions.
Source§

fn indentation(&self) -> Option<String>

The string used for indentation.
Source§

impl CompiledTarget for C

Source§

fn build_op( &mut self, op: &CoreOp, matching_ops: &mut Vec<CoreOp>, matching_funs: &mut Vec<usize>, current_fun: &mut usize, indent: &mut usize, ) -> Result<String, String>

Source§

fn build_std_op( &mut self, std_op: &StandardOp, matching_ops: &mut Vec<CoreOp>, matching_funs: &mut Vec<usize>, current_fun: &mut usize, indent: &mut usize, ) -> Result<String, String>

Source§

fn build_core(&mut self, program: &CoreProgram) -> Result<String, String>

Compile the core variant of the machine code (must be implemented for every target).
Source§

fn build_std(&mut self, program: &StandardProgram) -> Result<String, String>

Compile the standard variant of the machine code (should be implemented for every target possible).
Source§

impl Default for C

Source§

fn default() -> C

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for C

§

impl RefUnwindSafe for C

§

impl Send for C

§

impl Sync for C

§

impl Unpin for C

§

impl UnwindSafe for C

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.