Skip to content

Instantly share code, notes, and snippets.

@linkdd
Created May 13, 2022 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linkdd/2c69f4e4e1dad752a1704ed2ac0dd678 to your computer and use it in GitHub Desktop.
Save linkdd/2c69f4e4e1dad752a1704ed2ac0dd678 to your computer and use it in GitHub Desktop.
First Letlang module compiled
#[allow(unused_variables)]
#[allow(unused_imports)]
#[allow(dead_code)]
mod symbol_a {
use llcore_runtime::*;
pub fn const_a(context: Arc<Mutex<Context>>) -> Value {
Value::Primitive(PrimitiveValue::Number(42.0))
}
}
pub mod symbol_main {
use llcore_runtime::*;
#[allow(non_camel_case_types)]
pub struct func_main;
impl Function for func_main {
fn call(&self, context: Arc<Mutex<Context>>, args: Vec<Value>) -> FunctionContinuation {
async fn code_block(
co: FunctionCoroutine,
context: Arc<Mutex<Context>>,
args: Vec<Value>,
) -> Value {
let args_type = types::TupleType {
members_types: vec![],
};
let return_type = types::ValueType { llval: PrimitiveValue::Atom(context.lock().unwrap().get_atom("@ok")) };
let args_tuple = Value::Tuple(args);
utils::assert_type(
&co,
context.clone(),
&args_type,
&args_tuple,
format!("function main expected {}", args_type.to_string(context.clone())),
).await;
let result = Value::Primitive(PrimitiveValue::Atom(context.lock().unwrap().get_atom("@ok")));
utils::assert_type(
&co,
context.clone(),
&return_type,
&result,
format!("function main should return {}", return_type.to_string(context.clone())),
).await;
result
}
FunctionContinuation::new_boxed(|co| code_block(co, context, args))
}
}
}
module "hello.main";
const a := 42;
pub func main() -> @ok {
@ok;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment