parent
7c3636aaa3
commit
c06a61e9bf
@ -478,13 +478,9 @@ pub fn main() void {
|
|||||||
<td><code>undefined</code></td>
|
<td><code>undefined</code></td>
|
||||||
<td>used to leave a value unspecified</td>
|
<td>used to leave a value unspecified</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td><code>this</code></td>
|
|
||||||
<td>refers to the thing in immediate scope</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
{#see_also|Optionals|this#}
|
{#see_also|Optionals#}
|
||||||
{#header_close#}
|
{#header_close#}
|
||||||
{#header_open|String Literals#}
|
{#header_open|String Literals#}
|
||||||
{#code_begin|test#}
|
{#code_begin|test#}
|
||||||
@ -4186,11 +4182,6 @@ fn foo() void {}
|
|||||||
{#code_end#}
|
{#code_end#}
|
||||||
{#header_close#}
|
{#header_close#}
|
||||||
|
|
||||||
{#header_open|this#}
|
|
||||||
<p>TODO: example of this referring to Self struct</p>
|
|
||||||
<p>TODO: example of this referring to recursion function</p>
|
|
||||||
<p>TODO: example of this referring to basic block for @setRuntimeSafety</p>
|
|
||||||
{#header_close#}
|
|
||||||
{#header_open|comptime#}
|
{#header_open|comptime#}
|
||||||
<p>
|
<p>
|
||||||
Zig places importance on the concept of whether an expression is known at compile-time.
|
Zig places importance on the concept of whether an expression is known at compile-time.
|
||||||
@ -7744,7 +7735,7 @@ ArrayType : "[" option(Expression) "]" option("align" "(" Expression option(":"
|
|||||||
|
|
||||||
GroupedExpression = "(" Expression ")"
|
GroupedExpression = "(" Expression ")"
|
||||||
|
|
||||||
KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "this" | "unreachable" | "suspend"
|
KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "unreachable" | "suspend"
|
||||||
|
|
||||||
ErrorSetDecl = "error" "{" list(Symbol, ",") "}"
|
ErrorSetDecl = "error" "{" list(Symbol, ",") "}"
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ pub const Type = struct {
|
|||||||
Id.Enum => @fieldParentPtr(Enum, "base", base).destroy(comp),
|
Id.Enum => @fieldParentPtr(Enum, "base", base).destroy(comp),
|
||||||
Id.Union => @fieldParentPtr(Union, "base", base).destroy(comp),
|
Id.Union => @fieldParentPtr(Union, "base", base).destroy(comp),
|
||||||
Id.Namespace => @fieldParentPtr(Namespace, "base", base).destroy(comp),
|
Id.Namespace => @fieldParentPtr(Namespace, "base", base).destroy(comp),
|
||||||
Id.Block => @fieldParentPtr(Block, "base", base).destroy(comp),
|
|
||||||
Id.BoundFn => @fieldParentPtr(BoundFn, "base", base).destroy(comp),
|
Id.BoundFn => @fieldParentPtr(BoundFn, "base", base).destroy(comp),
|
||||||
Id.ArgTuple => @fieldParentPtr(ArgTuple, "base", base).destroy(comp),
|
Id.ArgTuple => @fieldParentPtr(ArgTuple, "base", base).destroy(comp),
|
||||||
Id.Opaque => @fieldParentPtr(Opaque, "base", base).destroy(comp),
|
Id.Opaque => @fieldParentPtr(Opaque, "base", base).destroy(comp),
|
||||||
@ -74,7 +73,6 @@ pub const Type = struct {
|
|||||||
Id.Enum => return @fieldParentPtr(Enum, "base", base).getLlvmType(allocator, llvm_context),
|
Id.Enum => return @fieldParentPtr(Enum, "base", base).getLlvmType(allocator, llvm_context),
|
||||||
Id.Union => return @fieldParentPtr(Union, "base", base).getLlvmType(allocator, llvm_context),
|
Id.Union => return @fieldParentPtr(Union, "base", base).getLlvmType(allocator, llvm_context),
|
||||||
Id.Namespace => unreachable,
|
Id.Namespace => unreachable,
|
||||||
Id.Block => unreachable,
|
|
||||||
Id.BoundFn => return @fieldParentPtr(BoundFn, "base", base).getLlvmType(allocator, llvm_context),
|
Id.BoundFn => return @fieldParentPtr(BoundFn, "base", base).getLlvmType(allocator, llvm_context),
|
||||||
Id.ArgTuple => unreachable,
|
Id.ArgTuple => unreachable,
|
||||||
Id.Opaque => return @fieldParentPtr(Opaque, "base", base).getLlvmType(allocator, llvm_context),
|
Id.Opaque => return @fieldParentPtr(Opaque, "base", base).getLlvmType(allocator, llvm_context),
|
||||||
@ -90,7 +88,6 @@ pub const Type = struct {
|
|||||||
Id.Undefined,
|
Id.Undefined,
|
||||||
Id.Null,
|
Id.Null,
|
||||||
Id.Namespace,
|
Id.Namespace,
|
||||||
Id.Block,
|
|
||||||
Id.BoundFn,
|
Id.BoundFn,
|
||||||
Id.ArgTuple,
|
Id.ArgTuple,
|
||||||
Id.Opaque,
|
Id.Opaque,
|
||||||
@ -124,7 +121,6 @@ pub const Type = struct {
|
|||||||
Id.Undefined,
|
Id.Undefined,
|
||||||
Id.Null,
|
Id.Null,
|
||||||
Id.Namespace,
|
Id.Namespace,
|
||||||
Id.Block,
|
|
||||||
Id.BoundFn,
|
Id.BoundFn,
|
||||||
Id.ArgTuple,
|
Id.ArgTuple,
|
||||||
Id.Opaque,
|
Id.Opaque,
|
||||||
@ -1012,14 +1008,6 @@ pub const Type = struct {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Block = struct {
|
|
||||||
base: Type,
|
|
||||||
|
|
||||||
pub fn destroy(self: *Block, comp: *Compilation) void {
|
|
||||||
comp.gpa().destroy(self);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
pub const BoundFn = struct {
|
pub const BoundFn = struct {
|
||||||
base: Type,
|
base: Type,
|
||||||
|
|
||||||
|
@ -283,7 +283,6 @@ struct ConstExprValue {
|
|||||||
ConstArrayValue x_array;
|
ConstArrayValue x_array;
|
||||||
ConstPtrValue x_ptr;
|
ConstPtrValue x_ptr;
|
||||||
ImportTableEntry *x_import;
|
ImportTableEntry *x_import;
|
||||||
Scope *x_block;
|
|
||||||
ConstArgTuple x_arg_tuple;
|
ConstArgTuple x_arg_tuple;
|
||||||
|
|
||||||
// populated if special == ConstValSpecialRuntime
|
// populated if special == ConstValSpecialRuntime
|
||||||
@ -413,7 +412,6 @@ enum NodeType {
|
|||||||
NodeTypeBoolLiteral,
|
NodeTypeBoolLiteral,
|
||||||
NodeTypeNullLiteral,
|
NodeTypeNullLiteral,
|
||||||
NodeTypeUndefinedLiteral,
|
NodeTypeUndefinedLiteral,
|
||||||
NodeTypeThisLiteral,
|
|
||||||
NodeTypeUnreachable,
|
NodeTypeUnreachable,
|
||||||
NodeTypeIfBoolExpr,
|
NodeTypeIfBoolExpr,
|
||||||
NodeTypeWhileExpr,
|
NodeTypeWhileExpr,
|
||||||
@ -1205,7 +1203,6 @@ enum ZigTypeId {
|
|||||||
ZigTypeIdUnion,
|
ZigTypeIdUnion,
|
||||||
ZigTypeIdFn,
|
ZigTypeIdFn,
|
||||||
ZigTypeIdNamespace,
|
ZigTypeIdNamespace,
|
||||||
ZigTypeIdBlock,
|
|
||||||
ZigTypeIdBoundFn,
|
ZigTypeIdBoundFn,
|
||||||
ZigTypeIdArgTuple,
|
ZigTypeIdArgTuple,
|
||||||
ZigTypeIdOpaque,
|
ZigTypeIdOpaque,
|
||||||
@ -1413,6 +1410,7 @@ enum BuiltinFnId {
|
|||||||
BuiltinFnIdSetEvalBranchQuota,
|
BuiltinFnIdSetEvalBranchQuota,
|
||||||
BuiltinFnIdAlignCast,
|
BuiltinFnIdAlignCast,
|
||||||
BuiltinFnIdOpaqueType,
|
BuiltinFnIdOpaqueType,
|
||||||
|
BuiltinFnIdThis,
|
||||||
BuiltinFnIdSetAlignStack,
|
BuiltinFnIdSetAlignStack,
|
||||||
BuiltinFnIdArgType,
|
BuiltinFnIdArgType,
|
||||||
BuiltinFnIdExport,
|
BuiltinFnIdExport,
|
||||||
|
@ -246,7 +246,6 @@ AstNode *type_decl_node(ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -284,7 +283,6 @@ bool type_is_complete(ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -320,7 +318,6 @@ bool type_has_zero_bits_known(ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -1414,7 +1411,6 @@ static bool type_allowed_in_packed_struct(ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -1455,7 +1451,6 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -1613,7 +1608,6 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
|
|||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdMetaType:
|
case ZigTypeIdMetaType:
|
||||||
case ZigTypeIdVoid:
|
case ZigTypeIdVoid:
|
||||||
@ -1703,7 +1697,6 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
|
|||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdMetaType:
|
case ZigTypeIdMetaType:
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
@ -3437,7 +3430,6 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
|
|||||||
case NodeTypeBoolLiteral:
|
case NodeTypeBoolLiteral:
|
||||||
case NodeTypeNullLiteral:
|
case NodeTypeNullLiteral:
|
||||||
case NodeTypeUndefinedLiteral:
|
case NodeTypeUndefinedLiteral:
|
||||||
case NodeTypeThisLiteral:
|
|
||||||
case NodeTypeSymbol:
|
case NodeTypeSymbol:
|
||||||
case NodeTypePrefixOpExpr:
|
case NodeTypePrefixOpExpr:
|
||||||
case NodeTypePointerType:
|
case NodeTypePointerType:
|
||||||
@ -3497,7 +3489,6 @@ ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry
|
|||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",
|
add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",
|
||||||
@ -3798,34 +3789,6 @@ ZigFn *scope_fn_entry(Scope *scope) {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZigFn *scope_get_fn_if_root(Scope *scope) {
|
|
||||||
assert(scope);
|
|
||||||
scope = scope->parent;
|
|
||||||
while (scope) {
|
|
||||||
switch (scope->id) {
|
|
||||||
case ScopeIdBlock:
|
|
||||||
return nullptr;
|
|
||||||
case ScopeIdDecls:
|
|
||||||
case ScopeIdDefer:
|
|
||||||
case ScopeIdDeferExpr:
|
|
||||||
case ScopeIdVarDecl:
|
|
||||||
case ScopeIdCImport:
|
|
||||||
case ScopeIdLoop:
|
|
||||||
case ScopeIdSuspend:
|
|
||||||
case ScopeIdCompTime:
|
|
||||||
case ScopeIdCoroPrelude:
|
|
||||||
case ScopeIdRuntime:
|
|
||||||
scope = scope->parent;
|
|
||||||
continue;
|
|
||||||
case ScopeIdFnDef:
|
|
||||||
ScopeFnDef *fn_scope = (ScopeFnDef *)scope;
|
|
||||||
return fn_scope->fn_entry;
|
|
||||||
}
|
|
||||||
zig_unreachable();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) {
|
TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) {
|
||||||
assert(enum_type->id == ZigTypeIdEnum);
|
assert(enum_type->id == ZigTypeIdEnum);
|
||||||
if (enum_type->data.enumeration.src_field_count == 0)
|
if (enum_type->data.enumeration.src_field_count == 0)
|
||||||
@ -3907,7 +3870,6 @@ static bool is_container(ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -3966,7 +3928,6 @@ void resolve_container_type(CodeGen *g, ZigType *type_entry) {
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdInvalid:
|
case ZigTypeIdInvalid:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
@ -4427,7 +4388,6 @@ bool handle_is_ptr(ZigType *type_entry) {
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -4842,8 +4802,6 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
|
|||||||
return const_val->data.x_err_set->value ^ 2630160122;
|
return const_val->data.x_err_set->value ^ 2630160122;
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
return hash_ptr(const_val->data.x_import);
|
return hash_ptr(const_val->data.x_import);
|
||||||
case ZigTypeIdBlock:
|
|
||||||
return hash_ptr(const_val->data.x_block);
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdInvalid:
|
case ZigTypeIdInvalid:
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
@ -4904,7 +4862,6 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
|
|||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
@ -4971,7 +4928,6 @@ static bool return_type_is_cacheable(ZigType *return_type) {
|
|||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
@ -5083,7 +5039,6 @@ bool type_requires_comptime(ZigType *type_entry) {
|
|||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdMetaType:
|
case ZigTypeIdMetaType:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
return true;
|
return true;
|
||||||
@ -5615,8 +5570,6 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
|
|||||||
zig_panic("TODO");
|
zig_panic("TODO");
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
return a->data.x_import == b->data.x_import;
|
return a->data.x_import == b->data.x_import;
|
||||||
case ZigTypeIdBlock:
|
|
||||||
return a->data.x_block == b->data.x_block;
|
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
return a->data.x_arg_tuple.start_index == b->data.x_arg_tuple.start_index &&
|
return a->data.x_arg_tuple.start_index == b->data.x_arg_tuple.start_index &&
|
||||||
a->data.x_arg_tuple.end_index == b->data.x_arg_tuple.end_index;
|
a->data.x_arg_tuple.end_index == b->data.x_arg_tuple.end_index;
|
||||||
@ -5795,12 +5748,6 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
|
|||||||
}
|
}
|
||||||
case ZigTypeIdPointer:
|
case ZigTypeIdPointer:
|
||||||
return render_const_val_ptr(g, buf, const_val, type_entry);
|
return render_const_val_ptr(g, buf, const_val, type_entry);
|
||||||
case ZigTypeIdBlock:
|
|
||||||
{
|
|
||||||
AstNode *node = const_val->data.x_block->source_node;
|
|
||||||
buf_appendf(buf, "(scope:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ")", node->line + 1, node->column + 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case ZigTypeIdArray:
|
case ZigTypeIdArray:
|
||||||
{
|
{
|
||||||
ZigType *child_type = type_entry->data.array.child_type;
|
ZigType *child_type = type_entry->data.array.child_type;
|
||||||
@ -5980,7 +5927,6 @@ uint32_t type_id_hash(TypeId x) {
|
|||||||
case ZigTypeIdUnion:
|
case ZigTypeIdUnion:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -6027,7 +5973,6 @@ bool type_id_eql(TypeId a, TypeId b) {
|
|||||||
case ZigTypeIdUnion:
|
case ZigTypeIdUnion:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -6153,7 +6098,6 @@ static const ZigTypeId all_type_ids[] = {
|
|||||||
ZigTypeIdUnion,
|
ZigTypeIdUnion,
|
||||||
ZigTypeIdFn,
|
ZigTypeIdFn,
|
||||||
ZigTypeIdNamespace,
|
ZigTypeIdNamespace,
|
||||||
ZigTypeIdBlock,
|
|
||||||
ZigTypeIdBoundFn,
|
ZigTypeIdBoundFn,
|
||||||
ZigTypeIdArgTuple,
|
ZigTypeIdArgTuple,
|
||||||
ZigTypeIdOpaque,
|
ZigTypeIdOpaque,
|
||||||
@ -6215,16 +6159,14 @@ size_t type_id_index(ZigType *entry) {
|
|||||||
return 18;
|
return 18;
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
return 19;
|
return 19;
|
||||||
case ZigTypeIdBlock:
|
|
||||||
return 20;
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
return 21;
|
return 20;
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
return 22;
|
return 21;
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
return 23;
|
return 22;
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
return 24;
|
return 23;
|
||||||
}
|
}
|
||||||
zig_unreachable();
|
zig_unreachable();
|
||||||
}
|
}
|
||||||
@ -6273,8 +6215,6 @@ const char *type_id_name(ZigTypeId id) {
|
|||||||
return "Fn";
|
return "Fn";
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
return "Namespace";
|
return "Namespace";
|
||||||
case ZigTypeIdBlock:
|
|
||||||
return "Block";
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
return "BoundFn";
|
return "BoundFn";
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
|
@ -87,7 +87,6 @@ ZigFn *create_fn(AstNode *proto_node);
|
|||||||
ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
|
ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage);
|
||||||
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
|
void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc);
|
||||||
AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index);
|
AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index);
|
||||||
ZigFn *scope_get_fn_if_root(Scope *scope);
|
|
||||||
bool type_requires_comptime(ZigType *type_entry);
|
bool type_requires_comptime(ZigType *type_entry);
|
||||||
Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry);
|
Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry);
|
||||||
Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry);
|
Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry);
|
||||||
|
@ -193,8 +193,6 @@ static const char *node_type_str(NodeType node_type) {
|
|||||||
return "NullLiteral";
|
return "NullLiteral";
|
||||||
case NodeTypeUndefinedLiteral:
|
case NodeTypeUndefinedLiteral:
|
||||||
return "UndefinedLiteral";
|
return "UndefinedLiteral";
|
||||||
case NodeTypeThisLiteral:
|
|
||||||
return "ThisLiteral";
|
|
||||||
case NodeTypeIfBoolExpr:
|
case NodeTypeIfBoolExpr:
|
||||||
return "IfBoolExpr";
|
return "IfBoolExpr";
|
||||||
case NodeTypeWhileExpr:
|
case NodeTypeWhileExpr:
|
||||||
@ -897,11 +895,6 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NodeTypeThisLiteral:
|
|
||||||
{
|
|
||||||
fprintf(ar->f, "this");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case NodeTypeBoolLiteral:
|
case NodeTypeBoolLiteral:
|
||||||
{
|
{
|
||||||
const char *bool_str = node->data.bool_literal.value ? "true" : "false";
|
const char *bool_str = node->data.bool_literal.value ? "true" : "false";
|
||||||
|
@ -5479,7 +5479,6 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
|
|||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdVoid:
|
case ZigTypeIdVoid:
|
||||||
@ -5954,7 +5953,6 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -6477,12 +6475,6 @@ static void define_builtin_types(CodeGen *g) {
|
|||||||
entry->zero_bits = true;
|
entry->zero_bits = true;
|
||||||
g->builtin_types.entry_namespace = entry;
|
g->builtin_types.entry_namespace = entry;
|
||||||
}
|
}
|
||||||
{
|
|
||||||
ZigType *entry = new_type_table_entry(ZigTypeIdBlock);
|
|
||||||
buf_init_from_str(&entry->name, "(block)");
|
|
||||||
entry->zero_bits = true;
|
|
||||||
g->builtin_types.entry_block = entry;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
ZigType *entry = new_type_table_entry(ZigTypeIdComptimeFloat);
|
ZigType *entry = new_type_table_entry(ZigTypeIdComptimeFloat);
|
||||||
buf_init_from_str(&entry->name, "comptime_float");
|
buf_init_from_str(&entry->name, "comptime_float");
|
||||||
@ -6763,6 +6755,7 @@ static void define_builtin_fns(CodeGen *g) {
|
|||||||
create_builtin_fn(g, BuiltinFnIdErrSetCast, "errSetCast", 2);
|
create_builtin_fn(g, BuiltinFnIdErrSetCast, "errSetCast", 2);
|
||||||
create_builtin_fn(g, BuiltinFnIdToBytes, "sliceToBytes", 1);
|
create_builtin_fn(g, BuiltinFnIdToBytes, "sliceToBytes", 1);
|
||||||
create_builtin_fn(g, BuiltinFnIdFromBytes, "bytesToSlice", 2);
|
create_builtin_fn(g, BuiltinFnIdFromBytes, "bytesToSlice", 2);
|
||||||
|
create_builtin_fn(g, BuiltinFnIdThis, "This", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *bool_to_str(bool b) {
|
static const char *bool_to_str(bool b) {
|
||||||
@ -6944,7 +6937,6 @@ Buf *codegen_generate_builtin_source(CodeGen *g) {
|
|||||||
" Union: Union,\n"
|
" Union: Union,\n"
|
||||||
" Fn: Fn,\n"
|
" Fn: Fn,\n"
|
||||||
" Namespace: void,\n"
|
" Namespace: void,\n"
|
||||||
" Block: void,\n"
|
|
||||||
" BoundFn: Fn,\n"
|
" BoundFn: Fn,\n"
|
||||||
" ArgTuple: void,\n"
|
" ArgTuple: void,\n"
|
||||||
" Opaque: void,\n"
|
" Opaque: void,\n"
|
||||||
@ -7589,7 +7581,6 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
@ -7768,7 +7759,6 @@ static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_bu
|
|||||||
case ZigTypeIdMetaType:
|
case ZigTypeIdMetaType:
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
@ -7921,7 +7911,6 @@ static void gen_h_file(CodeGen *g) {
|
|||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOptional:
|
case ZigTypeIdOptional:
|
||||||
|
81
src/ir.cpp
81
src/ir.cpp
@ -1029,12 +1029,6 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode *
|
|||||||
return &const_instruction->base;
|
return &const_instruction->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) {
|
|
||||||
IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry);
|
|
||||||
ir_instruction_append(irb->current_basic_block, instruction);
|
|
||||||
return instruction;
|
|
||||||
}
|
|
||||||
|
|
||||||
static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ImportTableEntry *import) {
|
static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ImportTableEntry *import) {
|
||||||
IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
|
IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
|
||||||
const_instruction->base.value.type = irb->codegen->builtin_types.entry_namespace;
|
const_instruction->base.value.type = irb->codegen->builtin_types.entry_namespace;
|
||||||
@ -1043,16 +1037,6 @@ static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNod
|
|||||||
return &const_instruction->base;
|
return &const_instruction->base;
|
||||||
}
|
}
|
||||||
|
|
||||||
static IrInstruction *ir_build_const_scope(IrBuilder *irb, Scope *parent_scope, AstNode *source_node,
|
|
||||||
Scope *target_scope)
|
|
||||||
{
|
|
||||||
IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, parent_scope, source_node);
|
|
||||||
const_instruction->base.value.type = irb->codegen->builtin_types.entry_block;
|
|
||||||
const_instruction->base.value.special = ConstValSpecialStatic;
|
|
||||||
const_instruction->base.value.data.x_block = target_scope;
|
|
||||||
return &const_instruction->base;
|
|
||||||
}
|
|
||||||
|
|
||||||
static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) {
|
static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) {
|
||||||
IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
|
IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node);
|
||||||
const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool;
|
const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool;
|
||||||
@ -3892,6 +3876,21 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode *
|
|||||||
return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr);
|
return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *node) {
|
||||||
|
for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) {
|
||||||
|
if (it_scope->id == ScopeIdDecls) {
|
||||||
|
ScopeDecls *decls_scope = (ScopeDecls *)it_scope;
|
||||||
|
ZigType *container_type = decls_scope->container_type;
|
||||||
|
if (container_type != nullptr) {
|
||||||
|
return ir_build_const_type(irb, orig_scope, node, container_type);
|
||||||
|
} else {
|
||||||
|
return ir_build_const_import(irb, orig_scope, node, decls_scope->import);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zig_unreachable();
|
||||||
|
}
|
||||||
|
|
||||||
static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) {
|
static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) {
|
||||||
assert(node->type == NodeTypeFnCallExpr);
|
assert(node->type == NodeTypeFnCallExpr);
|
||||||
|
|
||||||
@ -4830,6 +4829,11 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
|
|||||||
IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node);
|
IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node);
|
||||||
return ir_lval_wrap(irb, scope, opaque_type, lval);
|
return ir_lval_wrap(irb, scope, opaque_type, lval);
|
||||||
}
|
}
|
||||||
|
case BuiltinFnIdThis:
|
||||||
|
{
|
||||||
|
IrInstruction *this_inst = ir_gen_this(irb, scope, node);
|
||||||
|
return ir_lval_wrap(irb, scope, this_inst, lval);
|
||||||
|
}
|
||||||
case BuiltinFnIdSetAlignStack:
|
case BuiltinFnIdSetAlignStack:
|
||||||
{
|
{
|
||||||
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
|
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
|
||||||
@ -5681,33 +5685,6 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo
|
|||||||
return ir_build_phi(irb, parent_scope, node, incoming_blocks.length, incoming_blocks.items, incoming_values.items);
|
return ir_build_phi(irb, parent_scope, node, incoming_blocks.length, incoming_blocks.items, incoming_values.items);
|
||||||
}
|
}
|
||||||
|
|
||||||
static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode *node) {
|
|
||||||
assert(node->type == NodeTypeThisLiteral);
|
|
||||||
|
|
||||||
if (!scope->parent)
|
|
||||||
return ir_build_const_import(irb, scope, node, node->owner);
|
|
||||||
|
|
||||||
ZigFn *fn_entry = scope_get_fn_if_root(scope);
|
|
||||||
if (fn_entry)
|
|
||||||
return ir_build_const_fn(irb, scope, node, fn_entry);
|
|
||||||
|
|
||||||
while (scope->id != ScopeIdBlock && scope->id != ScopeIdDecls) {
|
|
||||||
scope = scope->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scope->id == ScopeIdDecls) {
|
|
||||||
ScopeDecls *decls_scope = (ScopeDecls *)scope;
|
|
||||||
ZigType *container_type = decls_scope->container_type;
|
|
||||||
assert(container_type);
|
|
||||||
return ir_build_const_type(irb, scope, node, container_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scope->id == ScopeIdBlock)
|
|
||||||
return ir_build_const_scope(irb, scope, node, scope);
|
|
||||||
|
|
||||||
zig_unreachable();
|
|
||||||
}
|
|
||||||
|
|
||||||
static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode *node) {
|
static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode *node) {
|
||||||
assert(node->type == NodeTypeBoolLiteral);
|
assert(node->type == NodeTypeBoolLiteral);
|
||||||
return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value);
|
return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value);
|
||||||
@ -7285,8 +7262,6 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop
|
|||||||
|
|
||||||
return ir_build_load_ptr(irb, scope, node, unwrapped_ptr);
|
return ir_build_load_ptr(irb, scope, node, unwrapped_ptr);
|
||||||
}
|
}
|
||||||
case NodeTypeThisLiteral:
|
|
||||||
return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval);
|
|
||||||
case NodeTypeBoolLiteral:
|
case NodeTypeBoolLiteral:
|
||||||
return ir_lval_wrap(irb, scope, ir_gen_bool_literal(irb, scope, node), lval);
|
return ir_lval_wrap(irb, scope, ir_gen_bool_literal(irb, scope, node), lval);
|
||||||
case NodeTypeArrayType:
|
case NodeTypeArrayType:
|
||||||
@ -11621,7 +11596,6 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op
|
|||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -12822,7 +12796,6 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor
|
|||||||
case ZigTypeIdErrorUnion:
|
case ZigTypeIdErrorUnion:
|
||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -12847,7 +12820,6 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor
|
|||||||
case ZigTypeIdErrorSet:
|
case ZigTypeIdErrorSet:
|
||||||
zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name));
|
zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name));
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -13905,7 +13877,6 @@ static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instru
|
|||||||
case ZigTypeIdUnion:
|
case ZigTypeIdUnion:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdPromise:
|
case ZigTypeIdPromise:
|
||||||
@ -15263,7 +15234,6 @@ static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeO
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdMetaType:
|
case ZigTypeIdMetaType:
|
||||||
case ZigTypeIdVoid:
|
case ZigTypeIdVoid:
|
||||||
@ -15516,7 +15486,6 @@ static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira,
|
|||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
ir_add_error_node(ira, slice_type_instruction->base.source_node,
|
ir_add_error_node(ira, slice_type_instruction->base.source_node,
|
||||||
@ -15627,7 +15596,6 @@ static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira,
|
|||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
ir_add_error_node(ira, array_type_instruction->base.source_node,
|
ir_add_error_node(ira, array_type_instruction->base.source_node,
|
||||||
@ -15698,7 +15666,6 @@ static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira,
|
|||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
@ -16184,7 +16151,6 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira,
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdOptional:
|
case ZigTypeIdOptional:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -16705,7 +16671,6 @@ static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruc
|
|||||||
case ZigTypeIdUnion:
|
case ZigTypeIdUnion:
|
||||||
case ZigTypeIdFn:
|
case ZigTypeIdFn:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
@ -17368,7 +17333,6 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdOpaque:
|
case ZigTypeIdOpaque:
|
||||||
*out = nullptr;
|
*out = nullptr;
|
||||||
@ -19341,7 +19305,6 @@ static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAli
|
|||||||
case ZigTypeIdUndefined:
|
case ZigTypeIdUndefined:
|
||||||
case ZigTypeIdNull:
|
case ZigTypeIdNull:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdVoid:
|
case ZigTypeIdVoid:
|
||||||
@ -20102,7 +20065,6 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
|
|||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
@ -20169,7 +20131,6 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
|
|||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
@ -20249,7 +20210,6 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit
|
|||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
@ -20275,7 +20235,6 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit
|
|||||||
case ZigTypeIdBoundFn:
|
case ZigTypeIdBoundFn:
|
||||||
case ZigTypeIdArgTuple:
|
case ZigTypeIdArgTuple:
|
||||||
case ZigTypeIdNamespace:
|
case ZigTypeIdNamespace:
|
||||||
case ZigTypeIdBlock:
|
|
||||||
case ZigTypeIdUnreachable:
|
case ZigTypeIdUnreachable:
|
||||||
case ZigTypeIdComptimeFloat:
|
case ZigTypeIdComptimeFloat:
|
||||||
case ZigTypeIdComptimeInt:
|
case ZigTypeIdComptimeInt:
|
||||||
|
@ -700,7 +700,7 @@ static AstNode *ast_parse_comptime_expr(ParseContext *pc, size_t *token_index, b
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | FnProto | AsmExpression | ContainerDecl | ("continue" option(":" Symbol)) | ErrorSetDecl | PromiseType
|
PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | FnProto | AsmExpression | ContainerDecl | ("continue" option(":" Symbol)) | ErrorSetDecl | PromiseType
|
||||||
KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "this" | "unreachable" | "suspend"
|
KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "unreachable" | "suspend"
|
||||||
ErrorSetDecl = "error" "{" list(Symbol, ",") "}"
|
ErrorSetDecl = "error" "{" list(Symbol, ",") "}"
|
||||||
*/
|
*/
|
||||||
static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
|
static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) {
|
||||||
@ -756,10 +756,6 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bo
|
|||||||
AstNode *node = ast_create_node(pc, NodeTypeUndefinedLiteral, token);
|
AstNode *node = ast_create_node(pc, NodeTypeUndefinedLiteral, token);
|
||||||
*token_index += 1;
|
*token_index += 1;
|
||||||
return node;
|
return node;
|
||||||
} else if (token->id == TokenIdKeywordThis) {
|
|
||||||
AstNode *node = ast_create_node(pc, NodeTypeThisLiteral, token);
|
|
||||||
*token_index += 1;
|
|
||||||
return node;
|
|
||||||
} else if (token->id == TokenIdKeywordUnreachable) {
|
} else if (token->id == TokenIdKeywordUnreachable) {
|
||||||
AstNode *node = ast_create_node(pc, NodeTypeUnreachable, token);
|
AstNode *node = ast_create_node(pc, NodeTypeUnreachable, token);
|
||||||
*token_index += 1;
|
*token_index += 1;
|
||||||
@ -3021,9 +3017,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
|
|||||||
case NodeTypeUndefinedLiteral:
|
case NodeTypeUndefinedLiteral:
|
||||||
// none
|
// none
|
||||||
break;
|
break;
|
||||||
case NodeTypeThisLiteral:
|
|
||||||
// none
|
|
||||||
break;
|
|
||||||
case NodeTypeIfBoolExpr:
|
case NodeTypeIfBoolExpr:
|
||||||
visit_field(&node->data.if_bool_expr.condition, visit, context);
|
visit_field(&node->data.if_bool_expr.condition, visit, context);
|
||||||
visit_field(&node->data.if_bool_expr.then_block, visit, context);
|
visit_field(&node->data.if_bool_expr.then_block, visit, context);
|
||||||
|
@ -146,7 +146,6 @@ static const struct ZigKeyword zig_keywords[] = {
|
|||||||
{"suspend", TokenIdKeywordSuspend},
|
{"suspend", TokenIdKeywordSuspend},
|
||||||
{"switch", TokenIdKeywordSwitch},
|
{"switch", TokenIdKeywordSwitch},
|
||||||
{"test", TokenIdKeywordTest},
|
{"test", TokenIdKeywordTest},
|
||||||
{"this", TokenIdKeywordThis},
|
|
||||||
{"true", TokenIdKeywordTrue},
|
{"true", TokenIdKeywordTrue},
|
||||||
{"try", TokenIdKeywordTry},
|
{"try", TokenIdKeywordTry},
|
||||||
{"undefined", TokenIdKeywordUndefined},
|
{"undefined", TokenIdKeywordUndefined},
|
||||||
@ -1588,7 +1587,6 @@ const char * token_name(TokenId id) {
|
|||||||
case TokenIdKeywordStruct: return "struct";
|
case TokenIdKeywordStruct: return "struct";
|
||||||
case TokenIdKeywordSwitch: return "switch";
|
case TokenIdKeywordSwitch: return "switch";
|
||||||
case TokenIdKeywordTest: return "test";
|
case TokenIdKeywordTest: return "test";
|
||||||
case TokenIdKeywordThis: return "this";
|
|
||||||
case TokenIdKeywordTrue: return "true";
|
case TokenIdKeywordTrue: return "true";
|
||||||
case TokenIdKeywordTry: return "try";
|
case TokenIdKeywordTry: return "try";
|
||||||
case TokenIdKeywordUndefined: return "undefined";
|
case TokenIdKeywordUndefined: return "undefined";
|
||||||
|
@ -87,7 +87,6 @@ enum TokenId {
|
|||||||
TokenIdKeywordSuspend,
|
TokenIdKeywordSuspend,
|
||||||
TokenIdKeywordSwitch,
|
TokenIdKeywordSwitch,
|
||||||
TokenIdKeywordTest,
|
TokenIdKeywordTest,
|
||||||
TokenIdKeywordThis,
|
|
||||||
TokenIdKeywordTrue,
|
TokenIdKeywordTrue,
|
||||||
TokenIdKeywordTry,
|
TokenIdKeywordTry,
|
||||||
TokenIdKeywordUndefined,
|
TokenIdKeywordUndefined,
|
||||||
|
@ -11,7 +11,7 @@ pub fn ArrayList(comptime T: type) type {
|
|||||||
|
|
||||||
pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
|
pub fn AlignedArrayList(comptime T: type, comptime A: u29) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
/// Use toSlice instead of slicing this directly, because if you don't
|
/// Use toSlice instead of slicing this directly, because if you don't
|
||||||
/// specify the end position of the slice, this will potentially give
|
/// specify the end position of the slice, this will potentially give
|
||||||
|
@ -6,7 +6,7 @@ pub fn Int(comptime T: type) type {
|
|||||||
return struct {
|
return struct {
|
||||||
unprotected_value: T,
|
unprotected_value: T,
|
||||||
|
|
||||||
pub const Self = this;
|
pub const Self = @This();
|
||||||
|
|
||||||
pub fn init(init_val: T) Self {
|
pub fn init(init_val: T) Self {
|
||||||
return Self{ .unprotected_value = init_val };
|
return Self{ .unprotected_value = init_val };
|
||||||
|
@ -12,7 +12,7 @@ pub fn Queue(comptime T: type) type {
|
|||||||
tail: ?*Node,
|
tail: ?*Node,
|
||||||
mutex: std.Mutex,
|
mutex: std.Mutex,
|
||||||
|
|
||||||
pub const Self = this;
|
pub const Self = @This();
|
||||||
pub const Node = std.LinkedList(T).Node;
|
pub const Node = std.LinkedList(T).Node;
|
||||||
|
|
||||||
pub fn init() Self {
|
pub fn init() Self {
|
||||||
|
@ -9,7 +9,7 @@ pub fn Stack(comptime T: type) type {
|
|||||||
root: ?*Node,
|
root: ?*Node,
|
||||||
lock: u8,
|
lock: u8,
|
||||||
|
|
||||||
pub const Self = this;
|
pub const Self = @This();
|
||||||
|
|
||||||
pub const Node = struct {
|
pub const Node = struct {
|
||||||
next: ?*Node,
|
next: ?*Node,
|
||||||
|
@ -1890,7 +1890,7 @@ const InstallArtifactStep = struct {
|
|||||||
artifact: *LibExeObjStep,
|
artifact: *LibExeObjStep,
|
||||||
dest_file: []const u8,
|
dest_file: []const u8,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub fn create(builder: *Builder, artifact: *LibExeObjStep) *Self {
|
pub fn create(builder: *Builder, artifact: *LibExeObjStep) *Self {
|
||||||
const dest_dir = switch (artifact.kind) {
|
const dest_dir = switch (artifact.kind) {
|
||||||
|
@ -33,7 +33,7 @@ pub const Blake2s256 = Blake2s(256);
|
|||||||
|
|
||||||
fn Blake2s(comptime out_len: usize) type {
|
fn Blake2s(comptime out_len: usize) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 64;
|
const block_length = 64;
|
||||||
const digest_length = out_len / 8;
|
const digest_length = out_len / 8;
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ pub const Blake2b512 = Blake2b(512);
|
|||||||
|
|
||||||
fn Blake2b(comptime out_len: usize) type {
|
fn Blake2b(comptime out_len: usize) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 128;
|
const block_length = 128;
|
||||||
const digest_length = out_len / 8;
|
const digest_length = out_len / 8;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ pub const HmacSha256 = Hmac(crypto.Sha256);
|
|||||||
|
|
||||||
pub fn Hmac(comptime Hash: type) type {
|
pub fn Hmac(comptime Hash: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const mac_length = Hash.digest_length;
|
pub const mac_length = Hash.digest_length;
|
||||||
pub const minimum_key_length = 0;
|
pub const minimum_key_length = 0;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ fn Rp(a: usize, b: usize, c: usize, d: usize, k: usize, s: u32, t: u32) RoundPar
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const Md5 = struct {
|
pub const Md5 = struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 64;
|
const block_length = 64;
|
||||||
const digest_length = 16;
|
const digest_length = 16;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ const readInt = std.mem.readInt;
|
|||||||
const writeInt = std.mem.writeInt;
|
const writeInt = std.mem.writeInt;
|
||||||
|
|
||||||
pub const Poly1305 = struct {
|
pub const Poly1305 = struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub const mac_length = 16;
|
pub const mac_length = 16;
|
||||||
pub const minimum_key_length = 32;
|
pub const minimum_key_length = 32;
|
||||||
|
@ -25,7 +25,7 @@ fn Rp(a: usize, b: usize, c: usize, d: usize, e: usize, i: u32) RoundParam {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const Sha1 = struct {
|
pub const Sha1 = struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 64;
|
const block_length = 64;
|
||||||
const digest_length = 20;
|
const digest_length = 20;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ pub const Sha256 = Sha2_32(Sha256Params);
|
|||||||
|
|
||||||
fn Sha2_32(comptime params: Sha2Params32) type {
|
fn Sha2_32(comptime params: Sha2Params32) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 64;
|
const block_length = 64;
|
||||||
const digest_length = params.out_len / 8;
|
const digest_length = params.out_len / 8;
|
||||||
|
|
||||||
@ -418,7 +418,7 @@ pub const Sha512 = Sha2_64(Sha512Params);
|
|||||||
|
|
||||||
fn Sha2_64(comptime params: Sha2Params64) type {
|
fn Sha2_64(comptime params: Sha2Params64) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 128;
|
const block_length = 128;
|
||||||
const digest_length = params.out_len / 8;
|
const digest_length = params.out_len / 8;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ pub const Sha3_512 = Keccak(512, 0x06);
|
|||||||
|
|
||||||
fn Keccak(comptime bits: usize, comptime delim: u8) type {
|
fn Keccak(comptime bits: usize, comptime delim: u8) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const block_length = 200;
|
const block_length = 200;
|
||||||
const digest_length = bits / 8;
|
const digest_length = bits / 8;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ pub fn Channel(comptime T: type) type {
|
|||||||
buffer_index: usize,
|
buffer_index: usize,
|
||||||
buffer_len: usize,
|
buffer_len: usize,
|
||||||
|
|
||||||
const SelfChannel = this;
|
const SelfChannel = @This();
|
||||||
const GetNode = struct {
|
const GetNode = struct {
|
||||||
tick_node: *Loop.NextTickNode,
|
tick_node: *Loop.NextTickNode,
|
||||||
data: Data,
|
data: Data,
|
||||||
|
@ -724,7 +724,7 @@ pub fn Watch(comptime V: type) type {
|
|||||||
|
|
||||||
const FileToHandle = std.AutoHashMap([]const u8, promise);
|
const FileToHandle = std.AutoHashMap([]const u8, promise);
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub const Event = struct {
|
pub const Event = struct {
|
||||||
id: Id,
|
id: Id,
|
||||||
|
@ -21,7 +21,7 @@ pub fn Future(comptime T: type) type {
|
|||||||
/// 2 - finished
|
/// 2 - finished
|
||||||
available: u8,
|
available: u8,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const Queue = std.atomic.Queue(promise);
|
const Queue = std.atomic.Queue(promise);
|
||||||
|
|
||||||
pub fn init(loop: *Loop) Self {
|
pub fn init(loop: *Loop) Self {
|
||||||
|
@ -13,7 +13,7 @@ pub fn Group(comptime ReturnType: type) type {
|
|||||||
alloc_stack: Stack,
|
alloc_stack: Stack,
|
||||||
lock: Lock,
|
lock: Lock,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
const Error = switch (@typeInfo(ReturnType)) {
|
const Error = switch (@typeInfo(ReturnType)) {
|
||||||
builtin.TypeId.ErrorUnion => |payload| payload.error_set,
|
builtin.TypeId.ErrorUnion => |payload| payload.error_set,
|
||||||
|
@ -10,7 +10,7 @@ pub fn Locked(comptime T: type) type {
|
|||||||
lock: Lock,
|
lock: Lock,
|
||||||
private_data: T,
|
private_data: T,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub const HeldLock = struct {
|
pub const HeldLock = struct {
|
||||||
value: *T,
|
value: *T,
|
||||||
|
@ -10,7 +10,7 @@ pub fn RwLocked(comptime T: type) type {
|
|||||||
lock: RwLock,
|
lock: RwLock,
|
||||||
locked_data: T,
|
locked_data: T,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub const HeldReadLock = struct {
|
pub const HeldReadLock = struct {
|
||||||
value: *const T,
|
value: *const T,
|
||||||
|
@ -132,7 +132,7 @@ test "listen on a port, send bytes, receive bytes" {
|
|||||||
const MyServer = struct {
|
const MyServer = struct {
|
||||||
tcp_server: Server,
|
tcp_server: Server,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
async<*mem.Allocator> fn handler(tcp_server: *Server, _addr: *const std.net.Address, _socket: *const std.os.File) void {
|
async<*mem.Allocator> fn handler(tcp_server: *Server, _addr: *const std.net.Address, _socket: *const std.os.File) void {
|
||||||
const self = @fieldParentPtr(Self, "tcp_server", tcp_server);
|
const self = @fieldParentPtr(Self, "tcp_server", tcp_server);
|
||||||
var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
|
var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733
|
||||||
|
@ -1183,7 +1183,7 @@ test "fmt.format" {
|
|||||||
//custom type format
|
//custom type format
|
||||||
{
|
{
|
||||||
const Vec2 = struct {
|
const Vec2 = struct {
|
||||||
const SelfType = this;
|
const SelfType = @This();
|
||||||
x: f32,
|
x: f32,
|
||||||
y: f32,
|
y: f32,
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ pub const Crc32 = Crc32WithPoly(Polynomial.IEEE);
|
|||||||
// slicing-by-8 crc32 implementation.
|
// slicing-by-8 crc32 implementation.
|
||||||
pub fn Crc32WithPoly(comptime poly: u32) type {
|
pub fn Crc32WithPoly(comptime poly: u32) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const lookup_tables = comptime block: {
|
const lookup_tables = comptime block: {
|
||||||
@setEvalBranchQuota(20000);
|
@setEvalBranchQuota(20000);
|
||||||
var tables: [8][256]u32 = undefined;
|
var tables: [8][256]u32 = undefined;
|
||||||
@ -117,7 +117,7 @@ test "crc32 castagnoli" {
|
|||||||
// half-byte lookup table implementation.
|
// half-byte lookup table implementation.
|
||||||
pub fn Crc32SmallWithPoly(comptime poly: u32) type {
|
pub fn Crc32SmallWithPoly(comptime poly: u32) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const lookup_table = comptime block: {
|
const lookup_table = comptime block: {
|
||||||
var table: [16]u32 = undefined;
|
var table: [16]u32 = undefined;
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ pub const Fnv1a_128 = Fnv1a(u128, 0x1000000000000000000013b, 0x6c62272e07bb01426
|
|||||||
|
|
||||||
fn Fnv1a(comptime T: type, comptime prime: T, comptime offset: T) type {
|
fn Fnv1a(comptime T: type, comptime prime: T, comptime offset: T) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
value: T,
|
value: T,
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
|
|||||||
debug.assert(c_rounds > 0 and d_rounds > 0);
|
debug.assert(c_rounds > 0 and d_rounds > 0);
|
||||||
|
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const digest_size = 64;
|
const digest_size = 64;
|
||||||
const block_size = 64;
|
const block_size = 64;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3
|
|||||||
// this is used to detect bugs where a hashtable is edited while an iterator is running.
|
// this is used to detect bugs where a hashtable is edited while an iterator is running.
|
||||||
modification_count: debug_u32,
|
modification_count: debug_u32,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
pub const KV = struct {
|
pub const KV = struct {
|
||||||
key: K,
|
key: K,
|
||||||
@ -472,7 +472,6 @@ pub fn autoHash(key: var, comptime rng: *std.rand.Random, comptime HashInt: type
|
|||||||
builtin.TypeId.Promise, builtin.TypeId.Fn => return autoHash(@ptrToInt(key), rng),
|
builtin.TypeId.Promise, builtin.TypeId.Fn => return autoHash(@ptrToInt(key), rng),
|
||||||
|
|
||||||
builtin.TypeId.Namespace,
|
builtin.TypeId.Namespace,
|
||||||
builtin.TypeId.Block,
|
|
||||||
builtin.TypeId.BoundFn,
|
builtin.TypeId.BoundFn,
|
||||||
builtin.TypeId.ComptimeFloat,
|
builtin.TypeId.ComptimeFloat,
|
||||||
builtin.TypeId.ComptimeInt,
|
builtin.TypeId.ComptimeInt,
|
||||||
@ -517,7 +516,6 @@ pub fn autoEql(a: var, b: @typeOf(a)) bool {
|
|||||||
builtin.TypeId.ComptimeFloat,
|
builtin.TypeId.ComptimeFloat,
|
||||||
builtin.TypeId.ComptimeInt,
|
builtin.TypeId.ComptimeInt,
|
||||||
builtin.TypeId.Namespace,
|
builtin.TypeId.Namespace,
|
||||||
builtin.TypeId.Block,
|
|
||||||
builtin.TypeId.Promise,
|
builtin.TypeId.Promise,
|
||||||
builtin.TypeId.Enum,
|
builtin.TypeId.Enum,
|
||||||
builtin.TypeId.BoundFn,
|
builtin.TypeId.BoundFn,
|
||||||
|
@ -385,7 +385,7 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: *Allocator) Stack
|
|||||||
|
|
||||||
pub fn StackFallbackAllocator(comptime size: usize) type {
|
pub fn StackFallbackAllocator(comptime size: usize) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
buffer: [size]u8,
|
buffer: [size]u8,
|
||||||
allocator: Allocator,
|
allocator: Allocator,
|
||||||
|
12
std/io.zig
12
std/io.zig
@ -76,7 +76,7 @@ pub const FileOutStream = struct {
|
|||||||
|
|
||||||
pub fn InStream(comptime ReadError: type) type {
|
pub fn InStream(comptime ReadError: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const Error = ReadError;
|
pub const Error = ReadError;
|
||||||
|
|
||||||
/// Return the number of bytes read. If the number read is smaller than buf.len, it
|
/// Return the number of bytes read. If the number read is smaller than buf.len, it
|
||||||
@ -218,7 +218,7 @@ pub fn InStream(comptime ReadError: type) type {
|
|||||||
|
|
||||||
pub fn OutStream(comptime WriteError: type) type {
|
pub fn OutStream(comptime WriteError: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const Error = WriteError;
|
pub const Error = WriteError;
|
||||||
|
|
||||||
writeFn: fn (self: *Self, bytes: []const u8) Error!void,
|
writeFn: fn (self: *Self, bytes: []const u8) Error!void,
|
||||||
@ -291,7 +291,7 @@ pub fn BufferedInStream(comptime Error: type) type {
|
|||||||
|
|
||||||
pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) type {
|
pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const Stream = InStream(Error);
|
const Stream = InStream(Error);
|
||||||
|
|
||||||
pub stream: Stream,
|
pub stream: Stream,
|
||||||
@ -361,7 +361,7 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type)
|
|||||||
/// This makes look-ahead style parsing much easier.
|
/// This makes look-ahead style parsing much easier.
|
||||||
pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) type {
|
pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const Error = InStreamError;
|
pub const Error = InStreamError;
|
||||||
pub const Stream = InStream(Error);
|
pub const Stream = InStream(Error);
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) typ
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const SliceInStream = struct {
|
pub const SliceInStream = struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const Error = error{};
|
pub const Error = error{};
|
||||||
pub const Stream = InStream(Error);
|
pub const Stream = InStream(Error);
|
||||||
|
|
||||||
@ -505,7 +505,7 @@ pub fn BufferedOutStream(comptime Error: type) type {
|
|||||||
|
|
||||||
pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamError: type) type {
|
pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamError: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
pub const Stream = OutStream(Error);
|
pub const Stream = OutStream(Error);
|
||||||
pub const Error = OutStreamError;
|
pub const Error = OutStreamError;
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ fn LazyInit(comptime T: type) type {
|
|||||||
state: u8, // TODO make this an enum
|
state: u8, // TODO make this an enum
|
||||||
data: Data,
|
data: Data,
|
||||||
|
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
// TODO this isn't working for void, investigate and then remove this special case
|
// TODO this isn't working for void, investigate and then remove this special case
|
||||||
const Data = if (@sizeOf(T) == 0) u8 else T;
|
const Data = if (@sizeOf(T) == 0) u8 else T;
|
||||||
|
@ -7,7 +7,7 @@ const Allocator = mem.Allocator;
|
|||||||
/// Generic doubly linked list.
|
/// Generic doubly linked list.
|
||||||
pub fn LinkedList(comptime T: type) type {
|
pub fn LinkedList(comptime T: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
/// Node inside the linked list wrapping the actual data.
|
/// Node inside the linked list wrapping the actual data.
|
||||||
pub const Node = struct {
|
pub const Node = struct {
|
||||||
|
@ -25,7 +25,7 @@ pub const tan = @import("tan.zig").tan;
|
|||||||
|
|
||||||
pub fn Complex(comptime T: type) type {
|
pub fn Complex(comptime T: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
re: T,
|
re: T,
|
||||||
im: T,
|
im: T,
|
||||||
|
@ -3,7 +3,7 @@ const debug = std.debug;
|
|||||||
const assert = debug.assert;
|
const assert = debug.assert;
|
||||||
const math = std.math;
|
const math = std.math;
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const mem = this;
|
const mem = @This();
|
||||||
|
|
||||||
pub const Allocator = struct {
|
pub const Allocator = struct {
|
||||||
pub const Error = error{OutOfMemory};
|
pub const Error = error{OutOfMemory};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
const std = @import("index.zig");
|
const std = @import("index.zig");
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
const net = this;
|
const net = @This();
|
||||||
const posix = std.os.posix;
|
const posix = std.os.posix;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ const is_posix = switch (builtin.os) {
|
|||||||
builtin.Os.linux, builtin.Os.macosx => true,
|
builtin.Os.linux, builtin.Os.macosx => true,
|
||||||
else => false,
|
else => false,
|
||||||
};
|
};
|
||||||
const os = this;
|
const os = @This();
|
||||||
|
|
||||||
test "std.os" {
|
test "std.os" {
|
||||||
_ = @import("child_process.zig");
|
_ = @import("child_process.zig");
|
||||||
|
@ -75,7 +75,7 @@ const Allocator = std.mem.Allocator;
|
|||||||
/// size is small. `prealloc_item_count` must be 0, or a power of 2.
|
/// size is small. `prealloc_item_count` must be 0, or a power of 2.
|
||||||
pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type {
|
pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
const prealloc_exp = blk: {
|
const prealloc_exp = blk: {
|
||||||
// we don't use the prealloc_exp constant when prealloc_item_count is 0.
|
// we don't use the prealloc_exp constant when prealloc_item_count is 0.
|
||||||
assert(prealloc_item_count != 0);
|
assert(prealloc_item_count != 0);
|
||||||
|
@ -231,7 +231,7 @@ pub const Error = union(enum) {
|
|||||||
|
|
||||||
fn SingleTokenError(comptime msg: []const u8) type {
|
fn SingleTokenError(comptime msg: []const u8) type {
|
||||||
return struct {
|
return struct {
|
||||||
const ThisError = this;
|
const ThisError = @This();
|
||||||
|
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ pub const Error = union(enum) {
|
|||||||
|
|
||||||
fn SimpleError(comptime msg: []const u8) type {
|
fn SimpleError(comptime msg: []const u8) type {
|
||||||
return struct {
|
return struct {
|
||||||
const ThisError = this;
|
const ThisError = @This();
|
||||||
|
|
||||||
token: TokenIndex,
|
token: TokenIndex,
|
||||||
|
|
||||||
|
@ -1354,7 +1354,7 @@ test "zig fmt: indexing" {
|
|||||||
test "zig fmt: struct declaration" {
|
test "zig fmt: struct declaration" {
|
||||||
try testCanonical(
|
try testCanonical(
|
||||||
\\const S = struct {
|
\\const S = struct {
|
||||||
\\ const Self = this;
|
\\ const Self = @This();
|
||||||
\\ f1: u8,
|
\\ f1: u8,
|
||||||
\\ pub f3: u8,
|
\\ pub f3: u8,
|
||||||
\\
|
\\
|
||||||
|
@ -20,7 +20,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf(
|
|||||||
|
|
||||||
// make a passthrough stream that checks whether something changed
|
// make a passthrough stream that checks whether something changed
|
||||||
const MyStream = struct {
|
const MyStream = struct {
|
||||||
const MyStream = this;
|
const MyStream = @This();
|
||||||
const StreamError = @typeOf(stream).Child.Error;
|
const StreamError = @typeOf(stream).Child.Error;
|
||||||
const Stream = std.io.OutStream(StreamError);
|
const Stream = std.io.OutStream(StreamError);
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ test "implicitly cast a container to a const pointer of it" {
|
|||||||
|
|
||||||
fn Struct(comptime T: type) type {
|
fn Struct(comptime T: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
x: T,
|
x: T,
|
||||||
|
|
||||||
fn pointer(self: *const Self) Self {
|
fn pointer(self: *const Self) Self {
|
||||||
@ -106,7 +106,7 @@ const Enum = enum {
|
|||||||
|
|
||||||
test "implicitly cast indirect pointer to maybe-indirect pointer" {
|
test "implicitly cast indirect pointer to maybe-indirect pointer" {
|
||||||
const S = struct {
|
const S = struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
x: u8,
|
x: u8,
|
||||||
fn constConst(p: *const *const Self) u8 {
|
fn constConst(p: *const *const Self) u8 {
|
||||||
return p.*.x;
|
return p.*.x;
|
||||||
|
@ -628,7 +628,7 @@ test "call method with comptime pass-by-non-copying-value self parameter" {
|
|||||||
const S = struct {
|
const S = struct {
|
||||||
a: u8,
|
a: u8,
|
||||||
|
|
||||||
fn b(comptime s: this) u8 {
|
fn b(comptime s: @This()) u8 {
|
||||||
return s.a;
|
return s.a;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -510,9 +510,6 @@ test "@typeId" {
|
|||||||
assert(@typeId(AUnion) == Tid.Union);
|
assert(@typeId(AUnion) == Tid.Union);
|
||||||
assert(@typeId(fn () void) == Tid.Fn);
|
assert(@typeId(fn () void) == Tid.Fn);
|
||||||
assert(@typeId(@typeOf(builtin)) == Tid.Namespace);
|
assert(@typeId(@typeOf(builtin)) == Tid.Namespace);
|
||||||
assert(@typeId(@typeOf(x: {
|
|
||||||
break :x this;
|
|
||||||
})) == Tid.Block);
|
|
||||||
// TODO bound fn
|
// TODO bound fn
|
||||||
// TODO arg tuple
|
// TODO arg tuple
|
||||||
// TODO opaque
|
// TODO opaque
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const assert = @import("std").debug.assert;
|
const assert = @import("std").debug.assert;
|
||||||
const mem = @import("std").mem;
|
const mem = @import("std").mem;
|
||||||
const reflection = this;
|
const reflection = @This();
|
||||||
|
|
||||||
test "reflection: array, pointer, optional, error union type child" {
|
test "reflection: array, pointer, optional, error union type child" {
|
||||||
comptime {
|
comptime {
|
||||||
|
@ -423,10 +423,10 @@ fn alloc(comptime T: type) []T {
|
|||||||
|
|
||||||
test "call method with mutable reference to struct with no fields" {
|
test "call method with mutable reference to struct with no fields" {
|
||||||
const S = struct {
|
const S = struct {
|
||||||
fn doC(s: *const this) bool {
|
fn doC(s: *const @This()) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
fn do(s: *this) bool {
|
fn do(s: *@This()) bool {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
const assert = @import("std").debug.assert;
|
const assert = @import("std").debug.assert;
|
||||||
|
|
||||||
const module = this;
|
const module = @This();
|
||||||
|
|
||||||
fn Point(comptime T: type) type {
|
fn Point(comptime T: type) type {
|
||||||
return struct {
|
return struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
x: T,
|
x: T,
|
||||||
y: T,
|
y: T,
|
||||||
|
|
||||||
@ -19,11 +19,6 @@ fn add(x: i32, y: i32) i32 {
|
|||||||
return x + y;
|
return x + y;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn factorial(x: i32) i32 {
|
|
||||||
const selfFn = this;
|
|
||||||
return if (x == 0) 1 else x * selfFn(x - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
test "this refer to module call private fn" {
|
test "this refer to module call private fn" {
|
||||||
assert(module.add(1, 2) == 3);
|
assert(module.add(1, 2) == 3);
|
||||||
}
|
}
|
||||||
@ -37,7 +32,3 @@ test "this refer to container" {
|
|||||||
assert(pt.x == 13);
|
assert(pt.x == 13);
|
||||||
assert(pt.y == 35);
|
assert(pt.y == 35);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "this refer to fn" {
|
|
||||||
assert(factorial(5) == 120);
|
|
||||||
}
|
|
||||||
|
@ -166,7 +166,7 @@ fn testUnion() void {
|
|||||||
assert(TypeId(typeinfo_info) == TypeId.Union);
|
assert(TypeId(typeinfo_info) == TypeId.Union);
|
||||||
assert(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto);
|
assert(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto);
|
||||||
assert(typeinfo_info.Union.tag_type.? == TypeId);
|
assert(typeinfo_info.Union.tag_type.? == TypeId);
|
||||||
assert(typeinfo_info.Union.fields.len == 25);
|
assert(typeinfo_info.Union.fields.len == 24);
|
||||||
assert(typeinfo_info.Union.fields[4].enum_field != null);
|
assert(typeinfo_info.Union.fields[4].enum_field != null);
|
||||||
assert(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
|
assert(typeinfo_info.Union.fields[4].enum_field.?.value == 4);
|
||||||
assert(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int));
|
assert(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int));
|
||||||
@ -217,7 +217,7 @@ fn testStruct() void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TestStruct = packed struct {
|
const TestStruct = packed struct {
|
||||||
const Self = this;
|
const Self = @This();
|
||||||
|
|
||||||
fieldA: usize,
|
fieldA: usize,
|
||||||
fieldB: void,
|
fieldB: void,
|
||||||
|
@ -3813,11 +3813,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||||||
\\ return struct {
|
\\ return struct {
|
||||||
\\ b: B(),
|
\\ b: B(),
|
||||||
\\
|
\\
|
||||||
\\ const Self = this;
|
\\ const Self = @This();
|
||||||
\\
|
\\
|
||||||
\\ fn B() type {
|
\\ fn B() type {
|
||||||
\\ return struct {
|
\\ return struct {
|
||||||
\\ const Self = this;
|
\\ const Self = @This();
|
||||||
\\ };
|
\\ };
|
||||||
\\ }
|
\\ }
|
||||||
\\ };
|
\\ };
|
||||||
@ -4314,12 +4314,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||||||
\\ var a = undefined;
|
\\ var a = undefined;
|
||||||
\\ var b = 1;
|
\\ var b = 1;
|
||||||
\\ var c = 1.0;
|
\\ var c = 1.0;
|
||||||
\\ var d = this;
|
\\ var d = null;
|
||||||
\\ var e = null;
|
\\ var e = opaque.*;
|
||||||
\\ var f = opaque.*;
|
\\ var f = i32;
|
||||||
\\ var g = i32;
|
\\ var g = @import("std",);
|
||||||
\\ var h = @import("std",);
|
\\ var h = (Foo {}).bar;
|
||||||
\\ var i = (Foo {}).bar;
|
|
||||||
\\
|
\\
|
||||||
\\ var z: noreturn = return;
|
\\ var z: noreturn = return;
|
||||||
\\}
|
\\}
|
||||||
@ -4332,13 +4331,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||||||
".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",
|
".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",
|
||||||
".tmp_source.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
|
".tmp_source.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
|
||||||
".tmp_source.zig:9:4: error: variable of type 'comptime_float' must be const or comptime",
|
".tmp_source.zig:9:4: error: variable of type 'comptime_float' must be const or comptime",
|
||||||
".tmp_source.zig:10:4: error: variable of type '(block)' must be const or comptime",
|
".tmp_source.zig:10:4: error: variable of type '(null)' must be const or comptime",
|
||||||
".tmp_source.zig:11:4: error: variable of type '(null)' must be const or comptime",
|
".tmp_source.zig:11:4: error: variable of type 'Opaque' not allowed",
|
||||||
".tmp_source.zig:12:4: error: variable of type 'Opaque' not allowed",
|
".tmp_source.zig:12:4: error: variable of type 'type' must be const or comptime",
|
||||||
".tmp_source.zig:13:4: error: variable of type 'type' must be const or comptime",
|
".tmp_source.zig:13:4: error: variable of type '(namespace)' must be const or comptime",
|
||||||
".tmp_source.zig:14:4: error: variable of type '(namespace)' must be const or comptime",
|
".tmp_source.zig:14:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime",
|
||||||
".tmp_source.zig:15:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime",
|
".tmp_source.zig:16:4: error: unreachable code",
|
||||||
".tmp_source.zig:17:4: error: unreachable code",
|
|
||||||
);
|
);
|
||||||
|
|
||||||
cases.add(
|
cases.add(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user