First 0.7 update, removing all deprecated features.

This commit is contained in:
Christoffer Lerno
2025-02-27 14:16:36 +01:00
committed by Christoffer Lerno
parent cff6697818
commit 2a895ec7be
1589 changed files with 2635 additions and 115363 deletions

View File

@@ -1,12 +1,11 @@
// #target: macos-x64
// #deprecation: no
<* @require Type.kindof == STRUCT *>
module abc(<Type>);
module abc{Type};
import std::io;
import std::collections::list;
def TextTagList = List(<TextTag>);
def TextTagList = List{TextTag};
fault TextError
{
@@ -47,7 +46,6 @@ struct TextTag
*>
fn void! TextTemplate.init(&self, String template, String tag_start = "{{", String tag_end = "}}", Allocator using = allocator::heap())
{
TextTagList tags;
String tmpl = template;
uptr data = (uptr)&self.data;
@@ -62,29 +60,34 @@ fn void! TextTemplate.init(&self, String template, String tag_start = "{{", Stri
String name = tmpl[:end].trim();
if (name == "") return TextError.EMPTY_TAG?;
// Check that the tag exists in the data struct.
TextTag tag = {|
TextTag tag @noinit;
do OUTER:
{
$foreach ($m : Type.membersof)
if (name == $m.nameof)
{
$switch ($m.typeid)
$case String.typeid:
return (TextTag){
tag = {
.kind = STRING,
.data = (String*)(data + $m.offsetof),
};
break OUTER;
$default:
$if $defined($m.get(self.data).as_stream):
return (TextTag){
tag = {
.kind = TEMPLATE,
.template = self.data.$eval($m.nameof).as_stream(),
};
break;
$endif
$endswitch
//return TextError.UNSUPPORTED_TAG?;
}
$endforeach
return TextError.MISSING_TAG?;
|}!;
};
tmpl = tmpl[end + tag_end.len..];
tag.start = start;
@@ -130,7 +133,7 @@ module text_test;
import abc;
import std::io;
def Tmpl = TextTemplate(<Data>);
def Tmpl = TextTemplate{Data};
struct Data
{
@@ -141,8 +144,8 @@ struct Data
def FooTmpl = TextTemplate(<Foo>);
def BarTmpl = TextTemplate(<Bar>);
def FooTmpl = TextTemplate{Foo};
def BarTmpl = TextTemplate{Bar};
struct Foo
{
@@ -218,7 +221,7 @@ panic_block: ; preds = %assign_optional
%8 = insertvalue %"any[]" undef, ptr %varargslots, 0
%"$$temp" = insertvalue %"any[]" %8, i64 1, 1
store %"any[]" %"$$temp", ptr %indirectarg2, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 161, ptr byval(%"any[]") align 8 %indirectarg2)
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file
unreachable
noerr_block: ; preds = %after_check
@@ -241,7 +244,7 @@ panic_block7: ; preds = %assign_optional5
%13 = insertvalue %"any[]" undef, ptr %varargslots8, 0
%"$$temp9" = insertvalue %"any[]" %13, i64 1, 1
store %"any[]" %"$$temp9", ptr %indirectarg10, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func, i64 4, i32 162, ptr byval(%"any[]") align 8 %indirectarg10)
call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 25, ptr @.func,
unreachable
noerr_block11: ; preds = %after_check6