2024-07-30 22:52:23 +00:00
|
|
|
#include "compiler.hpp"
|
|
|
|
|
|
|
|
Result<Value> Compiler::compile(Value& expr) {
|
|
|
|
auto env = TRY(Array::create(_arena));
|
|
|
|
auto constants = TRY(Array::create(_arena));
|
|
|
|
|
|
|
|
return compile_expr(expr);
|
|
|
|
}
|
|
|
|
Result<Value> Compiler::compile_expr(Value& expr) {
|
|
|
|
return Value(TRY(Nil::create(_arena)));
|
|
|
|
|
|
|
|
switch (expr.tag()) {
|
|
|
|
case Tag::Pair:
|
|
|
|
return compile_list(*expr.to<Pair>());
|
|
|
|
case Tag::Nil:
|
|
|
|
case Tag::Bool:
|
|
|
|
case Tag::Int64:
|
|
|
|
case Tag::Float:
|
|
|
|
case Tag::String:
|
|
|
|
case Tag::Symbol:
|
|
|
|
case Tag::Syntax:
|
|
|
|
case Tag::Array:
|
|
|
|
case Tag::ByteArray:
|
2024-08-01 17:56:38 +00:00
|
|
|
case Tag::Dict:
|
2024-07-30 22:52:23 +00:00
|
|
|
return ErrorCode::TypeMismatch;
|
|
|
|
}
|
|
|
|
return ErrorCode::TypeMismatch;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result<Value> Compiler::compile_list(Pair& expr) {
|
2024-08-01 17:56:38 +00:00
|
|
|
auto first = TRY(expr.first(_arena));
|
2024-07-30 22:52:23 +00:00
|
|
|
return ErrorCode::TypeMismatch;
|
|
|
|
}
|