Created
May 13, 2022 23:21
-
-
Save linkdd/2c69f4e4e1dad752a1704ed2ac0dd678 to your computer and use it in GitHub Desktop.
First Letlang module compiled
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
#[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)) | |
} | |
} | |
} |
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
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