Compare commits

..

21 Commits

Author SHA1 Message Date
d5476b54d7 Fix tests. 2025-09-13 22:02:44 +02:00
622ce388fa Actually fix which allocator we're using in the tests. 2025-09-13 22:01:29 +02:00
b0653b6563 Tracy 2025-09-11 17:29:45 +02:00
d6ea2e4c2f Memory optimization for the general case by reserving significantly fewer tokens in lexer. It was reserving 1 million always! 2025-09-11 12:27:44 +02:00
361a310ed1 Actually pass the allocator in so it's used instead of temp. 2025-09-11 11:33:16 +02:00
78e6d6146e Remove compiler ctx allocator 2025-09-11 11:23:07 +02:00
79ec6cc42f Added the rest of current builtins. Started properly implementing compile tests. 2025-09-11 11:03:02 +02:00
9461fe626f Change result to context for clarity. Fix a bunch of stuff in builtin functions and structs. 2025-09-10 23:21:34 +02:00
ceafd197f5 A bunch of new allocation related stuff. 2025-09-10 06:59:29 +02:00
f4a9592f26 Much better allocation strategy with new ncore arenas. Add more builtin node gen stuff. It's kind of wonky. 2025-09-06 23:30:45 +02:00
9cf51a1534 Broke builtins. 2025-09-06 19:58:46 +02:00
11c936ba7f Started load directive. 2025-09-03 22:31:18 +02:00
4924b01eac Added some initial directive code. Don't quite like the way it's done 2025-09-03 21:05:00 +02:00
603b625e21 Rename of files, improved for handling, add cb hints
- Rename Test to Ink as main file
- Support more errors for for loops.
- Add hints to cbs
2025-09-02 11:55:27 +02:00
9e0728f952 Fixed some error handling and weird consume logic. 2025-09-01 12:58:45 +02:00
94fc3a4dad Added basic for i loops. Missing some breaking tests and more tests. Also want to add for each at some point and it_index. 2025-08-30 22:58:51 +02:00
14f8b20d5f More small changes 2025-08-27 22:12:19 +02:00
4825623c73 Merge branch 'main' of git.nbross.com:nielsbross/Ink-Shader-Language 2025-08-27 21:55:08 +02:00
da87209690 Move compile result stuff out of specific stages. 2025-08-27 21:55:01 +02:00
e0908a67c0 Add hint parsing on constant buffers. Not yet used in output. 2025-08-25 22:08:58 +02:00
ab711b5610 Minor experiment 2025-08-25 21:56:08 +02:00
46 changed files with 2486 additions and 730 deletions

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "modules/nbrutil"] [submodule "modules/nbrutil"]
path = modules/ncore path = modules/ncore
url = git@git.nbross.com:nielsbross/NCore.git url = git@git.nbross.com:nielsbross/NCore.git
[submodule "modules/tracy"]
path = modules/tracy
url = https://github.com/rluba/jai-tracy.git

63
AST.jai
View File

@@ -14,6 +14,8 @@ AST_Kind :: enum {
Meta; Meta;
Instance; Instance;
//== //==
// Directives
If_Directive;
// Hint; // Hint;
// Type; // Type;
@@ -21,6 +23,7 @@ AST_Kind :: enum {
Call; Call;
Struct; Struct;
If; If;
For;
CBuffer; CBuffer;
FieldList; FieldList;
ArgList; ArgList;
@@ -190,7 +193,13 @@ pretty_print_children :: (parent : *AST_Node, indentation : int, builder : *Stri
ind = 0; ind = 0;
} }
// skip := ifx it_index > 0 then false else true; // skip := ifx it_index > 0 then false else true;
pretty_print_node(child, ind, builder);
if child.kind == .Function {
pretty_print_declaration(child, ind, builder);
} else {
pretty_print_node(child, ind, builder);
}
if it_index != children.count - 1 { if it_index != children.count - 1 {
if flags & .Separator { if flags & .Separator {
@@ -309,6 +318,26 @@ pretty_print_if :: (node : *AST_Node, indentation : int, builder : *String_Build
append(builder, ")"); append(builder, ")");
} }
pretty_print_for :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
if !skip_indent {
indent(builder, indentation);
}
append(builder, "(for ");
loop_iterator := node.token;
print_to_builder(builder, "% : ", loop_iterator.ident_value);
pretty_print_node(node.children[0], 0, builder);
append(builder, "..");
pretty_print_node(node.children[1], 0, builder);
append(builder, "\n");
pretty_print_node(node.children[2], indentation + 4, builder);
append(builder, ")");
}
print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) { print_expression_statement :: (node : *AST_Node, indentation : int, builder : *String_Builder, skip_indent := false) {
if !skip_indent { if !skip_indent {
indent(builder, indentation); indent(builder, indentation);
@@ -327,6 +356,9 @@ pretty_print_node :: (node : *AST_Node, indentation : int, builder : *String_Bui
case .If; { case .If; {
pretty_print_if(node, indentation, builder, skip_indent); pretty_print_if(node, indentation, builder, skip_indent);
} }
case .For; {
pretty_print_for(node, indentation, builder, skip_indent);
}
case .Struct; case .Struct;
case .ArgList; { case .ArgList; {
pretty_print_arglist(node, indentation + 2, builder, skip_indent); pretty_print_arglist(node, indentation + 2, builder, skip_indent);
@@ -410,6 +442,10 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
append(builder, "pixel "); append(builder, "pixel ");
} }
if declaration.kind == .If_Directive {
append(builder, "#if ");
}
if declaration.kind == .Properties { if declaration.kind == .Properties {
append(builder, "properties"); append(builder, "properties");
if declaration.name.count > 0 { if declaration.name.count > 0 {
@@ -439,24 +475,15 @@ pretty_print_declaration :: (declaration : *AST_Node, indentation : int, builder
} }
if declaration.children.count > 0 { if declaration.children.count > 0 {
// print_to_builder(builder, "\n"); if declaration.kind == .If_Directive {
// if declaration.kind == .Function { pretty_print_node(declaration.children[0], 0, builder);
// field_list := declaration.children[0]; append(builder, "\n");
// pretty_print_fieldlist(field_list, indentation + 1, builder); pretty_print_node(declaration.children[1], indentation + 5, builder);
// append(builder, "\n"); } else {
print_to_builder(builder, "\n");
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
}
// if declaration.children.count > 1 {
// body := declaration.children[1];
// pretty_print_node(body, indentation + 1, builder, true);
// }
// } else if declaration.kind == .Struct {
// pretty_print_node(declaration.children[0], indentation + 1, builder);
// } else {
// pretty_print_node(declaration.children[0], indentation + 1, builder);
// }
print_to_builder(builder, "\n");
pretty_print_children(declaration, indentation + 1, builder, flags = .NewLine);
} }
append(builder, ")"); append(builder, ")");

View File

@@ -16,26 +16,26 @@ Output_Language :: enum {
Codegen_State :: struct { Codegen_State :: struct {
path : string; path : string;
scope_stack : Scope_Stack; // scope_stack : Scope_Stack;
current_scope : Scope_Handle; current_scope : Scope_Handle;
type_variables : []Type_Variable; // type_variables : []Type_Variable;
root : *AST_Node; // root : *AST_Node;
output_language : Output_Language; output_language : Output_Language;
builder : String_Builder; builder : String_Builder;
result : Codegen_Result; result : *Compiler_Context;
} }
Codegen_Result :: struct { // Codegen_Result :: struct {
messages : [..]Compiler_Message; // messages : [..]Compiler_Message;
had_error : bool; // had_error : bool;
result_text : string; // @Incomplete(nb): Result for now, should likely be far more sophisticated. // result_text : string; // @Incomplete(nb): Result for now, should likely be far more sophisticated.
} // }
Reserved_HLSL_Words :: string.[ Reserved_HLSL_Words :: string.[
"texture", "texture",
@@ -56,10 +56,7 @@ Reserved_GLSL_Words :: string.[
"" ""
]; ];
init_codegen_state :: (state : *Codegen_State, file : *Compiled_File, output_language : Output_Language) { init_codegen_state :: (state : *Codegen_State, result : *Compiler_Context, output_language : Output_Language) {
state.root = file.ast_root;
state.scope_stack = file.scope_stack;
state.type_variables = file.type_variables;
state.current_scope = cast(Scope_Handle)1; state.current_scope = cast(Scope_Handle)1;
state.output_language = output_language; state.output_language = output_language;
init_string_builder(*state.builder); init_string_builder(*state.builder);
@@ -105,16 +102,16 @@ hlsl_type_to_string :: (type_variable : Type_Variable) -> string {
} }
emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) { emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
find_result := find_symbol(state.scope_stack, node.name, state.current_scope); find_result := find_symbol(state.result.scope_stack, node.name, state.current_scope);
field := from_handle(state.type_variables, find_result.type_variable); field := from_handle(state.result.type_variables, find_result.type_variable);
indent(state, indentation); indent(state, indentation);
print_to_builder(*state.builder, "% ", hlsl_type_to_string(field)); print_to_builder(*state.builder, "% ", hlsl_type_to_string(field));
if field.struct_field_parent { if field.struct_field_parent {
parent_tv := from_handle(state.type_variables, field.struct_field_parent.type_variable); parent_tv := from_handle(state.result.type_variables, field.struct_field_parent.type_variable);
if parent_tv.typename == "properties" { if parent_tv.typename == "properties" {
append(*state.builder, "__PROPERTIES__"); append(*state.builder, "__PROPERTIES__");
@@ -144,7 +141,7 @@ emit_field :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
for i :0..field.children.count - 1 { for i :0..field.children.count - 1 {
child := from_handle(state.type_variables, field.children[i]); child := from_handle(state.result.type_variables, field.children[i]);
emit_node(state, child.source_node, 0); emit_node(state, child.source_node, 0);
} }
@@ -230,7 +227,7 @@ emit_call :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
} }
emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int) { emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
find_result := find_symbol(state.scope_stack, ifx node.name.count > 0 then node.name else "properties", state.current_scope); find_result := find_symbol(state.result.scope_stack, ifx node.name.count > 0 then node.name else "properties", state.current_scope);
if !find_result { if !find_result {
message : Compiler_Message; message : Compiler_Message;
@@ -241,7 +238,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
} }
assert(find_result != null, "Attempting to generate undeclared properties buffer. This should never happen at this stage."); assert(find_result != null, "Attempting to generate undeclared properties buffer. This should never happen at this stage.");
variable := from_handle(state.type_variables, find_result.type_variable); variable := from_handle(state.result.type_variables, find_result.type_variable);
print_to_builder(*state.builder, "cbuffer __PROPERTIES : register(b%) \n{\n", variable.resource_index); print_to_builder(*state.builder, "cbuffer __PROPERTIES : register(b%) \n{\n", variable.resource_index);
@@ -253,7 +250,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
for child : node.children { for child : node.children {
if child.kind == .FieldList { if child.kind == .FieldList {
for field : child.children { for field : child.children {
tv := from_handle(state.type_variables, field.type_variable); tv := from_handle(state.result.type_variables, field.type_variable);
if tv.type == .Sampler || tv.type == .Texture2D { if tv.type == .Sampler || tv.type == .Texture2D {
array_add(*resources, field); array_add(*resources, field);
continue; continue;
@@ -281,7 +278,7 @@ emit_properties :: (state : *Codegen_State, node : *AST_Node, indentation : int)
emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, emit_body := true) { emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, emit_body := true) {
name := get_actual_function_name(node); name := get_actual_function_name(node);
find_result := find_symbol(state.scope_stack, name, state.current_scope); find_result := find_symbol(state.result.scope_stack, name, state.current_scope);
assert(find_result != null, "Attempting to generate undeclared function. This should never happen at this stage."); assert(find_result != null, "Attempting to generate undeclared function. This should never happen at this stage.");
if !find_result { if !find_result {
@@ -293,12 +290,12 @@ emit_function :: (state : *Codegen_State, node : *AST_Node, indentation : int, e
} }
for func : find_result.functions { for func : find_result.functions {
function_variable := from_handle(state.type_variables, func.type_variable); function_variable := from_handle(state.result.type_variables, func.type_variable);
indent(state, indentation); indent(state, indentation);
if function_variable.return_type_variable { if function_variable.return_type_variable {
return_variable := from_handle(state.type_variables, function_variable.return_type_variable); return_variable := from_handle(state.result.type_variables, function_variable.return_type_variable);
print_to_builder(*state.builder, "% ", hlsl_type_to_string(return_variable)); print_to_builder(*state.builder, "% ", hlsl_type_to_string(return_variable));
} else { } else {
append(*state.builder, "void "); append(*state.builder, "void ");
@@ -438,12 +435,12 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
case .Variable; { case .Variable; {
indent(*state.builder, indentation); indent(*state.builder, indentation);
type_var := from_handle(state.type_variables, node.type_variable); type_var := from_handle(state.result.type_variables, node.type_variable);
is_properties := type_var.typename == "properties"; is_properties := type_var.typename == "properties";
if !is_properties { if !is_properties {
if type_var.struct_field_parent { if type_var.struct_field_parent {
parent_tv := from_handle(state.type_variables, type_var.struct_field_parent.type_variable); parent_tv := from_handle(state.result.type_variables, type_var.struct_field_parent.type_variable);
if parent_tv.typename == "properties" { if parent_tv.typename == "properties" {
append(*state.builder, "__PROPERTIES__"); append(*state.builder, "__PROPERTIES__");
@@ -497,6 +494,26 @@ emit_node :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
emit_node(state, node.children[0], 0); emit_node(state, node.children[0], 0);
append(*state.builder, ";"); append(*state.builder, ";");
} }
case .For; {
if node.parent.kind != .For {
indent(*state.builder, indentation);
}
append(*state.builder, "for ");
loop_ident := node.token.ident_value;
begin_val := node.children[0].integer_value;
end_val := node.children[1].integer_value;
print_to_builder(*state.builder, "(int % = %; % < %; %++)\n", loop_ident, begin_val, loop_ident, end_val, loop_ident);
indent(*state.builder, indentation);
append(*state.builder, "{\n");
emit_block(state, node.children[2], indentation + 1);
indent(*state.builder, indentation);
append(*state.builder, "}\n");
}
case .If; { case .If; {
if node.parent.kind != .If { if node.parent.kind != .If {
indent(*state.builder, indentation); indent(*state.builder, indentation);
@@ -556,7 +573,7 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
print_to_builder(*state.builder, "struct %", node.name); print_to_builder(*state.builder, "struct %", node.name);
current_scope := state.current_scope; current_scope := state.current_scope;
state.current_scope = from_handle(state.type_variables, node.type_variable).scope; state.current_scope = from_handle(state.result.type_variables, node.type_variable).scope;
field_list := node.children[0]; field_list := node.children[0];
@@ -573,11 +590,11 @@ emit_struct :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
} }
emit_cbuffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) { emit_cbuffer :: (state : *Codegen_State, node : *AST_Node, indentation : int) {
variable := from_handle(state.type_variables, node.type_variable); variable := from_handle(state.result.type_variables, node.type_variable);
print_to_builder(*state.builder, "cbuffer % : register(b%)", variable.name, variable.resource_index); print_to_builder(*state.builder, "cbuffer % : register(b%)", variable.name, variable.resource_index);
current_scope := state.current_scope; current_scope := state.current_scope;
state.current_scope = from_handle(state.type_variables, node.type_variable).scope; state.current_scope = from_handle(state.result.type_variables, node.type_variable).scope;
field_list := node.children[0]; field_list := node.children[0];
@@ -610,26 +627,37 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
} }
} }
codegen :: (result : *Compile_Result) { codegen :: (result : *Compiler_Context, allocator := temp) {
codegen(result, .HLSL);
}
codegen :: (result : *Compiler_Context, output_language : Output_Language, allocator := temp) {
if result.had_error { if result.had_error {
return; return;
} }
for *file : result.files { new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
state : Codegen_State; state : Codegen_State;
init_codegen_state(*state, file, .HLSL); state.result = result;
state.current_scope = cast(Scope_Handle)1;
state.output_language = output_language;
init_string_builder(*state.builder);
codegen_result := codegen(*state); codegen(*state);
file.codegen_result_text = copy_string(codegen_result.result_text);
} }
} }
codegen :: (state : *Codegen_State) -> Codegen_Result { #scope_file
codegen :: (state : *Codegen_State) {
found_function : bool = false; found_function : bool = false;
// found_struct : bool = false; // found_struct : bool = false;
// for variable : state.type_variables { // for variable : state.result.type_variables {
// if variable.type == .Struct && variable.kind == .Declaration && !variable.builtin { // if variable.type == .Struct && variable.kind == .Declaration && !variable.builtin {
// if variable.source_node.kind == .Properties continue; // if variable.source_node.kind == .Properties continue;
// if variable.source_node.kind == .Meta continue; // if variable.source_node.kind == .Meta continue;
@@ -642,7 +670,7 @@ codegen :: (state : *Codegen_State) -> Codegen_Result {
// append(*state.builder, "\n"); // append(*state.builder, "\n");
// } // }
for variable : state.type_variables { for variable : state.result.type_variables {
if variable.type == .Function && !variable.builtin if variable.type == .Function && !variable.builtin
&& !variable.source_node.vertex_entry_point && !variable.source_node.pixel_entry_point { && !variable.source_node.vertex_entry_point && !variable.source_node.pixel_entry_point {
emit_function(state, variable.source_node, 0, false); emit_function(state, variable.source_node, 0, false);
@@ -653,22 +681,14 @@ codegen :: (state : *Codegen_State) -> Codegen_Result {
append(*state.builder, "\n"); append(*state.builder, "\n");
} }
for declaration : state.root.children { for declaration : state.result.root.children {
if declaration.foreign_declaration { if declaration.foreign_declaration {
continue; continue;
} }
emit_declaration(state, declaration); emit_declaration(state, declaration);
} }
state.result.result_text = builder_to_string(*state.builder); state.result.codegen_result_text = builder_to_string(*state.builder);
return state.result;
}
codegen :: (file : *Compiled_File, output_language : Output_Language) -> Codegen_Result {
codegen_state : Codegen_State;
init_codegen_state(*codegen_state, file, output_language);
return codegen(*codegen_state);
} }
#scope_module #scope_module

View File

@@ -1,10 +1,14 @@
///////////////////////////////////// /////////////////////////////////////
//~ nbr: General improvements /*~ nbr: General improvements
// - [x] Print out all failed tests in a list at the end
// [x] Print out all failed tests in a list at the end - [x] Use new compiler API with Compile_Result and Compiled_File instead
// [ ] Use new compiler API with Compile_Result and Compiled_File instead - [ ] Use unix (posix? bash? ascii?) color codes for errors
// [ ] Use unix (posix? bash? ascii?) color codes for errors - [ ] Print golden file as green and new output as red
// [ ] Print golden file as green and new output as red - [ ] Rename to Ink.jai
- [ ] Add -test option. -test does the same as test.exe used to do
- [ ] Add -fuzz option to run fuzzer (add args later)
- [ ] Add -output option to output the compiled file. Issue with this is the generated data can't be output like that. Would require serialization.
*/
#import "Basic"; #import "Basic";
#import "File"; #import "File";
@@ -68,9 +72,11 @@ Test_Suite :: struct {
results : [..]Result; results : [..]Result;
} }
get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := context.allocator) -> string { get_golden_path :: (file_path : string, stage : Stage_Flags) -> string {
path := parse_path(file_path); sc := get_scratch();
file_without_extension := split(path.words[path.words.count - 1], "."); defer scratch_end(sc);
path := parse_path(file_path,, sc.allocator);
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
builder : String_Builder; builder : String_Builder;
builder.allocator = temp; builder.allocator = temp;
@@ -78,6 +84,7 @@ get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := contex
final_path_length := file_path.count - SHADER_EXTENSION.count + GOLDEN_EXTENSION.count + 1; // +1 for dot final_path_length := file_path.count - SHADER_EXTENSION.count + GOLDEN_EXTENSION.count + 1; // +1 for dot
path.words.count -= 1; path.words.count -= 1;
path.words.allocator = sc.allocator;
if stage == { if stage == {
case .Lexer; { case .Lexer; {
@@ -108,10 +115,11 @@ get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := contex
} }
init_string_builder(*builder, file_without_extension.count + GOLDEN_EXTENSION.count + 1); init_string_builder(*builder, file_without_extension.count + GOLDEN_EXTENSION.count + 1);
builder.allocator = sc.allocator;
append(*builder, file_without_extension[0]); append(*builder, file_without_extension[0]);
append(*builder, "."); append(*builder, ".");
append(*builder, GOLDEN_EXTENSION); append(*builder, GOLDEN_EXTENSION);
golden_path := builder_to_string(*builder); golden_path := builder_to_string(*builder,, sc.allocator);
array_add(*path.words, golden_path); array_add(*path.words, golden_path);
final_path := path_to_string(path); final_path := path_to_string(path);
@@ -119,208 +127,234 @@ get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := contex
return final_path; return final_path;
} }
do_golden_comparison :: (golden_path : string, comparison_text : string, result_data : *Result, output_type : Output_Type) { do_golden_comparison :: (golden_path : string, comparison_text : string, result : *Result, output_type : Output_Type) {
sc := get_scratch();
defer scratch_end(sc);
if output_type & .Golden { if output_type & .Golden {
// Output the comparison file // Output the comparison file
write_entire_file(golden_path, comparison_text); write_entire_file(golden_path, comparison_text);
result_data.golden_path = copy_string(golden_path); result.golden_path = copy_string(golden_path);
result_data.type = .Golden_Output; result.type = .Golden_Output;
return; return;
} else { } else {
// Do the comparison // Do the comparison
if !file_exists(golden_path) { if !file_exists(golden_path) {
result_data.info_text = tprint("Golden file % does not exist. Please run with -output-as-golden at least once.\n", golden_path); result.info_text = tprint("Golden file % does not exist. Please run with -output-as-golden at least once.\n", golden_path);
result_data.type = .Golden_File_Not_Found; result.type = .Golden_File_Not_Found;
return; return;
} }
golden_text, ok := read_entire_file(golden_path); golden_text, ok := read_entire_file(golden_path,, sc.allocator);
if !ok { if !ok {
result_data.info_text = tprint("Unable to open golden file %\n", golden_path); result.info_text = tprint("Unable to open golden file %\n", golden_path);
result_data.type = .Golden_File_Not_Found; result.type = .Golden_File_Not_Found;
return; return;
} }
comp := replace(comparison_text, "\r\n", "\n"); comp := replace(comparison_text, "\r\n", "\n",, sc.allocator);
gold := replace(golden_text, "\r\n", "\n"); gold := replace(golden_text, "\r\n", "\n",, sc.allocator);
result := compare(comp, gold) == 0; ok = compare(comp, gold) == 0;
if !result { if !ok {
result_data.type = .Failed; result.type = .Failed;
result_data.info_text = tprint("Golden file:\n%\n===============\n%", gold, comp); result.info_text = tprint("Golden file:\n%\n===============\n%", gold, comp);
} else { } else {
result_data.type = .Passed; result.type = .Passed;
} }
} }
} }
run_codegen_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_codegen_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
add_file(result, file_path); result : Result;
result.path = file_path;
result_data : Result; lex(ctx, context.allocator);
result_data.path = file_path; parse(ctx, context.allocator);
check(ctx, context.allocator);
lex(result); if ctx.had_error {
parse(result); result.type = .Failed;
check(result); return result;
if result.had_error {
result_data.type = .Failed;
return result_data;
} }
result_data = run_codegen_test(result, output_type); result = run_codegen_test(ctx, output_type);
return result_data; return result;
} }
run_codegen_test :: (result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_codegen_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
result_data : Result; result : Result;
result_data.path = result.files[0].file.path; result.path = ctx.file.path;
result_text : string; result_text : string;
codegen(result); codegen(ctx, context.allocator);
if result.had_error { if ctx.had_error {
result_data.type = .Failed; result.type = .Failed;
result_text = report_messages(result.messages); result_text = report_messages(ctx.messages);
return result_data; return result;
} }
result_text = result.files[0].codegen_result_text; result_text = ctx.codegen_result_text;
if output_type & .StdOut { if output_type & .StdOut {
result_data.info_text = result_text; result.info_text = result_text;
result_data.type = .StdOut; result.type = .StdOut;
return result_data; return result;
} }
golden_path := get_golden_path(result.files[0].file.path, .Codegen); golden_path := get_golden_path(ctx.file.path, .Codegen);
do_golden_comparison(golden_path, result_text, *result_data, output_type); do_golden_comparison(golden_path, result_text, *result, output_type);
return result_data; return result;
} }
run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compile_Result { run_compile_test :: (path : string, output_type : Output_Type = 0) -> Result, Compiler_Context {
compiler : Shader_Compiler; ctx : Compiler_Context;
result : Result; result : Result;
compilation_result := compile_file(*compiler, path); result.path = path;
print("\n"); compile_file(*ctx, path, context.allocator);
if compilation_result.had_error { if ctx.had_error {
result.type = .Failed; result.type = .Failed;
result.info_text = tprint("Failed compiling: %\n", path); result.info_text = tprint("Failed compiling: %\n", path);
}
return result, compilation_result;
}
run_lexer_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
result_data : Result;
result_data.path = file_path;
result_data.stage = .Lexer;
result_text : string;
add_file(result, file_path);
lex(result);
if result.had_error {
result_data.type = .Failed;
result_text = report_messages(result.messages);
} else { } else {
result_text = pretty_print_tokens(result.files[0].tokens.tokens, *temp); sc := get_scratch();
defer scratch_end(sc);
sb : String_Builder;
init_string_builder(*sb,, sc.allocator);
if ctx.vertex_entry_point.name.count > 0 {
print_to_builder(*sb, "[vertex entry point] - %\n", ctx.vertex_entry_point.name);
}
if ctx.pixel_entry_point.name.count > 0 {
print_to_builder(*sb, "[pixel entry point] - %\n", ctx.pixel_entry_point.name);
}
for cb : ctx.cbuffers {
print_to_builder(*sb, "[constant_buffer] - % - %\n", cb.name, cb.buffer_index);
indent(*sb, 1);
for field : cb.fields {
append(*sb, "[field] - ");
pretty_print_field(*sb, *field.base_field);
}
}
result.info_text = builder_to_string(*sb);
} }
if output_type & .StdOut { if output_type & .StdOut {
result_data.info_text = result_text; result.type = .StdOut;
result_data.type = .StdOut; return result, ctx;
return result_data; }
golden_path := get_golden_path(ctx.file.path, .Compile);
do_golden_comparison(golden_path, result.info_text, *result, output_type);
return result, ctx;
}
run_lexer_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
result : Result;
result.path = file_path;
result.stage = .Lexer;
result_text : string;
lex(ctx);
if ctx.had_error {
result.type = .Failed;
result_text = report_messages(ctx.messages);
} else {
result_text = pretty_print_tokens(ctx.tokens, context.allocator);
}
if output_type & .StdOut {
result.info_text = result_text;
result.type = .StdOut;
return result;
} }
golden_path := get_golden_path(file_path, .Lexer); golden_path := get_golden_path(file_path, .Lexer);
do_golden_comparison(golden_path, result_text, *result_data, output_type); do_golden_comparison(golden_path, result_text, *result, output_type);
return result_data; return result;
} }
run_parser_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_parser_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
result_data : Result; result : Result;
result_data.path = file_path; result.path = file_path;
add_file(result, file_path); lex(ctx);
if ctx.had_error {
lex(result); result.type = .Passed;
if result.had_error { return result;
result_data.type = .Passed;
return result_data;
} }
result_data = run_parser_test(result, output_type); result = run_parser_test(ctx, output_type);
return result_data; return result;
} }
run_parser_test :: (result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_parser_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
parse(result); parse(ctx, context.allocator);
result_data : Result; result : Result;
result_data.path = result.files[0].file.path; result.path = ctx.file.path;
result_text : string; result_text : string;
if result.had_error { if ctx.had_error {
result_data.type = .Failed; result.type = .Failed;
result_text = report_messages(result.messages,, temp); result_text = report_messages(ctx.messages);
} else { } else {
result_text = pretty_print_ast(result.files[0].ast_root, *temp); result_text = pretty_print_ast(ctx.root, context.allocator);
} }
if output_type & .StdOut { if output_type & .StdOut {
result_data.info_text = result_text; result.info_text = result_text;
result_data.type = .StdOut; result.type = .StdOut;
return result_data; return result;
} }
golden_path := get_golden_path(result.files[0].file.path, .Parser); golden_path := get_golden_path(ctx.file.path, .Parser);
do_golden_comparison(golden_path, result_text, *result_data, output_type); do_golden_comparison(golden_path, result_text, *result, output_type);
return result_data; return result;
} }
run_semantic_analysis_test :: (result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_semantic_analysis_test :: (ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
result_data : Result; result : Result;
result_data.path = result.files[0].file.path; result.path = ctx.file.path;
result_text : string; result_text : string;
check(result); check(ctx, context.allocator);
if result.had_error { if ctx.had_error {
result_data.type = .Failed; result.type = .Failed;
result_text = report_messages(result.messages); result_text = report_messages(ctx.messages);
} else { } else {
result_text = pretty_print_symbol_table(result, temp); result_text = pretty_print_symbol_table(ctx, context.allocator);
} }
if output_type & .StdOut { if output_type & .StdOut {
result_data.info_text = result_text; result.info_text = result_text;
result_data.type = .StdOut; result.type = .StdOut;
return result_data; return result;
} }
golden_path := get_golden_path(result.files[0].file.path, .Semantic_Analysis); golden_path := get_golden_path(ctx.file.path, .Semantic_Analysis);
do_golden_comparison(golden_path, result_text, *result_data, output_type); do_golden_comparison(golden_path, result_text, *result, output_type);
return result_data; return result;
} }
run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result { run_semantic_analysis_test :: (file_path : string, ctx : *Compiler_Context, output_type : Output_Type = 0) -> Result {
add_file(result, file_path); result : Result;
result.path = file_path;
result_data : Result; lex(ctx, context.allocator);
result_data.path = file_path; parse(ctx, context.allocator);
if ctx.had_error {
lex(result); result.type = .Failed;
parse(result); return result;
if result.had_error {
result_data.type = .Failed;
return result_data;
} }
result_data = run_semantic_analysis_test(result, output_type);; result = run_semantic_analysis_test(ctx, output_type);
return result_data; return result;
} }
make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := context.allocator) -> Test_Case { make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := context.allocator) -> Test_Case {
@@ -332,48 +366,57 @@ make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := contex
return test_case; return test_case;
} }
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) { run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
compile_result : Compile_Result; new_context := context;
result : Result; new_context.allocator = allocator;
if stage_flags & .Lexer { push_context new_context {
result = run_lexer_test(file_path, *compile_result, output_type); ctx : Compiler_Context;
record_result(results, result);
}
if stage_flags & .Parser { ctx.file = make_file(*ctx, file_path);
if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
result = run_parser_test(*compile_result, output_type); result : Result;
} else { if stage_flags & .Lexer {
result = run_parser_test(file_path, *compile_result, output_type); result = run_lexer_test(file_path, *ctx, output_type);
record_result(results, result);
} }
record_result(results, result);
}
if stage_flags & .Semantic_Analysis { if stage_flags & .Parser {
if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) { if stage_flags & .Lexer && result.type == .Passed || result.type == .Golden_Output {
result = run_semantic_analysis_test(*compile_result, output_type); result = run_parser_test(*ctx, output_type);
} else { } else {
result = run_semantic_analysis_test(file_path, *compile_result, output_type); result = run_parser_test(file_path, *ctx, output_type);
}
record_result(results, result);
} }
record_result(results, result);
}
if stage_flags & .Codegen { if stage_flags & .Semantic_Analysis {
if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) { if stage_flags & .Parser && (result.type == .Passed || result.type == .Golden_Output) {
result = run_codegen_test(*compile_result, output_type); result = run_semantic_analysis_test(*ctx, output_type);
} else { } else {
result = run_codegen_test(file_path, *compile_result, output_type); result = run_semantic_analysis_test(file_path, *ctx, output_type);
}
record_result(results, result);
} }
record_result(results, result);
}
if stage_flags & .Compile { if stage_flags & .Codegen {
result = run_compile_test(file_path, output_type); if stage_flags & .Semantic_Analysis && (result.type == .Passed || result.type == .Golden_Output) {
result = run_codegen_test(*ctx, output_type);
} else {
result = run_codegen_test(file_path, *ctx, output_type);
}
record_result(results, result);
}
if stage_flags & .Compile {
result = run_compile_test(file_path, output_type);
record_result(results, result);
}
} }
} }
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0, builder : *String_Builder) { run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0, allocator := temp) {
print_to_builder(builder, "%Running test: %......", cyan(), test_case.path); print("%Running test: %......", cyan(), test_case.path);
// path 30 // path 30
// len 35 // len 35
@@ -387,11 +430,10 @@ run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_
len := 50; len := 50;
rest := len - test_case.path.count; rest := len - test_case.path.count;
for i: 0..rest { for i: 0..rest {
append(builder, " "); print(" ");
} }
run_test_new(test_case.path, test_case.stage_flags, results, output_type); run_test_new(test_case.path, test_case.stage_flags, results, output_type, allocator);
// run_test(test_case.path, test_case.stage_flags, results, output_type);
} }
record_result :: (results : *[..]Result, result : Result) { record_result :: (results : *[..]Result, result : Result) {
@@ -408,15 +450,17 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
path : string; path : string;
stage : string; stage : string;
} }
test_arena : Allocator = make_arena(Gigabytes(1));
failed_test_paths : [..]Fail_Data; failed_test_paths : [..]Fail_Data;
failed_test_paths.allocator = temp; failed_test_paths.allocator = test_arena;
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, temp); init_string_builder(*builder,, test_arena);
for test_case : test_cases { for test_case : test_cases {
run_test(test_case, *suite.results, output_type, *builder); run_test(test_case, *suite.results, output_type, allocator = test_arena);
for < suite.results { for < suite.results {
result := suite.results[it_index]; result := suite.results[it_index];
@@ -432,7 +476,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
array_add(*failed_test_paths, .{ result.path, tprint("golden file not found for %", stage_to_string(result.stage)) }); array_add(*failed_test_paths, .{ result.path, tprint("golden file not found for %", stage_to_string(result.stage)) });
} }
} }
evaluate_result(result, *builder); evaluate_result(result);
} else { } else {
break; break;
} }
@@ -459,23 +503,33 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
} }
} }
print("%\n", builder_to_string(*builder)); print("%\n", builder_to_string(*builder,, test_arena));
} }
read_suite :: (file_path : string, suite : *Test_Suite) -> bool { read_suite :: (file_path : string, suite : *Test_Suite, allocator := temp) -> bool {
bytes, ok := read_entire_file(file_path); sc := get_scratch();
defer scratch_end(sc);
bytes, ok := read_entire_file(file_path,, sc.allocator);
if !ok { if !ok {
log_error("Unable to read suite file %\n", file_path); log_error("Unable to read suite file %\n", file_path);
return false; return false;
} }
path := parse_path(file_path); path := parse_path(file_path,, sc.allocator);
file_without_extension := split(path.words[path.words.count - 1], "."); file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
suite.name = copy_string(file_without_extension[0]); suite.name = copy_string(file_without_extension[0],, allocator);
split_lines := split(bytes, "\n"); split_lines := split(bytes, "\n",, sc.allocator);
for split_line : split_lines { for split_line : split_lines {
line := split(split_line, " "); if split_line.count == 0 {
break;
}
if split_line[0] == #char "#" {
continue;
}
line := split(split_line, " ",, sc.allocator);
if line[0].count == 0 { if line[0].count == 0 {
continue; continue;
} }
@@ -485,7 +539,7 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
} }
if line.count == 1 { if line.count == 1 {
line = split(split_line, "\t"); line = split(split_line, "\t",, sc.allocator);
if line.count == 1 { if line.count == 1 {
log_error("Invalid line - % - \n", it_index + 1); log_error("Invalid line - % - \n", it_index + 1);
continue; continue;
@@ -508,7 +562,7 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
stage_flags |= .Compile; stage_flags |= .Compile;
} }
} }
test_case := make_test_case(test_case_path, stage_flags); test_case := make_test_case(test_case_path, stage_flags, allocator);
array_add(*suite.test_cases, test_case); array_add(*suite.test_cases, test_case);
} }
@@ -530,54 +584,58 @@ stage_to_string :: (stage : Stage_Flags) -> string {
} }
} }
evaluate_result :: (result : Result, builder : *String_Builder) { evaluate_result :: (result : Result) {
stage : string = stage_to_string(result.stage); stage : string = stage_to_string(result.stage);
if #complete result.type == { if #complete result.type == {
case .File_Read_Failed; { case .File_Read_Failed; {
print_to_builder(builder, " %", red()); print(" %", red());
print_to_builder(builder, "failed with File_Read_Failed\n"); print("failed with File_Read_Failed\n");
} }
case .Golden_File_Not_Found; { case .Golden_File_Not_Found; {
print_to_builder(builder, " %", red()); print(" %", red());
print_to_builder(builder, "failed with Golden File Not Found for stage %\n", stage); print("failed with Golden File Not Found for stage %\n", stage);
} }
case .StdOut; { case .StdOut; {
} }
case .Golden_Output; { case .Golden_Output; {
print_to_builder(builder, " %", yellow()); print(" %", yellow());
print_to_builder(builder, "output new golden file at %\n", result.golden_path); print("output new golden file at %\n", result.golden_path);
} }
case .Passed; { case .Passed; {
print_to_builder(builder, " %", green()); print(" %", green());
print_to_builder(builder, "passed %\n", stage); print("passed %\n", stage);
} }
case .Failed; { case .Failed; {
print_to_builder(builder, " %", red()); print(" %", red());
print_to_builder(builder, "failed %\n", stage); print("failed %\n", stage);
} }
} }
if result.info_text.count > 0 { if result.info_text.count > 0 {
print_to_builder(builder, "%", cyan()); print("%", cyan());
print_to_builder(builder, "--- Info text ---\n"); print("--- Info text ---\n");
print_to_builder(builder, "%", yellow()); print("%", yellow());
print_to_builder(builder, "%\n", result.info_text); print("%\n", result.info_text);
} }
print_to_builder(builder, "%", reset_color()); print("%", reset_color());
} }
main :: () { main :: () {
lexer : Lexer;
args := get_command_line_arguments(); args := get_command_line_arguments();
init_context_allocators();
local_temp := make_arena(Megabytes(128));
suites : [..]Test_Suite; suites : [..]Test_Suite;
suites.allocator = local_temp;
output_type : Output_Type = 0; output_type : Output_Type = 0;
Argument_Parse_State :: enum { Argument_Parse_State :: enum {
None; None;
Compile;
Run_Suite; Run_Suite;
Run_Test; Run_Test;
} }
@@ -620,12 +678,14 @@ main :: () {
} else if arg == "-compile" { } else if arg == "-compile" {
current_suite.test_cases[cases - 1].stage_flags |= .Compile; current_suite.test_cases[cases - 1].stage_flags |= .Compile;
} else if contains(arg, ".") { } else if contains(arg, ".") {
path_split := split(arg, "\\"); sc := get_scratch();
split_path := split(path_split[path_split.count - 1], "."); defer scratch_end(sc);
path_split := split(arg, "\\",, sc.allocator);
split_path := split(path_split[path_split.count - 1], ".",, sc.allocator);
extension := split_path[1]; extension := split_path[1];
if extension == SHADER_EXTENSION { if extension == SHADER_EXTENSION {
path := copy_string(arg); path := copy_string(arg,, local_temp);
test_case := make_test_case(path, 0); test_case := make_test_case(path, 0, local_temp);
array_add(*current_suite.test_cases, test_case); array_add(*current_suite.test_cases, test_case);
} else { } else {
print("%Invalid file as argument % %\n", red(), arg, reset_color()); print("%Invalid file as argument % %\n", red(), arg, reset_color());
@@ -636,8 +696,10 @@ main :: () {
} }
case .None; { case .None; {
if contains(arg, ".") { if contains(arg, ".") {
path_split := split(arg, "\\"); sc := get_scratch();
split_path := split(path_split[path_split.count - 1], "."); defer scratch_end(sc);
path_split := split(arg, "\\",, sc.allocator);
split_path := split(path_split[path_split.count - 1], ".",, sc.allocator);
extension := split_path[1]; extension := split_path[1];
if extension == SHADER_EXTENSION { if extension == SHADER_EXTENSION {
@@ -648,12 +710,14 @@ main :: () {
if !current_suite { if !current_suite {
suite : Test_Suite; suite : Test_Suite;
suite.results.allocator = local_temp;
suite.test_cases.allocator = local_temp;
array_add(*suites, suite); array_add(*suites, suite);
current_suite = *suites[0]; current_suite = *suites[0];
} }
arg_parse_state = .Run_Test; arg_parse_state = .Run_Test;
path := copy_string(arg); path := copy_string(arg,, local_temp);
test_case := make_test_case(path, 0); test_case := make_test_case(path, 0, local_temp);
array_add(*current_suite.test_cases, test_case); array_add(*current_suite.test_cases, test_case);
} else if extension == SUITE_EXTENSION { } else if extension == SUITE_EXTENSION {
if arg_parse_state == .Run_Test { if arg_parse_state == .Run_Test {
@@ -664,7 +728,9 @@ main :: () {
path := copy_string(arg); path := copy_string(arg);
suite : Test_Suite; suite : Test_Suite;
read_suite(path, *suite); suite.results.allocator = local_temp;
suite.test_cases.allocator = local_temp;
read_suite(path, *suite, local_temp);
array_add(*suites, suite); array_add(*suites, suite);
current_suite = *suites[0]; current_suite = *suites[0];
} else { } else {
@@ -678,4 +744,6 @@ main :: () {
for suite : suites { for suite : suites {
run_test_suite(*suite, output_type); run_test_suite(*suite, output_type);
} }
clear(local_temp);
} }

View File

@@ -5,17 +5,11 @@ Lexer :: struct {
current_line : int; current_line : int;
current_column : int; current_column : int;
result : Lexing_Result; ctx : *Compiler_Context;
path : string; path : string;
} }
Lexing_Result :: struct {
tokens : [..]Token;
had_error : bool;
messages : [..]Compiler_Message;
}
Token_Kind :: enum { Token_Kind :: enum {
TOKEN_FLOATLITERAL; TOKEN_FLOATLITERAL;
TOKEN_INTLITERAL; TOKEN_INTLITERAL;
@@ -54,6 +48,7 @@ Token_Kind :: enum {
TOKEN_SEMICOLON; TOKEN_SEMICOLON;
TOKEN_COMMA; TOKEN_COMMA;
TOKEN_DOT; TOKEN_DOT;
TOKEN_DOTDOT;
TOKEN_IDENTIFIER; TOKEN_IDENTIFIER;
@@ -100,6 +95,7 @@ Token_Kind :: enum {
TOKEN_RETURN; TOKEN_RETURN;
TOKEN_REGISTER; TOKEN_REGISTER;
TOKEN_STRING;
TOKEN_STRUCT; TOKEN_STRUCT;
TOKEN_SWITCH; TOKEN_SWITCH;
@@ -137,6 +133,8 @@ Token :: struct {
index : int; index : int;
error : string; error : string;
builtin : bool; // @Incomplete: This is kind of a bad idea, but let's just do it for now...
} }
Source_Range :: struct { Source_Range :: struct {
@@ -264,12 +262,32 @@ identifier_kind :: (using lexer : *Lexer) -> Token_Kind {
error_token :: (lexer : *Lexer, message : string) -> *Token { error_token :: (lexer : *Lexer, message : string) -> *Token {
token : *Token = new_token(lexer, .TOKEN_ERROR); token : *Token = new_token(lexer, .TOKEN_ERROR);
lexer.result.had_error = true; lexer.ctx.had_error = true;
token.error = copy_string(message); token.error = copy_string(message);
return token; return token;
} }
// unable_to_open_file :: (state : *Parse_State, path : string, token : Token) {
// builder : String_Builder;
// init_string_builder(*builder,, temp);
// print_to_builder(*builder, "Unable to open file '%' for reading\n\n", path);
// location := generate_source_location_from_token(state, token);
// indent(*builder, 1);
// cyan(*builder);
// print_to_builder(*builder, "%\n", print_from_source_location(location));
// indent(*builder, 1);
// loc := location.begin;
// print_token_pointer(*builder, loc);
// final_message := builder_to_string(*builder);
// record_error(state, token, final_message, false);
// }
record_error :: (lexer : *Lexer, message : string) { record_error :: (lexer : *Lexer, message : string) {
error : Compiler_Message; error : Compiler_Message;
error.message_kind = .Error; error.message_kind = .Error;
@@ -291,8 +309,8 @@ record_error :: (lexer : *Lexer, message : string) {
array_add(*error.source_locations, source_location); array_add(*error.source_locations, source_location);
lexer.result.had_error = true; lexer.ctx.had_error = true;
array_add(*lexer.result.messages, error); array_add(*lexer.ctx.messages, error);
} }
make_int :: (lexer : *Lexer) -> *Token { make_int :: (lexer : *Lexer) -> *Token {
@@ -322,10 +340,6 @@ make_float :: (lexer : *Lexer) -> *Token {
return token; return token;
} }
make_string :: () {
}
new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token { new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
length := lexer.cursor - lexer.start; length := lexer.cursor - lexer.start;
token : Token; token : Token;
@@ -342,13 +356,49 @@ new_token :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
} }
lexer.current_column += length; lexer.current_column += length;
array_add(*lexer.result.tokens, token); array_add(*lexer.ctx.tokens, token);
return *lexer.result.tokens[lexer.result.tokens.count - 1]; return *lexer.ctx.tokens[lexer.ctx.tokens.count - 1];
} }
make_directive :: (lexer : *Lexer) -> *Token { make_directive :: (lexer : *Lexer) -> *Token {
lexer.start += 1; lexer.start += 1;
return make_identifier(lexer, .TOKEN_DIRECTIVE); ident := make_identifier(lexer, .TOKEN_DIRECTIVE);
if ident.ident_value == "load" {
path_tok := scan_next_token(lexer);
path := path_tok.string_value;
ctx : Compiler_Context;
ctx.environment = lexer.ctx.environment;
ctx.file = make_file(*ctx, path);
if ctx.file.source.count == 0 {
// unable_to_open_file(lexer, path, path_tok);
record_error(lexer, tprint("Unable to open file '%' for reading\n", path));
return error_token(lexer, tprint("Unable to open file '%' for reading\n", path));
}
lex(*ctx);
ctx.tokens.count -= 1; // @Note: remote TOKEN_EOF
lexer.ctx.tokens.count -= 2;
array_resize(*lexer.ctx.tokens, lexer.ctx.tokens.count + ctx.tokens.count);
for tok : ctx.tokens {
lexer.ctx.tokens[it_index] = tok;
}
return scan_next_token(lexer);;
}
return ident;
}
make_string :: (lexer : *Lexer) -> *Token {
token : *Token = new_token(lexer, .TOKEN_STRING);
name : string = .{ count = token.length - 2,
data = *lexer.input.data[lexer.start + 1] };
token.string_value = name;
return token;
} }
make_identifier :: (lexer : *Lexer, kind : Token_Kind) -> *Token { make_identifier :: (lexer : *Lexer, kind : Token_Kind) -> *Token {
@@ -367,6 +417,7 @@ make_token :: (lexer : *Lexer, token_kind : Token_Kind) -> *Token {
skip_whitespace :: (lexer : *Lexer) { skip_whitespace :: (lexer : *Lexer) {
while true { while true {
if is_at_end(lexer) return;
c := peek_char(lexer); c := peek_char(lexer);
if c == { if c == {
@@ -421,6 +472,17 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
if is_digit(c) return number(lexer); if is_digit(c) return number(lexer);
if c == { if c == {
case #char "\""; {
c = advance(lexer);
// lexer.start = lexer.cursor;
while c != #char "\"" {
c = advance(lexer);
}
// lexer.cursor -= 1;
tok := make_string(lexer);
// advance(lexer);
return tok;
}
case #char "+"; { case #char "+"; {
if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_PLUSEQUALS); if match_character(lexer, #char "=") return make_token(lexer, .TOKEN_PLUSEQUALS);
return make_token(lexer, .TOKEN_PLUS); return make_token(lexer, .TOKEN_PLUS);
@@ -490,7 +552,10 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
} }
case #char ";"; return make_token(lexer, .TOKEN_SEMICOLON); case #char ";"; return make_token(lexer, .TOKEN_SEMICOLON);
case #char ","; return make_token(lexer, .TOKEN_COMMA); case #char ","; return make_token(lexer, .TOKEN_COMMA);
case #char "."; return make_token(lexer, .TOKEN_DOT); case #char "."; {
if match_character(lexer, #char ".") return make_token(lexer, .TOKEN_DOTDOT);
return make_token(lexer, .TOKEN_DOT);
}
} }
s : string = .{ count = 1, data = *c }; s : string = .{ count = 1, data = *c };
@@ -499,45 +564,35 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
// return error_token(lexer, tprint("Invalid token: %", s)); // return error_token(lexer, tprint("Invalid token: %", s));
} }
lex :: (ctx : *Compiler_Context, allocator := temp) {
if ctx.had_error {
lex :: (result : *Compile_Result) {
if result.had_error {
return; return;
} }
for *file : result.files { new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
lexer : Lexer; lexer : Lexer;
init_lexer_from_string(*lexer, file.file.source); lexer.ctx = ctx;
lexer.path = file.file.path; array_reserve(*lexer.ctx.tokens, 1024);
init_lexer_from_string(*lexer, ctx.file.source);
lexer.path = ctx.file.path;
token : *Token = scan_next_token(*lexer); token : *Token = scan_next_token(*lexer);
while token && token.kind != .TOKEN_EOF { while token && token.kind != .TOKEN_EOF {
token = scan_next_token(*lexer); token = scan_next_token(*lexer);
} }
array_copy(*file.tokens.tokens, lexer.result.tokens);
result.had_error |= lexer.result.had_error;
// @Incomplete(nb): Temporary until we figure out a good way of passing this stuff around
copy_messages(lexer.result.messages, *result.messages);
} }
} }
lex :: (lexer : *Lexer, allocator : Allocator = context.allocator) -> Lexing_Result {
lexer.result.tokens.allocator = allocator;
token : *Token = scan_next_token(lexer);
while token && token.kind != .TOKEN_EOF {
token = scan_next_token(lexer);
}
return lexer.result;
}
init_lexer_from_string :: (lexer : *Lexer, input : string) { init_lexer_from_string :: (lexer : *Lexer, input : string) {
ok := read_input_from_string(lexer, input); ok := read_input_from_string(lexer, input);
if !ok { if !ok {
record_error(lexer, "Unable to initialize from string\n"); record_error(lexer, "Unable to initialize from string\n");
lexer.result.had_error = true; lexer.ctx.had_error = true;
} }
} }
@@ -545,7 +600,7 @@ init_lexer_from_file :: (lexer : *Lexer, file_path : string) {
ok := read_input_from_file(lexer, file_path); ok := read_input_from_file(lexer, file_path);
if !ok { if !ok {
record_error(lexer, tprint("Unable to read file: %\n", file_path)); record_error(lexer, tprint("Unable to read file: %\n", file_path));
lexer.result.had_error = true; lexer.ctx.had_error = true;
} }
} }
@@ -715,9 +770,11 @@ print_from_source_location :: (builder : *String_Builder, source_location : Sour
} }
print_from_source_location :: (source_location : Source_Range, allocator := context.allocator, indentation : int = 0) -> string { print_from_source_location :: (source_location : Source_Range, allocator := context.allocator, indentation : int = 0) -> string {
sc := get_scratch();
defer scratch_end(sc);
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, allocator); init_string_builder(*builder,, sc.allocator);
print_from_source_location(*builder, source_location); print_from_source_location(*builder, source_location,, sc.allocator);
return builder_to_string(*builder,, allocator); return builder_to_string(*builder,, allocator);
} }

View File

@@ -1,5 +1,7 @@
#import "Flat_Pool"; #import "Flat_Pool";
// #load "qpwodkqopwkd.jai";
/** /**
* TODO: * TODO:
* if parsing * if parsing
@@ -11,34 +13,14 @@
Parse_State :: struct { Parse_State :: struct {
current : *Token; current : *Token;
previous : *Token; previous : *Token;
tokens : [..]Token;
current_token_index : int; current_token_index : int;
node_allocator : Allocator; ctx : *Compiler_Context;
node_arena : Arena;
child_allocator : Allocator;
child_arena : Arena;
// had_error : bool;
path : string;
result : Parse_Result;
} }
//////////////////////////// ////////////////////////////
//@nb - Result and error handling //@nb - Result and error handling
Parse_Result :: struct {
root : *AST_Node;
nodes : [..]AST_Node;
had_error : bool;
messages : [..]Compiler_Message;
}
Parse_Error_Kind :: enum { Parse_Error_Kind :: enum {
Parse_Error_Type_Missing; Parse_Error_Type_Missing;
Parse_Error_Expected_Expression; Parse_Error_Expected_Expression;
@@ -129,16 +111,6 @@ parse_rules :: #run -> [(cast(int)Token_Kind.TOKEN_ERROR) + 1]Parse_Rule {
return rules; return rules;
} }
init_parse_state :: (parse_state : *Parse_State, tokens : [..]Token, path : string) {
parse_state.tokens = tokens;
parse_state.path = path;
parse_state.node_allocator = make_arena(*parse_state.node_arena);
parse_state.child_allocator = make_arena(*parse_state.child_arena);
parse_state.result.nodes.allocator = parse_state.node_allocator;
array_reserve(*parse_state.result.nodes, 4096);
parse_state.current_token_index = 0;
}
//////////////////////////// ////////////////////////////
//@nb - Error handling functions //@nb - Error handling functions
@@ -147,7 +119,7 @@ record_error :: (parse_state : *Parse_State, token : Token, message : string, re
error : Compiler_Message; error : Compiler_Message;
error.message_kind = .Error; error.message_kind = .Error;
error.message = message; error.message = message;
error.path = parse_state.path; error.path = parse_state.ctx.file.path;
source_location : Source_Range; source_location : Source_Range;
source_location.begin = token; source_location.begin = token;
@@ -155,14 +127,17 @@ record_error :: (parse_state : *Parse_State, token : Token, message : string, re
source_location.begin.source = source_location.begin.source - source_location.begin.column; source_location.begin.source = source_location.begin.source - source_location.begin.column;
source_location.main_token = token; source_location.main_token = token;
snap := snapshot_state(parse_state);
advance_to_sync_point(parse_state); advance_to_sync_point(parse_state);
error.report_source_location = report_source_location; error.report_source_location = report_source_location;
source_location.end = parse_state.current; source_location.end = parse_state.current;
array_add(*error.source_locations, source_location); array_add(*error.source_locations, source_location);
parse_state.result.had_error = true; parse_state.ctx.had_error = true;
array_add(*parse_state.result.messages, error); array_add(*parse_state.ctx.messages, error);
rewind_to_snapshot(parse_state, snap);
} }
generate_source_location_from_token :: (state : *Parse_State, token : Token) -> Source_Range { generate_source_location_from_token :: (state : *Parse_State, token : Token) -> Source_Range {
@@ -190,8 +165,10 @@ unexpected_token :: (state : *Parse_State, token : Token, message : string) {
/* /*
*/ */
sc := get_scratch();
defer scratch_end(sc);
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, temp); init_string_builder(*builder,, sc.allocator);
print_to_builder(*builder, "%\n\n", message); print_to_builder(*builder, "%\n\n", message);
@@ -214,7 +191,7 @@ unexpected_token :: (state : *Parse_State, token : Token, message : string) {
indent(*builder, 1); indent(*builder, 1);
print_token_pointer(*builder, token); print_token_pointer(*builder, token);
final_message := builder_to_string(*builder); final_message := builder_to_string(*builder,, context.allocator);
record_error(state, token, final_message, false); record_error(state, token, final_message, false);
} }
@@ -262,6 +239,26 @@ else_without_if :: (state : *Parse_State) {
record_error(state, token, final_message, false); record_error(state, token, final_message, false);
} }
unable_to_parse_statement :: (state : *Parse_State, token : Token, message : string = "") {
builder : String_Builder;
init_string_builder(*builder,, temp);
print_to_builder(*builder, "Unable to parse statement here. %\n", message);
location : Source_Range = generate_source_location_from_token(state, token);
indent(*builder, 1);
cyan(*builder);
print_to_builder(*builder, "%\n", print_from_source_location(location));
indent(*builder, 1);
print_token_pointer(*builder, token);
final_message := builder_to_string(*builder);
record_error(state, token, final_message, false);
}
expected_expression :: (state : *Parse_State, token : Token, message : string) { expected_expression :: (state : *Parse_State, token : Token, message : string) {
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, temp); init_string_builder(*builder,, temp);
@@ -329,6 +326,26 @@ empty_block :: (state : *Parse_State, token : Token, message : string) {
record_error(state, token, final_message, false); record_error(state, token, final_message, false);
} }
unable_to_open_file :: (state : *Parse_State, path : string, token : Token) {
builder : String_Builder;
init_string_builder(*builder,, temp);
print_to_builder(*builder, "Unable to open file '%' for reading\n\n", path);
location := generate_source_location_from_token(state, token);
indent(*builder, 1);
cyan(*builder);
print_to_builder(*builder, "%\n", print_from_source_location(location));
indent(*builder, 1);
loc := location.begin;
print_token_pointer(*builder, loc);
final_message := builder_to_string(*builder);
record_error(state, token, final_message, false);
}
error_node :: (parse_state : *Parse_State, message : string) -> *AST_Node { error_node :: (parse_state : *Parse_State, message : string) -> *AST_Node {
node := make_node(parse_state, .Error); node := make_node(parse_state, .Error);
node.name = copy_string(message); node.name = copy_string(message);
@@ -342,7 +359,7 @@ advance_to_sync_point :: (parse_state : *Parse_State) {
while true { while true {
if parse_state.current.kind == .TOKEN_SEMICOLON || parse_state.current.kind == .TOKEN_RIGHTBRACE || if parse_state.current.kind == .TOKEN_SEMICOLON || parse_state.current.kind == .TOKEN_RIGHTBRACE ||
parse_state.current.kind == .TOKEN_LEFTBRACE || parse_state.current.kind == .TOKEN_EOF { parse_state.current.kind == .TOKEN_LEFTBRACE || parse_state.current.kind == .TOKEN_EOF {
break; break;
} }
advance(parse_state); advance(parse_state);
} }
@@ -353,14 +370,217 @@ advance_to_sync_point :: (parse_state : *Parse_State) {
//////////////////////////// ////////////////////////////
//@nb - Base parsing functions //@nb - Base parsing functions
make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node { make_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
node : AST_Node; node : AST_Node;
node.kind = kind; node.kind = kind;
node.children.allocator = parse_state.child_allocator; array_add(nodes, node);
array_add(*parse_state.result.nodes, node);
return *parse_state.result.nodes[parse_state.result.nodes.count - 1]; return *(nodes.*[nodes.count - 1]);
}
make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node {
return make_node(*parse_state.ctx.nodes, kind);
}
// new_builtin_node :: (nodes : *[..]AST_Node, kind : AST_Kind) -> *AST_Node {
// node := make_node(parse_state, kind);
// node.builtin = true;
// return node;
// }
make_builtin_token :: (tokens : *[..]Token, builder : *String_Builder, kind : Token_Kind, text : string, col : *int, line : *int) -> *Token {
tok : Token;
tok.kind = kind;
start := 0;
buffer := get_current_buffer(builder);
if buffer {
start := buffer.count;
}
tok.column = col.*;
print_to_builder(builder, "%", text);
buffer = get_current_buffer(builder);
end := buffer.count;
for c : text {
if c == #char "\n" {
line.* ++ 1;
col.* = 0;
} else {
col.* += 1;
}
}
tok.index = buffer.count - text.count;
tok.length = text.count;
tok.builtin = true;
array_add(tokens, tok);
return *(tokens.*)[tokens.count - 1];
}
new_builtin_struct_node :: (ctx : *Compiler_Context, name : string, members : []Arg) -> *AST_Node {
sc := get_scratch(context.allocator);
defer scratch_end(sc);
builder : String_Builder;
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
node := make_node(*ctx.nodes, .Struct);
source_location : Source_Range;
col := 0;
line := 0;
tok_index := ctx.tokens.count;
ident_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
ident_token.ident_value = name;
source_location.begin = ident_token;
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_STRUCT, "struct", *col, *line);
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_LEFTBRACE, "{", *col, *line);
append(*builder, "\n");
line += 1;
col = 0;
field_list := make_node(*ctx.nodes, .FieldList);
add_child(node, field_list);
for member : members {
field := make_node(*ctx.nodes, .Field);
field_source_loc : Source_Range;
indent(*builder, 1);
field_ident := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line);
field_source_loc.begin = field_ident;
field.token = field_ident;
field.name = member.name;
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_COLON, ":", *col, *line);
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
semicolon_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_SEMICOLON, ";", *col, *line);
append(*builder, "\n");
col = 0;
line += 1;
field_source_loc.end = semicolon_tok;
field.source_location = field_source_loc;
add_child(field_list, field);
}
brace_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_RIGHTBRACE, "}", *col, *line);
append(*builder, "\n");
source_location.end = brace_token;
source := builder_to_string(*builder,, context.allocator);
source_location.begin.source = *source.data[source_location.begin.column];
source_location.end.source = *source.data[source_location.end.column];
for i : tok_index..ctx.tokens.count - 1 {
tok := ctx.tokens[i];
tok.source = *source.data[tok.column];
}
for field : field_list.children {
field.source_location.begin.source = *source.data[field.source_location.begin.column];
field.source_location.end.source = *source.data[field.source_location.end.column];
// field.source_location.main_token.source = *source.data[tok.column];
}
node.source_location = source_location;
return node;
}
new_builtin_function_node :: (ctx : *Compiler_Context, name : string, members : []Arg, return_var : Arg) -> *AST_Node {
sc := get_scratch(context.allocator);
defer scratch_end(sc);
builder : String_Builder;
builder.allocator = sc.allocator; // I want to find a good way to use scratch here...
node := make_node(*ctx.nodes, .Function);
source_location : Source_Range;
col := 0;
line := 0;
tok_index := ctx.tokens.count;
ident_token := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
source_location.begin = ident_token;
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
append(*builder, " ");
make_builtin_token(*ctx.tokens, *builder, .TOKEN_LEFTPAREN, "(", *col, *line);
field_list := make_node(*ctx.nodes, .FieldList);
add_child(node, field_list);
for member : members {
field := make_node(*ctx.nodes, .Field);
field_source_loc : Source_Range;
// field_ident := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line);
type_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
field_source_loc.begin = type_tok;
field.token = type_tok;
if it_index < members.count - 1 {
make_builtin_token(*ctx.tokens, *builder, .TOKEN_COMMA, ",", *col, *line);
append(*builder, " ");
}
field_source_loc.end = type_tok;
field.source_location = field_source_loc;
add_child(field_list, field);
}
make_builtin_token(*ctx.tokens, *builder, .TOKEN_RIGHTPAREN, ")", *col, *line);
semicolon_tok := make_builtin_token(*ctx.tokens, *builder, .TOKEN_SEMICOLON, ";", *col, *line);
source_location.end = semicolon_tok;
source := builder_to_string(*builder,, context.allocator);
source_location.begin.source = *source.data[source_location.begin.column];
source_location.end.source = *source.data[source_location.end.column];
for i : tok_index..ctx.tokens.count - 1 {
tok := ctx.tokens[i];
tok.source = *source.data[tok.column];
}
for field : field_list.children {
field.source_location.begin.source = *source.data[field.source_location.begin.column];
field.source_location.end.source = *source.data[field.source_location.end.column];
// field.source_location.main_token.source = *source.data[tok.column];
}
node.source_location = source_location;
return node;
}
get_field_list :: (struct_or_func : *AST_Node) -> *AST_Node {
assert(struct_or_func.kind == .Function || struct_or_func.kind == .Struct || struct_or_func.kind == .Properties);
return struct_or_func.children[0];
} }
add_child :: (node : *AST_Node, child : *AST_Node) { add_child :: (node : *AST_Node, child : *AST_Node) {
@@ -393,10 +613,10 @@ advance :: (parse_state : *Parse_State) {
parse_state.previous = parse_state.current; parse_state.previous = parse_state.current;
while true { while true {
if parse_state.current_token_index >= parse_state.tokens.count { if parse_state.current_token_index >= parse_state.ctx.tokens.count {
break; break;
} }
parse_state.current = *parse_state.tokens[parse_state.current_token_index]; parse_state.current = *parse_state.ctx.tokens[parse_state.current_token_index];
parse_state.current_token_index += 1; parse_state.current_token_index += 1;
if parse_state.current.kind != .TOKEN_ERROR break; if parse_state.current.kind != .TOKEN_ERROR break;
@@ -429,20 +649,24 @@ check_any :: (parse_state : *Parse_State, kinds : ..Token_Kind) -> bool {
//nb - Checks if the next token is of a certain kind //nb - Checks if the next token is of a certain kind
check_next :: (parse_state : *Parse_State, kind : Token_Kind) -> bool { check_next :: (parse_state : *Parse_State, kind : Token_Kind) -> bool {
return parse_state.tokens[parse_state.current_token_index].kind == kind; return parse_state.ctx.tokens[parse_state.current_token_index].kind == kind;
} }
//nb - Consume a token if //nb - Consume a token if
consume :: (parse_state : *Parse_State, kind : Token_Kind, message : string) { consume :: (parse_state : *Parse_State, kind : Token_Kind, message : string) {
if parse_state.current.kind == kind { if parse_state.current.kind == kind {
advance(parse_state); advance(parse_state);
return; return;
} }
token := parse_state.previous; token := parse_state.previous;
advance(parse_state); advance_to_sync_point(parse_state);
unexpected_token(parse_state, token, message); unexpected_token(parse_state, token, message);
consume(parse_state, kind, message);
if parse_state.current.kind == .TOKEN_EOF {
return;
}
} }
//////////////////////////// ////////////////////////////
@@ -451,16 +675,21 @@ get_rule :: (kind : Token_Kind) -> *Parse_Rule {
return *parse_rules[kind]; return *parse_rules[kind];
} }
precedence :: (parse_state : *Parse_State, precedence : Precedence) -> *AST_Node { precedence :: (parse_state : *Parse_State, precedence : Precedence, message : string = "") -> *AST_Node {
prev := parse_state.previous;
advance(parse_state); advance(parse_state);
prefix_rule := get_rule(parse_state.previous.kind).prefix; prefix_rule := get_rule(parse_state.previous.kind).prefix;
if prefix_rule == null { if prefix_rule == null {
tok_s : string; tok_s : string;
tok_s.data = parse_state.previous.source; tok_s.data = prev.source;
tok_s.count = parse_state.previous.length; tok_s.count = prev.length;
expected_expression(parse_state, parse_state.previous, tprint("Expected expression after '%'.", tok_s)); if message {
// @Incomplete: Add error node here? expected_expression(parse_state, prev, tprint("Expected expression after '%'. %", tok_s, message));
} else {
expected_expression(parse_state, prev, tprint("Expected expression after '%'.", tok_s));
}
return error_node(parse_state, "Expected expression."); return error_node(parse_state, "Expected expression.");
} }
@@ -473,7 +702,6 @@ precedence :: (parse_state : *Parse_State, precedence : Precedence) -> *AST_Node
tok_s.data = parse_state.previous.source; tok_s.data = parse_state.previous.source;
tok_s.count = parse_state.previous.length; tok_s.count = parse_state.previous.length;
expected_expression(parse_state, parse_state.current, tprint("Reached end of file. Expected expression after '%'.", tok_s)); expected_expression(parse_state, parse_state.current, tprint("Reached end of file. Expected expression after '%'.", tok_s));
// expected_expression(parse_state, parse_state.current, "Reached end of file. Expected expression.");
// @Incomplete: Add error node here? // @Incomplete: Add error node here?
return null; return null;
} }
@@ -540,8 +768,8 @@ binary :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
} }
array_access :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node { array_access :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
identifier := parse_state.tokens[parse_state.current_token_index - 3]; identifier := parse_state.ctx.tokens[parse_state.current_token_index - 3];
left_bracket := parse_state.tokens[parse_state.current_token_index - 2]; left_bracket := parse_state.ctx.tokens[parse_state.current_token_index - 2];
array_access := make_node(parse_state, .Unary); array_access := make_node(parse_state, .Unary);
array_access.token = left_bracket; array_access.token = left_bracket;
@@ -606,6 +834,66 @@ directive :: (state : *Parse_State) -> *AST_Node {
func := function_declaration(state, identifier_token, .None, false, false); func := function_declaration(state, identifier_token, .None, false, false);
func.foreign_declaration = true; func.foreign_declaration = true;
return func; return func;
} else if state.current.ident_value == "if" {
if_directive := make_node(state, .If_Directive);
source_location : Source_Range;
// source_location.begin = state.previous;
advance(state);
cond := expression(state);
add_child(if_directive, cond);
if_body := block(state);
add_child(if_directive, if_body);
if_directive.source_location = source_location;
return if_directive;
} else if state.current.ident_value == "load" {
advance(state);
if check(state, .TOKEN_STRING) {
// path_tok := state.current;
// path := path_tok.string_value;
// advance(state);
// result : Compiler_Context;
// ctx.allocator = state.ctx.allocator;
// ctx.environment = state.ctx.environment;
// ctx.file = make_file(*result, path);
// if ctx.file.source.count == 0 {
// unable_to_open_file(state, path, path_tok);
// advance_to_sync_point(state);
// advance(state);
// return null;
// }
// consume(state, .TOKEN_SEMICOLON, "Expected ';' after #load directive");
// lex(*result);
// count := state.ctx.tokens..count;
// current_idx := state.current_token_index;
// result_count := ctx.tokens..count;
// // state.ctx.tokens..count -= 1;
// array_resize(*state.ctx.tokens., count + result_count - 1);
// memcpy(*state.ctx.tokens[current_idx + result_count - 1], *state.ctx.tokens[current_idx], size_of(Token) * (count - current_idx));
// for *tok : ctx.tokens. {
// if tok.kind == .TOKEN_EOF {
// break;
// }
// tok.builtin = true;
// state.ctx.tokens[it_index] = tok.*;
// }
}
} }
return null; return null;
@@ -693,8 +981,8 @@ floating :: (parse_state : *Parse_State, left : *AST_Node) -> *AST_Node {
return node; return node;
} }
expression :: (parse_state : *Parse_State) -> *AST_Node { expression :: (parse_state : *Parse_State, message : string = "") -> *AST_Node {
expression := precedence(parse_state, .PREC_ASSIGNMENT); expression := precedence(parse_state, .PREC_ASSIGNMENT, message);
return expression; return expression;
} }
@@ -749,7 +1037,7 @@ field_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
node.array_field = true; node.array_field = true;
} else { } else {
if !check(parse_state, .TOKEN_ASSIGN) { if !check(parse_state, .TOKEN_ASSIGN) {
internal_error_message(*parse_state.result.messages, "Unimplemented error message.", parse_state.path); internal_error_message(*parse_state.ctx.messages, "Unimplemented error message.", parse_state.ctx.file.path);
return node; return node;
} }
// missing_type_specifier(parse_state, identifier_token, "Expected type specifier after field name."); // missing_type_specifier(parse_state, identifier_token, "Expected type specifier after field name.");
@@ -771,7 +1059,6 @@ field_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
advance(parse_state); advance(parse_state);
} }
} }
} else if match(parse_state, .TOKEN_ASSIGN) { } else if match(parse_state, .TOKEN_ASSIGN) {
add_child(node, expression(parse_state)); add_child(node, expression(parse_state));
} }
@@ -794,8 +1081,8 @@ argument_list :: (parse_state : *Parse_State) -> *AST_Node {
source_location.main_token = parse_state.current; source_location.main_token = parse_state.current;
error_before := parse_state.result.had_error; error_before := parse_state.ctx.had_error;
parse_state.result.had_error = false; parse_state.ctx.had_error = false;
while !check(parse_state, .TOKEN_RIGHTPAREN) { while !check(parse_state, .TOKEN_RIGHTPAREN) {
arg := expression(parse_state); arg := expression(parse_state);
@@ -808,12 +1095,12 @@ argument_list :: (parse_state : *Parse_State) -> *AST_Node {
if check(parse_state, .TOKEN_RIGHTPAREN) break; if check(parse_state, .TOKEN_RIGHTPAREN) break;
consume(parse_state, .TOKEN_COMMA, "Expect ',' after function argument."); consume(parse_state, .TOKEN_COMMA, "Expect ',' after function argument.");
if parse_state.result.had_error { if parse_state.ctx.had_error {
break; break;
} }
} }
parse_state.result.had_error = error_before || parse_state.result.had_error; parse_state.ctx.had_error = error_before || parse_state.ctx.had_error;
consume(parse_state, .TOKEN_RIGHTPAREN, "Expect ')' after function call."); consume(parse_state, .TOKEN_RIGHTPAREN, "Expect ')' after function call.");
@@ -873,9 +1160,10 @@ statement :: (parse_state : *Parse_State) -> *AST_Node {
source_location : Source_Range; source_location : Source_Range;
source_location.begin = parse_state.previous; source_location.begin = parse_state.previous;
if_cond := expression(parse_state); if_cond := expression(parse_state, "Expected if condition.");
add_child(node, if_cond); add_child(node, if_cond);
source_location.end = parse_state.previous; source_location.end = parse_state.previous;
advance_to_sync_point(parse_state);
if_body := block(parse_state); if_body := block(parse_state);
add_child(node, if_body); add_child(node, if_body);
@@ -904,7 +1192,60 @@ statement :: (parse_state : *Parse_State) -> *AST_Node {
} }
return error_node(parse_state, "'else' without 'if'."); return error_node(parse_state, "'else' without 'if'.");
} }
} else if match(parse_state, .TOKEN_FOR) {
if check(parse_state, .TOKEN_IDENTIFIER) {
node := make_node(parse_state, .For);
source_location : Source_Range;
source_location.begin = parse_state.previous;
loop_iterator := parse_state.current;
node.token = loop_iterator;
advance(parse_state);
consume(parse_state, .TOKEN_COLON, "Expect ':' after for loop iterator.");
snap := snapshot_state(parse_state);
begin_iter := expression(parse_state, "Expected beginning of iterator.");
if begin_iter.kind == .Error {
unable_to_parse_statement(parse_state, source_location.begin);
rewind_to_snapshot(parse_state, snap);
if parse_state.current.kind == .TOKEN_LEFTBRACE {
block(parse_state);
}
return error_node(parse_state, "'for' without well-formed iterator expression.");
}
add_child(node, begin_iter);
consume(parse_state, .TOKEN_DOTDOT, "Expect '..' after for loop iter left hand side.");
snap = snapshot_state(parse_state);
end_iter := expression(parse_state, "Expected end of iterator.");
if end_iter.kind == .Error {
unable_to_parse_statement(parse_state, source_location.begin);
rewind_to_snapshot(parse_state, snap);
if parse_state.current.kind == .TOKEN_LEFTBRACE {
block(parse_state);
}
return error_node(parse_state, "'for' without well-formed iterator expression.");
}
add_child(node, end_iter);
if check(parse_state, .TOKEN_LEFTBRACE) {
for_body := block(parse_state);
add_child(node, for_body);
} else {
unable_to_parse_statement(parse_state, source_location.begin, "'for' currently expects a brace-enclosed block as a body.");
return error_node(parse_state, "'for' currently expects a brace-enclosed block as a body.");
}
node.source_location = source_location;
return node;
}
} else { } else {
return expression_statement(parse_state); return expression_statement(parse_state);
} }
@@ -1108,6 +1449,18 @@ constant_buffer :: (parse_state : *Parse_State, identifier_token : *Token = null
node : *AST_Node; node : *AST_Node;
source_location : Source_Range; source_location : Source_Range;
source_location.begin = parse_state.current; source_location.begin = parse_state.current;
if check(parse_state, .TOKEN_AT) {
while check(parse_state, .TOKEN_AT) {
advance(parse_state);
// @Incomplete(niels): this is a mapping
if check(parse_state, .TOKEN_IDENTIFIER) {
array_add(*node.hint_tokens, parse_state.current);
advance(parse_state);
}
}
}
consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'constant_buffer' keyword"); consume(parse_state, .TOKEN_LEFTBRACE, "Expect '{' after 'constant_buffer' keyword");
buffer := field_list(parse_state, .Semicolon); buffer := field_list(parse_state, .Semicolon);
@@ -1162,6 +1515,7 @@ const_declaration :: (parse_state : *Parse_State, identifier_token : *Token) ->
} }
declaration :: (parse_state : *Parse_State) -> *AST_Node { declaration :: (parse_state : *Parse_State) -> *AST_Node {
skip_statement := false;
decl_node : *AST_Node; decl_node : *AST_Node;
if match(parse_state, .TOKEN_PROPERTIES) { if match(parse_state, .TOKEN_PROPERTIES) {
decl_node = property_block(parse_state); decl_node = property_block(parse_state);
@@ -1189,6 +1543,7 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
decl_node = call(parse_state, null); decl_node = call(parse_state, null);
} else if check(parse_state, .TOKEN_DIRECTIVE) { } else if check(parse_state, .TOKEN_DIRECTIVE) {
decl_node = directive(parse_state); decl_node = directive(parse_state);
skip_statement = true;
} else if check(parse_state, .TOKEN_IDENTIFIER) { } else if check(parse_state, .TOKEN_IDENTIFIER) {
identifier := parse_state.current; identifier := parse_state.current;
@@ -1211,7 +1566,7 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
decl_node = error; decl_node = error;
} }
if !decl_node { if !decl_node && !skip_statement {
decl_node = statement(parse_state); decl_node = statement(parse_state);
} }
@@ -1222,20 +1577,28 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
return decl_node; return decl_node;
} }
parse :: (result : *Compile_Result) { parse :: (ctx : *Compiler_Context, allocator := temp) {
if result.had_error { if ctx.had_error {
return; return;
} }
for *file : result.files { new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
parse_state : Parse_State; parse_state : Parse_State;
init_parse_state(*parse_state, file.tokens.tokens, file.file.path); array_reserve(*ctx.nodes, 4096);
parse_state.current_token_index = 0;
parse_state.ctx = ctx;
advance(*parse_state); advance(*parse_state);
if !match(*parse_state, .TOKEN_EOF) { if !match(*parse_state, .TOKEN_EOF) {
parse_state.result.root = make_node(*parse_state, .Program); parse_state.ctx.root = make_node(*parse_state, .Program);
array_reserve(*parse_state.result.root.children, 1024); array_reserve(*parse_state.ctx.root.children, 1024);
program := parse_state.result.root; program := parse_state.ctx.root;
while !check(*parse_state, .TOKEN_EOF) { while !check(*parse_state, .TOKEN_EOF) {
decl := declaration(*parse_state); decl := declaration(*parse_state);
@@ -1244,34 +1607,7 @@ parse :: (result : *Compile_Result) {
} }
} }
} }
//@Incomplete(nb): will this straight copy just work?
// Might need to rething how we do this.
file.ast_root = parse_state.result.root;
file.ast_nodes = parse_state.result.nodes;
copy_messages(parse_state.result.messages, *result.messages);
result.had_error |= parse_state.result.had_error;
} }
} }
parse :: (parse_state : *Parse_State) -> Parse_Result {
advance(parse_state);
if !match(parse_state, .TOKEN_EOF) {
parse_state.result.root = make_node(parse_state, .Program);
array_reserve(*parse_state.result.root.children, 1024);
program := parse_state.result.root;
while !check(parse_state, .TOKEN_EOF) {
decl := declaration(parse_state);
if decl {
add_child(program, decl);
}
}
}
return parse_state.result;
}
#load "AST.jai"; #load "AST.jai";

View File

@@ -40,7 +40,7 @@ Type_Kind :: enum {
Array; Array;
} }
Type_Variable_Kind :: enum { Source_Kind :: enum {
Expression; Expression;
Declaration; // struct, properties, function, etc. Declaration; // struct, properties, function, etc.
} }
@@ -55,9 +55,12 @@ Typenames :: string.[
"bool" , "bool" ,
]; ];
//@Incomplete(niels): We can vastly simplify type handling
// There's really no reason to have these type variables anymore now that we don't do union find
// We can just have the built-in types and then we can declare structs, functions, buffers etc. as one time things.
Type_Variable :: struct { Type_Variable :: struct {
type : Type_Kind; type : Type_Kind;
kind : Type_Variable_Kind; source_kind : Source_Kind;
builtin : bool; builtin : bool;
name : string; name : string;
@@ -87,8 +90,6 @@ Type_Variable_Handle :: #type, distinct u32;
Scope_Stack :: struct { Scope_Stack :: struct {
allocator : Allocator; allocator : Allocator;
arena : Arena;
stack : [..]Scope; stack : [..]Scope;
} }
@@ -123,6 +124,8 @@ Scope :: struct {
builtin : bool; builtin : bool;
kind : Scope_Kind; kind : Scope_Kind;
allocator : Allocator;
} }
Scope_Handle :: #type, distinct u32; Scope_Handle :: #type, distinct u32;
@@ -140,15 +143,12 @@ Semantic_Checker :: struct {
current_scope : Scope_Handle; current_scope : Scope_Handle;
result_file : *Compiled_File; ctx : *Compiler_Context;
current_buffer_index : u32 = 0; current_buffer_index : u32 = 0;
current_sampler_index : u32 = 0; current_sampler_index : u32 = 0;
current_texture_index : u32 = 0; current_texture_index : u32 = 0;
messages : [..]Compiler_Message;
message_arena : Arena;
message_allocator : Allocator;
had_error : bool; had_error : bool;
} }
@@ -451,7 +451,7 @@ Attempting to access a field on a primitive type '%'.
init_string_builder(*builder,, temp); init_string_builder(*builder,, temp);
variable := from_handle(checker, handle); variable := from_handle(checker, handle);
print_to_builder(*builder, "Attempting to access a field on a primitive type '%'.\n", proper_type_to_string(checker.result_file.type_variables, variable)); print_to_builder(*builder, "Attempting to access a field on a primitive type '%'.\n", proper_type_to_string(checker.ctx.type_variables, variable));
indent(*builder, 1); indent(*builder, 1);
cyan(*builder); cyan(*builder);
@@ -512,7 +512,7 @@ if_condition_has_to_be_boolean_type :: (checker : *Semantic_Checker, usage_site
usage_child := usage_site.children[0]; usage_child := usage_site.children[0];
usage_loc := usage_child.source_location; usage_loc := usage_child.source_location;
print_to_builder(*builder, "% has type %\n", print_from_source_location(*usage_loc), proper_type_to_string(checker.result_file.type_variables, var)); print_to_builder(*builder, "% has type %\n", print_from_source_location(*usage_loc), proper_type_to_string(checker.ctx.type_variables, var));
message := builder_to_string(*builder,, temp); message := builder_to_string(*builder,, temp);
record_error(checker, message, usage_site.source_location, false); record_error(checker, message, usage_site.source_location, false);
@@ -554,7 +554,7 @@ type_mismatch :: (checker : *Semantic_Checker, usage_site : *AST_Node, expect_no
indent(*builder, 1); indent(*builder, 1);
print_to_builder(*builder, "expected:\n"); print_to_builder(*builder, "expected:\n");
indent(*builder, 2); indent(*builder, 2);
proper_type_to_string(*builder, checker.result_file.type_variables, expect_var); proper_type_to_string(*builder, checker.ctx.type_variables, expect_var);
append(*builder, "\n"); append(*builder, "\n");
// indent(*builder, 2); // indent(*builder, 2);
@@ -592,7 +592,7 @@ record_error :: (checker : *Semantic_Checker, error_string : string, locations :
error.message = error_string; error.message = error_string;
checker.had_error = true; checker.had_error = true;
array_add(*checker.messages, error); array_add(*checker.ctx.messages, error);
} }
is_proper :: (var : Type_Variable) -> bool { is_proper :: (var : Type_Variable) -> bool {
@@ -617,10 +617,12 @@ use_scope :: (checker : *Semantic_Checker, handle : Scope_Handle) -> Scope_Handl
push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Global) -> *Scope, Scope_Handle { push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Global) -> *Scope, Scope_Handle {
new_scope : Scope; new_scope : Scope;
array_add(*checker.result_file.scope_stack.stack, new_scope); array_add(*checker.ctx.scope_stack.stack, new_scope);
count := checker.result_file.scope_stack.stack.count; count := checker.ctx.scope_stack.stack.count;
scope := *checker.result_file.scope_stack.stack[count - 1]; scope := *checker.ctx.scope_stack.stack[count - 1];
scope.allocator = make_arena(Kilobytes(512));
scope.table.allocator = scope.allocator;
scope.parent = checker.current_scope; scope.parent = checker.current_scope;
scope.name = name; scope.name = name;
scope.kind = kind; scope.kind = kind;
@@ -628,7 +630,7 @@ push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Glo
scope.builtin = true; scope.builtin = true;
} }
scope.children.allocator = checker.result_file.scope_stack.allocator; scope.children.allocator = checker.ctx.scope_stack.stack.allocator;
if checker.current_scope { if checker.current_scope {
scope := get_current_scope(checker); scope := get_current_scope(checker);
@@ -651,12 +653,12 @@ pop_scope :: (checker : *Semantic_Checker) -> Scope_Handle {
} }
peek_scope :: (checker : *Semantic_Checker) -> *Scope, Scope_Handle { peek_scope :: (checker : *Semantic_Checker) -> *Scope, Scope_Handle {
if checker.result_file.scope_stack.stack.count == 0 { if checker.ctx.scope_stack.stack.count == 0 {
return null, 0; return null, 0;
} }
count := checker.result_file.scope_stack.stack.count; count := checker.ctx.scope_stack.stack.count;
scope := *checker.result_file.scope_stack.stack[count - 1]; scope := *checker.ctx.scope_stack.stack[count - 1];
return scope, xx count; return scope, xx count;
} }
@@ -673,7 +675,7 @@ get_scope :: (scope_stack : Scope_Stack, handle : Scope_Handle) -> *Scope {
} }
get_scope :: (checker : *Semantic_Checker, handle : Scope_Handle) -> *Scope { get_scope :: (checker : *Semantic_Checker, handle : Scope_Handle) -> *Scope {
return get_scope(*checker.result_file.scope_stack, handle); return get_scope(*checker.ctx.scope_stack, handle);
} }
add_symbol_to_scope :: (state : Checker_State, scope_stack : *Scope_Stack, scope_handle : Scope_Handle, name : string, symbol : Defined_Symbol) -> *Defined_Symbol { add_symbol_to_scope :: (state : Checker_State, scope_stack : *Scope_Stack, scope_handle : Scope_Handle, name : string, symbol : Defined_Symbol) -> *Defined_Symbol {
@@ -695,12 +697,124 @@ add_symbol_to_scope :: (state : Checker_State, scope_stack : *Scope_Stack, scope
new_type_variable :: (checker : *Semantic_Checker) -> *Type_Variable, Type_Variable_Handle { new_type_variable :: (checker : *Semantic_Checker) -> *Type_Variable, Type_Variable_Handle {
variable : Type_Variable; variable : Type_Variable;
handle := cast(Type_Variable_Handle)checker.result_file.type_variables.count + 1; handle := cast(Type_Variable_Handle)checker.ctx.type_variables.count + 1;
array_add(*checker.result_file.type_variables, variable); array_add(*checker.ctx.type_variables, variable);
return from_handle(checker, handle), handle; return from_handle(checker, handle), handle;
} }
new_builtin_type_variable :: (checker : *Semantic_Checker, type : Type_Kind, source : Source_Kind, name : string, typename : string = "") -> *Type_Variable, Type_Variable_Handle {
tv, handle := new_type_variable(checker);
tv.name = name;
tv.type = type;
tv.source_kind = source;
tv.builtin = true;
tv.typename = typename;
return tv, handle;
}
Arg :: struct {
name : string;
typename : string;
}
new_builtin_struct :: (checker : *Semantic_Checker, name : string, members : []Arg) -> *Type_Variable, Type_Variable_Handle {
tv, handle := new_builtin_type_variable(checker, .Struct, .Declaration, name, name);
builtin_node := new_builtin_struct_node(checker.ctx, name, members);
symbol : Defined_Symbol;
symbol.name = name;
symbol.source_node = builtin_node;
symbol.builtin = true;
symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, name, symbol);
tv.source_node = builtin_node;
field_list := get_field_list(builtin_node);
scope, scope_handle := push_scope(checker, name, .Struct);
tv.scope = scope_handle;
for member : members {
typename : string;
kind := lookup_type(checker, checker.current_scope, member.typename, *typename);
member_var, member_handle := new_builtin_type_variable(checker, kind, .Expression, member.name);
member_var.scope = tv.scope;
member_symbol : Defined_Symbol;
member_symbol.name = member.name;
member_symbol.type_variable = member_handle;
add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, member.name, member_symbol);
field_list.children[it_index].type_variable = member_handle;
member_var.source_node = field_list.children[it_index];
add_child(checker, handle, member_handle);
}
pop_scope(checker);
return from_handle(checker, handle), handle;
}
new_builtin_function :: (checker : *Semantic_Checker, name : string, args : []Arg, return_arg : Arg) -> *Type_Variable, Type_Variable_Handle {
tv, handle := new_builtin_type_variable(checker, .Function, .Declaration, name);
builtin_node := new_builtin_function_node(checker.ctx, name, args, return_arg);
function : Defined_Symbol;
function.name = name;
function.source_node = builtin_node;
function.type_variable = handle;
find_result := find_symbol(checker, name, checker.current_scope);
if !find_result {
symbol : Defined_Symbol;
symbol.name = name;
symbol.source_node = builtin_node;
symbol.builtin = true;
symbol.type_variable = 0;
symbol.functions.allocator = get_current_scope(checker).allocator;
array_add(*symbol.functions, function);
add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, name, symbol);
} else {
array_add(*find_result.functions, function);
}
tv.source_node = builtin_node;
field_list := get_field_list(builtin_node);
for arg : args {
typename : string;
kind := lookup_type(checker, checker.current_scope, arg.typename, *typename);
arg_var, arg_handle := new_builtin_type_variable(checker, kind, .Expression, arg.name);
arg_var.scope = tv.scope;
arg_var.type = kind;
arg_var.typename = typename;
field_list.children[it_index].type_variable = arg_handle;
arg_var.source_node = field_list.children[it_index];
add_child(checker, handle, arg_handle);
}
if return_arg.typename.count > 0 {
return_var, return_handle := new_type_variable(checker);
return_var.type = lookup_type(checker, checker.current_scope, return_arg.typename, *return_var.typename);
from_handle(checker, handle).return_type_variable = return_handle;
}
return from_handle(checker, handle), handle;
}
add_child :: (variable : *Type_Variable, child : Type_Variable_Handle) { add_child :: (variable : *Type_Variable, child : Type_Variable_Handle) {
assert(variable.children.count < Type_Variable.MAX_TYPE_VARIABLE_CHILDREN); assert(variable.children.count < Type_Variable.MAX_TYPE_VARIABLE_CHILDREN);
array_add(*variable.children, child); array_add(*variable.children, child);
@@ -718,17 +832,14 @@ init_semantic_checker :: (checker : *Semantic_Checker, root : *AST_Node, path :
checker.current_buffer_index = 0; checker.current_buffer_index = 0;
checker.current_sampler_index = 0; checker.current_sampler_index = 0;
checker.current_texture_index = 0; checker.current_texture_index = 0;
array_reserve(*checker.messages, 16);
checker.program_root = root; checker.program_root = root;
checker.path = path; checker.path = path;
// @Incomplete(niels): Use other allocator and/or add static array with convenience functions array_reserve(*checker.ctx.type_variables, 2048);
array_reserve(*checker.result_file.type_variables, 2048);
checker.result_file.scope_stack.allocator = make_arena(*checker.result_file.scope_stack.arena); checker.ctx.scope_stack.stack.allocator = checker.ctx.scope_stack.allocator;
array_reserve(*checker.result_file.scope_stack.stack, 256); array_reserve(*checker.ctx.scope_stack.stack, 256);
global_scope, global_handle := push_scope(checker, kind = .Global); global_scope, global_handle := push_scope(checker, kind = .Global);
array_reserve(*global_scope.children, 2048); array_reserve(*global_scope.children, 2048);
@@ -754,7 +865,7 @@ find_symbol :: (scope_stack : Scope_Stack, name : string, current_scope : Scope_
} }
find_symbol :: (checker : *Semantic_Checker, name : string, current_scope : Scope_Handle, containing_scope : *Scope_Handle = null) -> *Defined_Symbol { find_symbol :: (checker : *Semantic_Checker, name : string, current_scope : Scope_Handle, containing_scope : *Scope_Handle = null) -> *Defined_Symbol {
return find_symbol(checker.result_file.scope_stack, name, current_scope, containing_scope); return find_symbol(checker.ctx.scope_stack, name, current_scope, containing_scope);
} }
find_symbol :: (name : string, checker : *Semantic_Checker, containing_scope : *Scope_Handle = null) -> *Defined_Symbol { find_symbol :: (name : string, checker : *Semantic_Checker, containing_scope : *Scope_Handle = null) -> *Defined_Symbol {
@@ -762,12 +873,12 @@ find_symbol :: (name : string, checker : *Semantic_Checker, containing_scope : *
} }
from_handle :: (variables : []Type_Variable, handle : Type_Variable_Handle) -> *Type_Variable { from_handle :: (variables : []Type_Variable, handle : Type_Variable_Handle) -> *Type_Variable {
assert(handle > 0 && xx handle <= variables.count, tprint("Invalid handle: %. Range is: 1-%", handle, variables.count - 1)); // assert(handle > 0 && xx handle <= variables.count, tprint("Invalid handle: %. Range is: 1-%", handle, variables.count - 1));
return *variables[handle - 1]; return *variables[handle - 1];
} }
from_handle :: (checker : *Semantic_Checker, handle : Type_Variable_Handle) -> *Type_Variable { from_handle :: (checker : *Semantic_Checker, handle : Type_Variable_Handle) -> *Type_Variable {
return from_handle(checker.result_file.type_variables, handle); return from_handle(checker.ctx.type_variables, handle);
} }
proper_type_to_string :: (builder : *String_Builder, variables : []Type_Variable, var : Type_Variable) { proper_type_to_string :: (builder : *String_Builder, variables : []Type_Variable, var : Type_Variable) {
@@ -842,11 +953,8 @@ proper_type_to_string :: (variables : []Type_Variable, var : Type_Variable, allo
return "______not proper type______"; return "______not proper type______";
} }
get_type_from_identifier :: (checker : *Semantic_Checker, scope : Scope_Handle, node : *AST_Node, typename : *string = null) -> Type_Kind {
type_string := node.token.ident_value;
lookup_type :: (checker : *Semantic_Checker, scope : Scope_Handle, type_string : string, typename : *string = null) -> Type_Kind {
if type_string == { if type_string == {
case Typenames[Type_Kind.Int]; return .Int; case Typenames[Type_Kind.Int]; return .Int;
case Typenames[Type_Kind.Half]; return .Half; case Typenames[Type_Kind.Half]; return .Half;
@@ -872,8 +980,9 @@ get_type_from_identifier :: (checker : *Semantic_Checker, scope : Scope_Handle,
return .Invalid; return .Invalid;
} }
check_expression :: (node : *AST_Node, checker : *Semantic_Checker) -> Type_Variable_Handle { lookup_type :: (checker : *Semantic_Checker, scope : Scope_Handle, node : *AST_Node, typename : *string = null) -> Type_Kind {
return 0; type_string := node.token.ident_value;
return lookup_type(checker, scope, type_string, typename);
} }
check_block :: (checker : *Semantic_Checker, node : *AST_Node) { check_block :: (checker : *Semantic_Checker, node : *AST_Node) {
@@ -885,7 +994,7 @@ check_block :: (checker : *Semantic_Checker, node : *AST_Node) {
declare_struct :: (checker : *Semantic_Checker, node : *AST_Node, name : string) -> Type_Variable_Handle { declare_struct :: (checker : *Semantic_Checker, node : *AST_Node, name : string) -> Type_Variable_Handle {
variable, handle := new_type_variable(checker); variable, handle := new_type_variable(checker);
variable.type = .Struct; variable.type = .Struct;
variable.kind = .Declaration; variable.source_kind = .Declaration;
variable.name = name; variable.name = name;
variable.source_node = node; variable.source_node = node;
variable.typename = name; variable.typename = name;
@@ -898,7 +1007,7 @@ declare_struct :: (checker : *Semantic_Checker, node : *AST_Node, name : string)
symbol.name = name; symbol.name = name;
symbol.source_node = node; symbol.source_node = node;
symbol.type_variable = handle; symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, name, symbol); add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, name, symbol);
} else { } else {
symbol_redeclaration(checker, node, find_result); symbol_redeclaration(checker, node, find_result);
return 0; return 0;
@@ -933,7 +1042,7 @@ declare_properties :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Va
name := ifx node.name.count == 0 then "properties" else node.name; name := ifx node.name.count == 0 then "properties" else node.name;
if node.name.count > 0 { if node.name.count > 0 {
checker.result_file.property_name = name; checker.ctx.property_name = name;
} }
type_var := declare_struct(checker, node, name); type_var := declare_struct(checker, node, name);
var := from_handle(checker, type_var); var := from_handle(checker, type_var);
@@ -950,14 +1059,13 @@ declare_cbuffer :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Varia
var.type = .CBuffer; var.type = .CBuffer;
var.resource_index = checker.current_buffer_index; var.resource_index = checker.current_buffer_index;
checker.current_buffer_index += 1; checker.current_buffer_index += 1;
array_add(*checker.result_file.constant_buffers, type_var); array_add(*checker.ctx.constant_buffers, type_var);
return type_var; return type_var;
} }
get_actual_function_name :: (node : *AST_Node) -> string { get_actual_function_name :: (node : *AST_Node) -> string {
name_to_check := node.name; name_to_check := node.name;
if node.vertex_entry_point { if node.vertex_entry_point {
name_to_check = sprint("%__%", VERTEX_MAIN_FUNCTION_PREFIX, node.name); name_to_check = sprint("%__%", VERTEX_MAIN_FUNCTION_PREFIX, node.name);
} else if node.pixel_entry_point { } else if node.pixel_entry_point {
name_to_check = sprint("%__%", PIXEL_MAIN_FUNCTION_PREFIX, node.name); name_to_check = sprint("%__%", PIXEL_MAIN_FUNCTION_PREFIX, node.name);
@@ -977,7 +1085,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
variable, handle := new_type_variable(checker); variable, handle := new_type_variable(checker);
variable.type = .Function; variable.type = .Function;
variable.kind = .Declaration; variable.source_kind = .Declaration;
variable.name = node.name; variable.name = node.name;
variable.source_node = node; variable.source_node = node;
variable.builtin = builtin; variable.builtin = builtin;
@@ -986,11 +1094,11 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
name_to_check := get_actual_function_name(node); name_to_check := get_actual_function_name(node);
if node.vertex_entry_point { if node.vertex_entry_point {
checker.result_file.vertex_entry_point.node = node; checker.ctx.vertex_entry_point.node = node;
} }
if node.pixel_entry_point { if node.pixel_entry_point {
checker.result_file.pixel_entry_point.node = node; checker.ctx.pixel_entry_point.node = node;
} }
find_result := find_symbol(checker, name_to_check, checker.current_scope); find_result := find_symbol(checker, name_to_check, checker.current_scope);
@@ -1004,10 +1112,11 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
symbol.name = name_to_check; symbol.name = name_to_check;
symbol.source_node = node; symbol.source_node = node;
symbol.type_variable = 0; symbol.type_variable = 0;
symbol.functions.allocator = get_current_scope(checker).allocator;
array_reserve(*symbol.functions, 32); array_reserve(*symbol.functions, 32);
array_add(*symbol.functions, function); array_add(*symbol.functions, function);
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, name_to_check, symbol); add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, name_to_check, symbol);
} else { } else {
//@Note(niels): This is some ugly code, but it's probably fine for now. //@Note(niels): This is some ugly code, but it's probably fine for now.
field_list := node.children[0]; field_list := node.children[0];
@@ -1024,7 +1133,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
node_child := field_list.children[i]; node_child := field_list.children[i];
typename : string; typename : string;
arg_type := get_type_from_identifier(checker, checker.current_scope, node_child, *typename); arg_type := lookup_type(checker, checker.current_scope, node_child, *typename);
other_arg := from_handle(checker, arg); other_arg := from_handle(checker, arg);
if arg_type != other_arg.type { if arg_type != other_arg.type {
@@ -1084,7 +1193,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
if builtin && node.token.ident_value.count > 0 { if builtin && node.token.ident_value.count > 0 {
return_var, return_handle := new_type_variable(checker); return_var, return_handle := new_type_variable(checker);
return_var.type = get_type_from_identifier(checker, checker.current_scope, node, *return_var.typename); return_var.type = lookup_type(checker, checker.current_scope, node, *return_var.typename);
from_handle(checker, handle).return_type_variable= return_handle; from_handle(checker, handle).return_type_variable= return_handle;
} }
@@ -1204,7 +1313,7 @@ check_field :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_
variable, handle := new_type_variable(checker); variable, handle := new_type_variable(checker);
variable.name = node.name; variable.name = node.name;
typename : string; typename : string;
variable.type = get_type_from_identifier(checker, checker.current_scope, node, *typename); variable.type = lookup_type(checker, checker.current_scope, node, *typename);
variable.is_array = node.array_field; variable.is_array = node.array_field;
@@ -1216,12 +1325,12 @@ check_field :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_
} }
} }
if variable.kind == .Declaration && variable.type == .Sampler { if variable.source_kind == .Declaration && variable.type == .Sampler {
variable.resource_index = checker.current_sampler_index; variable.resource_index = checker.current_sampler_index;
checker.current_sampler_index += 1; checker.current_sampler_index += 1;
} }
if variable.kind == .Declaration && variable.type == .Texture2D { if variable.source_kind == .Declaration && variable.type == .Texture2D {
variable.resource_index = checker.current_texture_index; variable.resource_index = checker.current_texture_index;
checker.current_texture_index += 1; checker.current_texture_index += 1;
} }
@@ -1244,7 +1353,7 @@ check_field :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_
symbol.name = node.name; symbol.name = node.name;
symbol.source_node = node; symbol.source_node = node;
symbol.type_variable = handle; symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.result_file.scope_stack, checker.current_scope, node.name, symbol); add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, node.name, symbol);
} else { } else {
symbol_redeclaration(checker, node, find_result); symbol_redeclaration(checker, node, find_result);
return 0; return 0;
@@ -1252,7 +1361,7 @@ check_field :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_
} }
if node.token.ident_value.count > 0 { if node.token.ident_value.count > 0 {
variable.type = get_type_from_identifier(checker, checker.current_scope, node); variable.type = lookup_type(checker, checker.current_scope, node);
} }
if node.children.count > 0 { if node.children.count > 0 {
@@ -1437,8 +1546,6 @@ check_node :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_H
lhs_type := from_handle(checker, lhs_var); lhs_type := from_handle(checker, lhs_var);
rhs_type := from_handle(checker, rhs_var); rhs_type := from_handle(checker, rhs_var);
variable.type = lhs_type.type; variable.type = lhs_type.type;
variable.typename = lhs_type.typename; variable.typename = lhs_type.typename;
variable.scope = lhs_type.scope; variable.scope = lhs_type.scope;
@@ -1490,6 +1597,33 @@ check_node :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_H
case .Return; { case .Return; {
return check_node(checker, node.children[0]); return check_node(checker, node.children[0]);
} }
case .For; {
loop_iterator := node.token;
symbol : Defined_Symbol;
symbol.name = loop_iterator.ident_value;
symbol.source_node = node;
variable, handle := new_type_variable(checker);
variable.name = symbol.name;
typename : string;
variable.type = .Int;
symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.ctx.scope_stack, checker.current_scope, symbol.name, symbol);
begin_iter := check_node(checker, node.children[0]);
begin_var := from_handle(checker, begin_iter);
if begin_var.type != .Int {
}
end_iter := check_node(checker, node.children[1]);
end_var := from_handle(checker, end_iter);
if end_var.type != .Int {
}
check_block(checker, node.children[2]);
}
case .If; { case .If; {
cond_var := check_node(checker, node.children[0]); cond_var := check_node(checker, node.children[0]);
@@ -1510,6 +1644,10 @@ check_node :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_H
} }
} }
} }
case .If_Directive; {
cond_var := check_node(checker, node.children[0]);
assert(false, "Not implemented yet\n");
}
case .Variable; { case .Variable; {
return check_variable(checker, node); return check_variable(checker, node);
} }
@@ -1656,11 +1794,278 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
return true; return true;
} }
} }
return false; return false;
} }
add_hlsl_builtins :: (checker : *Semantic_Checker) { add_builtins_new :: (checker : *Semantic_Checker) {
checker.state = .Adding_Builtins;
float_name := Typenames[Type_Kind.Float];
int_name := Typenames[Type_Kind.Int];
arg :: (name : string = "", kind : Type_Kind) -> Arg {
return .{ name, Typenames[kind] };
}
targ :: (typename : string) -> Arg {
return .{ "", typename };
}
farg :: (name : string = "") -> Arg {
return arg(name, .Float);
}
iarg :: (name : string = "") -> Arg {
return arg(name, .Int);
}
float2_tv, f2h := new_builtin_struct(checker, "float2", .[farg("x"), farg("y")]);
float3_tv, f3h := new_builtin_struct(checker, "float3", .[farg("x"), farg("y"), farg("z")]);
float4_tv, f4h := new_builtin_struct(checker, "float4", .[farg("x"), farg("y"), farg("z"), farg("w")]);
float4x4_members : [16]Arg;
i := 0;
for x : 0..3 {
for y : 0..3 {
float4x4_members[i] = farg(tprint("m%1%2", x + 1, y + 1));
i += 1;
}
}
float4x4_tv, f4x4h := new_builtin_struct(checker, "float4x4", float4x4_members);
int2_tv, i2h := new_builtin_struct(checker, "int2", .[iarg("x"), iarg("y")]);
int3_tv, i3h := new_builtin_struct(checker, "int3", .[iarg("x"), iarg("y"), iarg("z")]);
int4_tv, i4h := new_builtin_struct(checker, "int4", .[iarg("x"), iarg("y"), iarg("z"), iarg("w")]);
int4x4_members : [16]Arg;
i = 0;
for x : 0..3 {
for y : 0..3 {
int4x4_members[i].name = tprint("m%1%2", x + 1, y + 1);
int4x4_members[i].typename = int_name;
i += 1;
}
}
int4x4_tv, i4x4h := new_builtin_struct(checker, "int4x4", int4x4_members);
new_builtin_function(checker, "float2", .[farg(), farg()], targ("float2"));
new_builtin_function(checker, "float2", .[farg()], targ("float2"));
new_builtin_function(checker, "float2", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "float3", .[farg(), farg(), farg()], targ("float3"));
new_builtin_function(checker, "float3", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "float3", .[targ("float2"), farg()], targ("float3"));
new_builtin_function(checker, "float3", .[farg(), targ("float2")], targ("float3"));
new_builtin_function(checker, "float3", .[farg()], targ("float3"));
new_builtin_function(checker, "float4", .[farg(), farg(), farg(), farg()], targ("float4"));
new_builtin_function(checker, "float4", .[targ("float2"), targ("float2")], targ("float4"));
new_builtin_function(checker, "float4", .[targ("float2"), farg(), farg()], targ("float4"));
new_builtin_function(checker, "float4", .[farg(), targ("float2"), farg()], targ("float4"));
new_builtin_function(checker, "float4", .[farg(), farg(), targ("float2")], targ("float4"));
new_builtin_function(checker, "float4", .[farg(), targ("float3")], targ("float4"));
new_builtin_function(checker, "float4", .[targ("float3"), farg()], targ("float4"));
new_builtin_function(checker, "float4", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "float4", .[farg()], targ("float4"));
new_builtin_function(checker, "cross", .[targ("float3"), targ("float3")], targ("float3"));
new_builtin_function(checker, "distance", .[targ("float2"), targ("float2")], farg());
new_builtin_function(checker, "distance", .[targ("float3"), targ("float3")], farg());
new_builtin_function(checker, "distance", .[targ("float4"), targ("float4")], farg());
new_builtin_function(checker, "length", .[targ("float2")], farg());
new_builtin_function(checker, "length", .[targ("float3")], farg());
new_builtin_function(checker, "length", .[targ("float3")], farg());
new_builtin_function(checker, "dot", .[targ("float2"), targ("float2")], farg());
new_builtin_function(checker, "dot", .[targ("float3"), targ("float3")], farg());
new_builtin_function(checker, "dot", .[targ("float4"), targ("float4")], farg());
new_builtin_function(checker, "normalize", .[targ("float2")], farg());
new_builtin_function(checker, "normalize", .[targ("float3")], farg());
new_builtin_function(checker, "normalize", .[targ("float3")], farg());
new_builtin_function(checker, "transpose", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "mul", .[targ("float2"), targ("float2")], farg());
new_builtin_function(checker, "mul", .[targ("float3"), targ("float3")], farg());
new_builtin_function(checker, "mul", .[targ("float4"), targ("float4")], farg());
new_builtin_function(checker, "mul", .[targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "mul", .[farg(), targ("float2")], targ("float2"));
new_builtin_function(checker, "mul", .[farg(), targ("float3")], targ("float3"));
new_builtin_function(checker, "mul", .[farg(), targ("float4")], targ("float4"));
new_builtin_function(checker, "mul", .[farg(), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "mul", .[targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "mul", .[targ("float4x4"), targ("float4")], targ("float4"));
new_builtin_function(checker, "mul", .[targ("float2"), farg()], targ("float2"));
new_builtin_function(checker, "mul", .[targ("float3"), farg()], targ("float3"));
new_builtin_function(checker, "mul", .[targ("float4"), farg()], targ("float4"));
new_builtin_function(checker, "mul", .[targ("float4"), targ("float4x4")], targ("float4"));
new_builtin_function(checker, "abs", .[farg()], farg());
new_builtin_function(checker, "abs", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "abs", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "abs", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "abs", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "min", .[farg()], farg());
new_builtin_function(checker, "min", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "min", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "min", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "min", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "max", .[farg()], farg());
new_builtin_function(checker, "max", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "max", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "max", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "max", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "ceil", .[farg()], farg());
new_builtin_function(checker, "ceil", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "ceil", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "ceil", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "ceil", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "floor", .[farg()], farg());
new_builtin_function(checker, "floor", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "floor", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "floor", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "floor", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "round", .[farg()], farg());
new_builtin_function(checker, "round", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "round", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "round", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "round", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "clamp", .[farg(), farg(), farg()], farg());
new_builtin_function(checker, "clamp", .[targ("float2"), targ("float2"), targ("float2")], targ("float2"));
new_builtin_function(checker, "clamp", .[targ("float3"), targ("float3"), targ("float3")], targ("float3"));
new_builtin_function(checker, "clamp", .[targ("float4"), targ("float4"), targ("float4")], targ("float4"));
new_builtin_function(checker, "clamp", .[targ("float4x4"), targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "log", .[farg()], farg());
new_builtin_function(checker, "log", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "log", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "log", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "log", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "log2", .[farg()], farg());
new_builtin_function(checker, "log2", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "log2", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "log2", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "log2", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "log10", .[farg()], farg());
new_builtin_function(checker, "log10", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "log10", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "log10", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "log10", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "pow", .[farg(), farg(), farg()], farg());
new_builtin_function(checker, "pow", .[targ("float2"), targ("float2"), targ("float2")], targ("float2"));
new_builtin_function(checker, "pow", .[targ("float3"), targ("float3"), targ("float3")], targ("float3"));
new_builtin_function(checker, "pow", .[targ("float4"), targ("float4"), targ("float4")], targ("float4"));
new_builtin_function(checker, "pow", .[targ("float4x4"), targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "smoothstep", .[farg(), farg(), farg()], farg());
new_builtin_function(checker, "smoothstep", .[targ("float2"), targ("float2"), targ("float2")], targ("float2"));
new_builtin_function(checker, "smoothstep", .[targ("float3"), targ("float3"), targ("float3")], targ("float3"));
new_builtin_function(checker, "smoothstep", .[targ("float4"), targ("float4"), targ("float4")], targ("float4"));
new_builtin_function(checker, "smoothstep", .[targ("float4x4"), targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "step", .[farg()], farg());
new_builtin_function(checker, "step", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "step", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "step", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "step", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "sqrt", .[farg()], farg());
new_builtin_function(checker, "sqrt", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "sqrt", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "sqrt", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "sqrt", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "cos", .[farg()], farg());
new_builtin_function(checker, "cos", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "cos", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "cos", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "cos", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "cosh", .[farg()], farg());
new_builtin_function(checker, "cosh", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "cosh", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "cosh", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "cosh", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "acos", .[farg()], farg());
new_builtin_function(checker, "acos", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "acos", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "acos", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "acos", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "sin", .[farg()], farg());
new_builtin_function(checker, "sin", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "sin", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "sin", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "sin", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "sinh", .[farg()], farg());
new_builtin_function(checker, "sinh", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "sinh", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "sinh", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "sinh", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "asin", .[farg()], farg());
new_builtin_function(checker, "asin", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "asin", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "asin", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "asin", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "tan", .[farg()], farg());
new_builtin_function(checker, "tan", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "tan", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "tan", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "tan", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "tanh", .[farg()], farg());
new_builtin_function(checker, "tanh", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "tanh", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "tanh", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "tanh", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "atan", .[farg()], farg());
new_builtin_function(checker, "atan", .[targ("float2")], targ("float2"));
new_builtin_function(checker, "atan", .[targ("float3")], targ("float3"));
new_builtin_function(checker, "atan", .[targ("float4")], targ("float4"));
new_builtin_function(checker, "atan", .[targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "atan2", .[farg(), farg()], farg());
new_builtin_function(checker, "atan2", .[targ("float2"), targ("float2")], farg());
new_builtin_function(checker, "atan2", .[targ("float3"), targ("float3")], farg());
new_builtin_function(checker, "atan2", .[targ("float4"), targ("float4")], farg());
new_builtin_function(checker, "atan2", .[targ("float4x4"), targ("float4x4")], targ("float4x4"));
new_builtin_function(checker, "sample", .[targ(Typenames[Type_Kind.Texture2D]), targ(Typenames[Type_Kind.Sampler])], targ("float4"));
new_builtin_function(checker, "pow", .[farg(), farg(), farg()], farg());
new_builtin_function(checker, "pow", .[targ("float2"), targ("float2"), farg()], targ("float2"));
new_builtin_function(checker, "pow", .[targ("float3"), targ("float3"), farg()], targ("float3"));
new_builtin_function(checker, "pow", .[targ("float4"), targ("float4"), farg()], targ("float4"));
checker.state = .Type_Checking;
}
add_builtins :: (checker : *Semantic_Checker) {
source_location := #location().fully_pathed_filename; source_location := #location().fully_pathed_filename;
path_array := split(source_location, "/"); path_array := split(source_location, "/");
@@ -1670,11 +2075,11 @@ add_hlsl_builtins :: (checker : *Semantic_Checker) {
append(*sb, "/"); append(*sb, "/");
} }
append(*sb, "hlsl_builtin.ink"); append(*sb, "builtins.ink");
path := builder_to_string(*sb); path := builder_to_string(*sb);
HLSL_BUILTIN, ok := read_entire_file(path); BUILTIN, ok := read_entire_file(path);
if !ok { if !ok {
messages : [..]Compiler_Message; messages : [..]Compiler_Message;
@@ -1686,70 +2091,71 @@ add_hlsl_builtins :: (checker : *Semantic_Checker) {
checker.state = .Adding_Builtins; checker.state = .Adding_Builtins;
lexer : Lexer; checker.ctx.file = make_file_from_string(BUILTIN);
prev_file := checker.ctx.file;
prev_root := checker.ctx.root;
prev_tokens := checker.ctx.tokens;
checker.ctx.root = null;
tokens : [..]Token;
scratch := get_scratch();
defer scratch_end(scratch);
tokens.allocator = scratch.allocator;
array_reserve(*tokens, 1024 * 1024);
checker.ctx.tokens = tokens;
init_lexer_from_string(*lexer, HLSL_BUILTIN); checker.ctx.tokens.count = 0;
if lexer.result.had_error {
print("%\n", report_messages(lexer.result.messages));
return;
}
lex_result := lex(*lexer,, *temp);
if lex_result.had_error {
print("%\n", report_messages(lex_result.messages));
return;
}
parse_state : Parse_State; lex(checker.ctx);
init_parse_state(*parse_state, lex_result.tokens, lexer.path); parse(checker.ctx);
type_check(checker, checker.ctx.root);
parse_result := parse(*parse_state); for *type_var : checker.ctx.type_variables {
if parse_result.had_error {
print("%\n", report_messages(parse_result.messages));
return;
}
type_check(checker, parse_result.root);
if checker.had_error {
print("%\n", report_messages(checker.messages));
return;
}
for *type_var : checker.result_file.type_variables {
type_var.builtin = true; type_var.builtin = true;
} }
checker.state = .Type_Checking; checker.state = .Type_Checking;
checker.ctx.file = prev_file;
checker.ctx.root = prev_root;
checker.ctx.tokens = prev_tokens;
} }
type_check :: (checker : *Semantic_Checker, root : *AST_Node) { type_check :: (checker : *Semantic_Checker, root : *AST_Node) {
traverse(checker, root); traverse(checker, root);
} }
check :: (result : *Compile_Result) { check :: (ctx : *Compiler_Context, allocator : Allocator = temp) {
if result.had_error { if ctx.had_error {
return; return;
} }
for *file : result.files { new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
checker : Semantic_Checker; checker : Semantic_Checker;
checker.current_buffer_index = 0; checker.current_buffer_index = 0;
checker.current_sampler_index = 0; checker.current_sampler_index = 0;
checker.current_texture_index = 0; checker.current_texture_index = 0;
checker.result_file = file; checker.ctx = ctx;
array_reserve(*checker.messages, 32);
init_semantic_checker(*checker, file.ast_root, file.file.path); init_semantic_checker(*checker, ctx.root, ctx.file.path);
// @Performance: Should have this built in stuff done earlier and only once
add_hlsl_builtins(*checker);
type_check(*checker, file.ast_root);
result.had_error |= checker.had_error; add_builtins_new(*checker);
copy_messages(checker.messages, *result.messages); // add_builtins(*checker);
type_check(*checker, ctx.root);
ctx.had_error |= checker.had_error;
} }
} }
// =========================================================== // ===========================================================
@@ -1882,7 +2288,7 @@ pretty_print_scope :: (current_scope : Scope_Handle, scope_stack : Scope_Stack,
case .CBuffer; #through; case .CBuffer; #through;
case .Properties; #through; case .Properties; #through;
case .Struct; { case .Struct; {
if type_variable.typename.count > 0 && type_variable.kind != .Declaration { if type_variable.typename.count > 0 && type_variable.source_kind != .Declaration {
indent(builder, indentation + 1); indent(builder, indentation + 1);
print_key(*scope_stack, current_scope, builder, key); print_key(*scope_stack, current_scope, builder, key);
print_type_variable(builder, variables, type_variable); print_type_variable(builder, variables, type_variable);
@@ -1908,7 +2314,7 @@ pretty_print_scope :: (current_scope : Scope_Handle, scope_stack : Scope_Stack,
case .CBuffer; #through; case .CBuffer; #through;
case .Properties; #through; case .Properties; #through;
case .Struct; { case .Struct; {
if type_variable.typename.count > 0 && type_variable.kind != .Declaration { if type_variable.typename.count > 0 && type_variable.source_kind != .Declaration {
indent(builder, indentation + 1); indent(builder, indentation + 1);
print_key(*scope_stack, current_scope, builder, key); print_key(*scope_stack, current_scope, builder, key);
print_to_builder(builder, "%\n", type_variable.typename); print_to_builder(builder, "%\n", type_variable.typename);
@@ -1985,7 +2391,7 @@ print_type_variable :: (builder : *String_Builder, variables : []Type_Variable,
source_location.end = right_most.source_location.main_token; source_location.end = right_most.source_location.main_token;
source_location.main_token = node.source_location.main_token; source_location.main_token = node.source_location.main_token;
print_from_source_location(builder, source_location); print("%\n", print_from_source_location(builder, source_location,, temp));
} }
case .Call; { case .Call; {
if variable.return_type_variable{ if variable.return_type_variable{
@@ -2012,7 +2418,7 @@ print_type_variable :: (builder : *String_Builder, variables : []Type_Variable,
append(builder, ")"); append(builder, ")");
} }
case; { case; {
print_from_source_location(builder, node.source_location); print("%\n", print_from_source_location(builder, node.source_location,, temp));
} }
} }
} }
@@ -2028,21 +2434,17 @@ pretty_print_symbol_table :: (checker : *Semantic_Checker, allocator : Allocator
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, allocator); init_string_builder(*builder,, allocator);
pretty_print_scope(xx checker.current_scope, checker.result_file.scope_stack, checker.result_file.type_variables, *checker.result_file.scope_stack.stack[0], *builder); pretty_print_scope(xx checker.current_scope, checker.ctx.scope_stack, checker.ctx.type_variables, *checker.ctx.scope_stack.stack[0], *builder);
return builder_to_string(*builder,, allocator); return builder_to_string(*builder,, allocator);
} }
pretty_print_symbol_table :: (result : *Compile_Result, allocator : Allocator) -> string { pretty_print_symbol_table :: (ctx : *Compiler_Context, allocator : Allocator) -> string {
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, allocator); init_string_builder(*builder,, allocator);
for *file : result.files { current_scope := cast(Scope_Handle)1;
current_scope := cast(Scope_Handle)1; pretty_print_scope(current_scope, ctx.scope_stack, ctx.type_variables, *ctx.scope_stack.stack[0], *builder);
pretty_print_scope(current_scope, file.scope_stack, file.type_variables, *file.scope_stack.stack[0], *builder);
}
return builder_to_string(*builder,, allocator); return builder_to_string(*builder,, allocator);
} }

View File

@@ -1,16 +1,19 @@
#import "Basic"; #import "Basic";
#import "File"; #import "File";
#import "Compiler"; #import "Compiler";
#import "Metaprogram_Plugins";
plugins: [..] *Metaprogram_Plugin;
build :: () { build :: () {
w := compiler_create_workspace("Shader Compiler Test Build"); w := compiler_create_workspace("Ink Build");
if !w { if !w {
print("Workspace creation failed.\n"); print("Workspace creation failed.\n");
return; return;
} }
EXECUTABLE_NAME :: "test"; EXECUTABLE_NAME :: "ink";
MAIN_FILE :: "Test.jai"; MAIN_FILE :: "Ink.jai";
options := get_build_options(w); options := get_build_options(w);
@@ -18,14 +21,45 @@ build :: () {
args := options.compile_time_command_line; args := options.compile_time_command_line;
intercept_flags: Intercept_Flags;
plugin_start_index := -1;
for arg : args { for arg : args {
if arg == { if arg == {
case "check"; { case "check"; {
options.output_type = .NO_OUTPUT; options.output_type = .NO_OUTPUT;
} }
} }
it := args[it_index];
if !it continue;
if it[0] == #char "+" {
plugin_start_index = it_index;
}
} }
plugins_to_create: [..] Plugin_To_Create;
tracy : Plugin_To_Create;
tracy.name = "tracy";
array_add(*plugins_to_create, tracy);
// got_error := false;
// if plugin_start_index >= 0 {
// success:, plugins_to_create = parse_plugin_arguments(args, plugin_start_index);
// if !success got_error = true;
// }
// if got_error {
// exit(1);
// }
success := init_plugins(plugins_to_create, *plugins, w);
if !success {
log_error("A plugin init() failed. Exiting.\n");
exit(0);
}
new_path: [..] string; new_path: [..] string;
array_add(*new_path, ..options.import_path); array_add(*new_path, ..options.import_path);
array_add(*new_path, "modules"); array_add(*new_path, "modules");
@@ -35,18 +69,41 @@ build :: () {
wd := get_working_directory(); wd := get_working_directory();
set_build_options(options, w); set_build_options(options, w);
compiler_begin_intercept(w); for plugins {
if it.before_intercept it.before_intercept(it, *intercept_flags);
}
compiler_begin_intercept(w, intercept_flags);
for plugins if it.add_source it.add_source(it);
add_build_file(MAIN_FILE, w); add_build_file(MAIN_FILE, w);
// Call message_loop(), which is a routine of ours below that will receive the messages.
message_loop(w);
compiler_end_intercept(w); compiler_end_intercept(w);
for plugins if it.finish it.finish (it);
for plugins if it.shutdown it.shutdown(it);
print("\nDone!\n\n"); print("\nDone!\n\n");
set_build_options_dc(.{do_output=false}); set_build_options_dc(.{do_output=false, write_added_strings=false});
} }
#run build(); message_loop :: (w: Workspace) {
while true {
// We ask the compiler for the next message. If one is not available,
// we will wait until it becomes available.
message := compiler_wait_for_message();
// Pass the message to all plugins.
for plugins if it.message it.message(it, message);
if message.kind == .COMPLETE break;
}
}
#run, stallable build();

View File

@@ -4,6 +4,8 @@
#load "Semantic_Analysis.jai"; #load "Semantic_Analysis.jai";
#load "Codegen.jai"; #load "Codegen.jai";
#import "File_Utilities";
add_define :: (env : *Environment, key : string) { add_define :: (env : *Environment, key : string) {
for define : env.defines { for define : env.defines {
if define == key { if define == key {
@@ -26,10 +28,6 @@ Environment :: struct {
defines : [..]string; defines : [..]string;
} }
Shader_Compiler :: struct {
environment : Environment;
}
Field_Kind :: enum { Field_Kind :: enum {
Int :: 0; Int :: 0;
Half :: 1; Half :: 1;
@@ -119,6 +117,9 @@ Constant_Buffer :: struct {
fields : Static_Array(Property_Field, 16); fields : Static_Array(Property_Field, 16);
// hints : Field_Hint; // optional hint...
hints : [..]Field_Hint;
buffer_index : u32; buffer_index : u32;
} }
@@ -136,15 +137,14 @@ Input_File :: struct {
path : string; path : string;
} }
Token_Stream :: struct { Compiler_Context :: struct {
tokens : [..]Token;
}
Compiled_File :: struct {
file : Input_File; file : Input_File;
tokens : Token_Stream;
ast_root : *AST_Node; environment : Environment;
ast_nodes : [..]AST_Node;
tokens : [..]Token;;
root : *AST_Node;
nodes : [..]AST_Node;
codegen_result_text : string; codegen_result_text : string;
@@ -170,23 +170,41 @@ Compiled_File :: struct {
properties : Properties; properties : Properties;
max_constant_buffers :: 16; max_constant_buffers :: 16;
cbuffers : Static_Array(Constant_Buffer, max_constant_buffers); cbuffers : Static_Array(Constant_Buffer, max_constant_buffers);
allocator : Allocator;
arena : Arena;
}
Compile_Result :: struct {
files : [..]Compiled_File;
had_error : bool; had_error : bool;
messages : [..]Compiler_Message; messages : [..]Compiler_Message;
allocator : Allocator;
arena : Arena;
} }
record_error :: (result : *Compile_Result, format : string, args : .. Any) { #add_context scratch_allocators : [2]Allocator;
#add_context scratch_id : int = 0;
init_context_allocators :: () {
if get_arena(context.scratch_allocators[0]) == null {
context.scratch_allocators[0] = make_arena(Megabytes(128));
context.scratch_allocators[1] = make_arena(Megabytes(128));
}
}
clear_context_allocators :: () {
if get_arena(context.scratch_allocators[0]) != null {
clear(context.scratch_allocators[0]);
clear(context.scratch_allocators[1]);
}
}
get_scratch :: (conflict : Allocator = .{}) -> Scratch {
arena := cast(*Arena)conflict.data;
if arena == get_arena(context.scratch_allocators[0]) || context.scratch_id == 0 {
context.scratch_id = 1;
return scratch_begin(*context.scratch_allocators[1]);
}
context.scratch_id = 0;
return scratch_begin(*context.scratch_allocators[0]);
}
record_error :: (result : *Compiler_Context, format : string, args : .. Any) {
error : Compiler_Message; error : Compiler_Message;
error.message_kind = .Error; error.message_kind = .Error;
error.message = sprint(format, args); error.message = sprint(format, args);
@@ -194,52 +212,30 @@ record_error :: (result : *Compile_Result, format : string, args : .. Any) {
array_add(*result.messages, error); array_add(*result.messages, error);
} }
//@Incomplete(niels): need to consider allocation make_file :: (result : *Compiler_Context, path : string) -> Input_File {
add_file :: (result : *Compile_Result, path : string) { if !file_exists(path) {
record_error(result, "Unable to load file: %", path);
return .{};
}
file_string, ok := read_entire_file(path); file_string, ok := read_entire_file(path);
if !ok { if !ok {
record_error(result, "Unable to load file: %", path); record_error(result, "Unable to load file: %", path);
return; return .{};
} }
return make_file_from_string(file_string, path);
}
make_file_from_string :: (source : string, path : string = "") -> Input_File {
input_file : Input_File; input_file : Input_File;
input_file.source = file_string; input_file.source = source;
input_file.path = path; input_file.path = path;
compiled_file : Compiled_File; return input_file;
compiled_file.file = input_file;
compiled_file.allocator = make_arena(*compiled_file.arena);
array_add(*result.files, compiled_file);
} }
// @Incomplete(nb): Will we ever even use this?
from_file :: (path : string) -> Compile_Result {
arr : [1]string;
arr[0] = path;
return from_files(arr);
}
from_files :: (paths : []string) -> Compile_Result {
result : Compile_Result;
for path : paths {
add_file(*result, path);
}
return result;
}
// Compilation_Result :: struct {
// messages : [..]Compiler_Message;
// had_error : bool;
// collection : Shader_Variant_Collection;
// }
pretty_print_field :: (field : *Field) -> string { pretty_print_field :: (field : *Field) -> string {
builder : String_Builder; builder : String_Builder;
init_string_builder(*builder,, temp); init_string_builder(*builder,, temp);
@@ -388,7 +384,7 @@ type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope
} }
field_hint.kind = .Target; field_hint.kind = .Target;
} else { } else {
field_hint.custom_hint_name = copy_string(hint.ident_value); field_hint.custom_hint_name = hint.ident_value;
field_hint.kind = .Custom; field_hint.kind = .Custom;
} }
array_add(*field.hints, field_hint); array_add(*field.hints, field_hint);
@@ -404,108 +400,117 @@ type_variable_to_field :: (type_variables : []Type_Variable, scope_stack : Scope
} }
type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field { type_variable_to_field :: (checker : *Semantic_Checker, variable : *Type_Variable) -> Field {
return type_variable_to_field(checker.result_file.type_variables, checker.result_file.scope_stack, variable); return type_variable_to_field(checker.ctx.type_variables, checker.ctx.scope_stack, variable);
} }
generate_output_data :: (result : *Compile_Result) { generate_output_data :: (ctx : *Compiler_Context) {
for *file : result.files { if ctx.had_error {
if file.vertex_entry_point.node { return;
file.vertex_entry_point.name = file.vertex_entry_point.node.name;
type_variable := from_handle(file.type_variables, file.vertex_entry_point.node.type_variable);
assert(type_variable.type == .Function);
node := type_variable.source_node;
if node.children.count > 0 {
if node.children[0].kind == .FieldList {
field_list := node.children[0];
for child : field_list.children {
tv := from_handle(file.type_variables, child.type_variable);
field := type_variable_to_field(file.type_variables, file.scope_stack, tv);
array_add(*file.vertex_entry_point.input, field);
}
}
}
}
for buffer_variable : file.constant_buffers {
variable := from_handle(file.type_variables, buffer_variable);
cb := array_add(*file.cbuffers);
for i : 0..variable.children.count - 1 {
child := variable.children[i];
field : Property_Field;
field.base_field = type_variable_to_field(file.type_variables, file.scope_stack, from_handle(file.type_variables, child));
array_add(*cb.fields, field);
}
cb.buffer_index = variable.resource_index;
}
find_result := find_symbol(*file.scope_stack, file.property_name, xx 1);
if find_result {
property_variable := from_handle(file.type_variables, find_result.type_variable);
for i : 0..property_variable.children.count - 1 {
child := property_variable.children[i];
field := type_variable_to_field(file.type_variables, file.scope_stack, from_handle(file.type_variables, child));
prop_field : Property_Field;
prop_field.base_field = field;
array_add(*file.properties.fields, prop_field);
}
file.properties.buffer_index = property_variable.resource_index;
}
if file.pixel_entry_point.node {
file.pixel_entry_point.name = file.pixel_entry_point.node.name;
type_variable := from_handle(file.type_variables, file.pixel_entry_point.node.type_variable);
assert(type_variable.type == .Function);
field := type_variable_to_field(file.type_variables, file.scope_stack, type_variable.return_type_variable);
for hint : type_variable.source_node.hint_tokens {
field_hint : Field_Hint;
if hint.ident_value == "position" {
// @Incomplete(nb): Should be a lookup table somewhere
field_hint.kind = .Position;
} else if starts_with(hint.ident_value, "target") {
// @Incomplete(nb): Should be a lookup table somewhere
index_str : string;
index_str.data = *hint.ident_value.data[7];
index_str.count = 1;
result, ok, remainder := string_to_int(index_str);
if ok {
field_hint.target_index = result;
}
field_hint.kind = .Target;
} else {
// @Incomplete(nb): custom hints
}
array_add(*field.hints, field_hint);
}
file.pixel_entry_point.return_value = field;
}
} }
}
compile_file :: (compiler : *Shader_Compiler, paths : ..string) -> Compile_Result {
result : Compile_Result;
for path : paths {
add_file(*result, path);
}
lex(*result);
parse(*result);
check(*result);
codegen(*result);
generate_output_data(*result);
return result; if ctx.vertex_entry_point.node {
ctx.vertex_entry_point.name = ctx.vertex_entry_point.node.name;
type_variable := from_handle(ctx.type_variables, ctx.vertex_entry_point.node.type_variable);
assert(type_variable.type == .Function);
node := type_variable.source_node;
if node.children.count > 0 {
if node.children[0].kind == .FieldList {
field_list := node.children[0];
for child : field_list.children {
tv := from_handle(ctx.type_variables, child.type_variable);
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, tv);
array_add(*ctx.vertex_entry_point.input, field);
}
}
}
}
for buffer_variable : ctx.constant_buffers {
variable := from_handle(ctx.type_variables, buffer_variable);
cb := array_add(*ctx.cbuffers);
for i : 0..variable.children.count - 1 {
child := variable.children[i];
field : Property_Field;
field.base_field = type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
array_add(*cb.fields, field);
}
cb.buffer_index = variable.resource_index;
for hint : variable.source_node.hint_tokens {
field_hint : Field_Hint;
field_hint.custom_hint_name = hint.ident_value;
field_hint.kind = .Custom;
array_add(*cb.hints, field_hint);
}
}
find_result := find_symbol(*ctx.scope_stack, ctx.property_name, xx 1);
if find_result {
property_variable := from_handle(ctx.type_variables, find_result.type_variable);
for i : 0..property_variable.children.count - 1 {
child := property_variable.children[i];
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, from_handle(ctx.type_variables, child));
prop_field : Property_Field;
prop_field.base_field = field;
array_add(*ctx.properties.fields, prop_field);
}
ctx.properties.buffer_index = property_variable.resource_index;
}
if ctx.pixel_entry_point.node {
ctx.pixel_entry_point.name = ctx.pixel_entry_point.node.name;
type_variable := from_handle(ctx.type_variables, ctx.pixel_entry_point.node.type_variable);
assert(type_variable.type == .Function);
field := type_variable_to_field(ctx.type_variables, ctx.scope_stack, type_variable.return_type_variable);
for hint : type_variable.source_node.hint_tokens {
field_hint : Field_Hint;
if hint.ident_value == "position" {
// @Incomplete(nb): Should be a lookup table somewhere
field_hint.kind = .Position;
} else if starts_with(hint.ident_value, "target") {
// @Incomplete(nb): Should be a lookup table somewhere
index_str : string;
index_str.data = *hint.ident_value.data[7];
index_str.count = 1;
result, ok, remainder := string_to_int(index_str);
if ok {
field_hint.target_index = result;
}
field_hint.kind = .Target;
} else {
// @Incomplete(nb): custom hints
}
array_add(*field.hints, field_hint);
}
ctx.pixel_entry_point.return_value = field;
}
} }
compile_file :: (ctx : *Compiler_Context, path : string, allocator : Allocator = temp) {
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
ctx.file = make_file(ctx, path);
lex(ctx, allocator);
parse(ctx, allocator);
check(ctx, allocator);
codegen(ctx, allocator);
generate_output_data(ctx);
}
}

1
modules/tracy Submodule

Submodule modules/tracy added at 9668d7b8ab

BIN
output.tracy Normal file

Binary file not shown.

34
test/builtin_types.ink Normal file
View File

@@ -0,0 +1,34 @@
vertex main :: () {
v2 : float2 = float2(2.0, 2.0);
v2 = float2(2.0);
v2 = float2(v2);
v3 : float3 = float3(2.0, 2.0, 2.0);
v3 = float3(v2, 1.0);
v3 = float3(1.0, v2);
v3 = float3(1.0);
v3 = float3(v3);
v4 : float4 = float4(2.0, 2.0, 2.0, 2.0);
v4 = float4(v4);
v4 = float4(v2, v2);
v4 = float4(v2, 1.0, 1.0);
v4 = float4(1.0, v2, 1.0);
v4 = float4(1.0, 1.0, v2);
v4 = float4(v3, 2.0);
v4 = float4(2.0, v3);
v4 = float4(2.0);
v4 = float4(1.0, 1.0, v2);
v4 = float4(2.0);
v2.x = 2.0;
v2.y = 2.0;
p := v2.x + v3.z;
q := v4.w + v2.x;
m : float4x4;
}

View File

@@ -0,0 +1,28 @@
void vs_main()
{
float2 v2 = float2(2.0f, 2.0f);
v2 = float2(2.0f, 2.0f);
v2 = float2(v2, v2);
float3 v3 = float3(2.0f, 2.0f, 2.0f);
v3 = float3(v2, 1.0f);
v3 = float3(1.0f, v2);
v3 = float3(1.0f, 1.0f, 1.0f);
v3 = float3(v3, v3, v3);
float4 v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v4 = float4(v4, v4, v4, v4);
v4 = float4(v2, v2);
v4 = float4(v2, 1.0f, 1.0f);
v4 = float4(1.0f, v2, 1.0f);
v4 = float4(1.0f, 1.0f, v2);
v4 = float4(v3, 2.0f);
v4 = float4(2.0f, v3);
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v4 = float4(1.0f, 1.0f, v2);
v4 = float4(2.0f, 2.0f, 2.0f, 2.0f);
v2.x = 2.0f;
v2.y = 2.0f;
float p = (v2.x + v3.z);
float q = (v4.w + v2.x);
float4x4 m;
}

View File

@@ -1,5 +1,6 @@
test/assign_arithmetic_expression.ink codegen test/assign_arithmetic_expression.ink codegen
test/basic_property_and_return_value.ink codegen test/basic_property_and_return_value.ink codegen
test/builtin_types.ink codegen
test/complicated_computation.ink codegen test/complicated_computation.ink codegen
test/constant_buffer.ink codegen test/constant_buffer.ink codegen
test/empty_struct.ink codegen test/empty_struct.ink codegen

View File

@@ -1,5 +1,6 @@
test/assign_arithmetic_expression.ink compile test/assign_arithmetic_expression.ink compile
test/basic_property_and_return_value.ink compile test/basic_property_and_return_value.ink compile
test/builtin_types.ink compile
test/complicated_computation.ink compile test/complicated_computation.ink compile
test/empty_struct.ink compile test/empty_struct.ink compile
test/empty_vertex_main.ink compile test/empty_vertex_main.ink compile

View File

@@ -0,0 +1 @@
[vertex entry point] - vs_main

6
test/for_i_loop.ink Normal file
View File

@@ -0,0 +1,6 @@
vertex main :: () {
x := 0;
for i : 0..10 {
x += 1.0;
}
}

4
test/for_i_one_liner.ink Normal file
View File

@@ -0,0 +1,4 @@
vertex main :: () {
x := 0.0;
for i : 0..10 x += 2.0;
}

6
test/for_no_iter.ink Normal file
View File

@@ -0,0 +1,6 @@
vertex main :: () {
x := 0.0;
for i : 0.. {
x += 2.0;
}
}

5
test/if_no_cond.ink Normal file
View File

@@ -0,0 +1,5 @@
vertex main :: () {
if {
}
}

5
test/ifdefs.ink Normal file
View File

@@ -0,0 +1,5 @@
#if Defines.Skinning {
vertex main :: () {
// Stub
}
}

View File

@@ -0,0 +1,223 @@
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 2 line = 2 ; column = 0 ; value ='v2'; }
{kind = TOKEN_COLON; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 27 ; length = 6 line = 2 ; column = 5 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 34 ; length = 1 line = 2 ; column = 12 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 2 ; column = 14 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 42 ; length = 1 line = 2 ; column = 20 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 43 ; length = 3 line = 2 ; column = 21 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 46 ; length = 1 line = 2 ; column = 24 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 48 ; length = 3 line = 2 ; column = 26 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 51 ; length = 1 line = 2 ; column = 29 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 52 ; length = 1 line = 2 ; column = 30 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 56 ; length = 2 line = 3 ; column = 0 ; value ='v2'; }
{kind = TOKEN_ASSIGN; ; index = 59 ; length = 1 line = 3 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 61 ; length = 6 line = 3 ; column = 5 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 67 ; length = 1 line = 3 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 68 ; length = 3 line = 3 ; column = 12 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 71 ; length = 1 line = 3 ; column = 15 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 72 ; length = 1 line = 3 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 76 ; length = 2 line = 4 ; column = 0 ; value ='v2'; }
{kind = TOKEN_ASSIGN; ; index = 79 ; length = 1 line = 4 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 81 ; length = 6 line = 4 ; column = 5 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 87 ; length = 1 line = 4 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 2 line = 4 ; column = 12 ; value ='v2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 90 ; length = 1 line = 4 ; column = 14 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 91 ; length = 1 line = 4 ; column = 15 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 97 ; length = 2 line = 6 ; column = 0 ; value ='v3'; }
{kind = TOKEN_COLON; ; index = 100 ; length = 1 line = 6 ; column = 3 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 102 ; length = 6 line = 6 ; column = 5 ; value ='float3'; }
{kind = TOKEN_ASSIGN; ; index = 109 ; length = 1 line = 6 ; column = 12 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 111 ; length = 6 line = 6 ; column = 14 ; value ='float3'; }
{kind = TOKEN_LEFTPAREN; ; index = 117 ; length = 1 line = 6 ; column = 20 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 118 ; length = 3 line = 6 ; column = 21 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 121 ; length = 1 line = 6 ; column = 24 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 123 ; length = 3 line = 6 ; column = 26 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 126 ; length = 1 line = 6 ; column = 29 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 128 ; length = 3 line = 6 ; column = 31 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 131 ; length = 1 line = 6 ; column = 34 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 132 ; length = 1 line = 6 ; column = 35 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 136 ; length = 2 line = 7 ; column = 0 ; value ='v3'; }
{kind = TOKEN_ASSIGN; ; index = 139 ; length = 1 line = 7 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 141 ; length = 6 line = 7 ; column = 5 ; value ='float3'; }
{kind = TOKEN_LEFTPAREN; ; index = 147 ; length = 1 line = 7 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 148 ; length = 2 line = 7 ; column = 12 ; value ='v2'; }
{kind = TOKEN_COMMA; ; index = 150 ; length = 1 line = 7 ; column = 14 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 152 ; length = 3 line = 7 ; column = 16 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 155 ; length = 1 line = 7 ; column = 19 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 156 ; length = 1 line = 7 ; column = 20 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 160 ; length = 2 line = 8 ; column = 0 ; value ='v3'; }
{kind = TOKEN_ASSIGN; ; index = 163 ; length = 1 line = 8 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 165 ; length = 6 line = 8 ; column = 5 ; value ='float3'; }
{kind = TOKEN_LEFTPAREN; ; index = 171 ; length = 1 line = 8 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 172 ; length = 3 line = 8 ; column = 12 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 175 ; length = 1 line = 8 ; column = 15 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 177 ; length = 2 line = 8 ; column = 17 ; value ='v2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 179 ; length = 1 line = 8 ; column = 19 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 180 ; length = 1 line = 8 ; column = 20 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 2 line = 9 ; column = 0 ; value ='v3'; }
{kind = TOKEN_ASSIGN; ; index = 187 ; length = 1 line = 9 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 189 ; length = 6 line = 9 ; column = 5 ; value ='float3'; }
{kind = TOKEN_LEFTPAREN; ; index = 195 ; length = 1 line = 9 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 196 ; length = 3 line = 9 ; column = 12 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 199 ; length = 1 line = 9 ; column = 15 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 200 ; length = 1 line = 9 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 204 ; length = 2 line = 10 ; column = 0 ; value ='v3'; }
{kind = TOKEN_ASSIGN; ; index = 207 ; length = 1 line = 10 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 209 ; length = 6 line = 10 ; column = 5 ; value ='float3'; }
{kind = TOKEN_LEFTPAREN; ; index = 215 ; length = 1 line = 10 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 216 ; length = 2 line = 10 ; column = 12 ; value ='v3'; }
{kind = TOKEN_RIGHTPAREN; ; index = 218 ; length = 1 line = 10 ; column = 14 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 219 ; length = 1 line = 10 ; column = 15 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 2 line = 12 ; column = 0 ; value ='v4'; }
{kind = TOKEN_COLON; ; index = 229 ; length = 1 line = 12 ; column = 3 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 231 ; length = 6 line = 12 ; column = 5 ; value ='float4'; }
{kind = TOKEN_ASSIGN; ; index = 238 ; length = 1 line = 12 ; column = 12 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 240 ; length = 6 line = 12 ; column = 14 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 246 ; length = 1 line = 12 ; column = 20 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 247 ; length = 3 line = 12 ; column = 21 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 250 ; length = 1 line = 12 ; column = 24 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 252 ; length = 3 line = 12 ; column = 26 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 255 ; length = 1 line = 12 ; column = 29 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 257 ; length = 3 line = 12 ; column = 31 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 260 ; length = 1 line = 12 ; column = 34 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 262 ; length = 3 line = 12 ; column = 36 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 265 ; length = 1 line = 12 ; column = 39 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 266 ; length = 1 line = 12 ; column = 40 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 270 ; length = 2 line = 13 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 273 ; length = 1 line = 13 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 275 ; length = 6 line = 13 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 281 ; length = 1 line = 13 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 282 ; length = 2 line = 13 ; column = 12 ; value ='v4'; }
{kind = TOKEN_RIGHTPAREN; ; index = 284 ; length = 1 line = 13 ; column = 14 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 285 ; length = 1 line = 13 ; column = 15 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 289 ; length = 2 line = 14 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 292 ; length = 1 line = 14 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 294 ; length = 6 line = 14 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 300 ; length = 1 line = 14 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 301 ; length = 2 line = 14 ; column = 12 ; value ='v2'; }
{kind = TOKEN_COMMA; ; index = 303 ; length = 1 line = 14 ; column = 14 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 305 ; length = 2 line = 14 ; column = 16 ; value ='v2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 307 ; length = 1 line = 14 ; column = 18 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 308 ; length = 1 line = 14 ; column = 19 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 312 ; length = 2 line = 15 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 315 ; length = 1 line = 15 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 317 ; length = 6 line = 15 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 323 ; length = 1 line = 15 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 324 ; length = 2 line = 15 ; column = 12 ; value ='v2'; }
{kind = TOKEN_COMMA; ; index = 326 ; length = 1 line = 15 ; column = 14 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 328 ; length = 3 line = 15 ; column = 16 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 331 ; length = 1 line = 15 ; column = 19 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 333 ; length = 3 line = 15 ; column = 21 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 336 ; length = 1 line = 15 ; column = 24 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 337 ; length = 1 line = 15 ; column = 25 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 341 ; length = 2 line = 16 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 344 ; length = 1 line = 16 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 346 ; length = 6 line = 16 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 352 ; length = 1 line = 16 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 353 ; length = 3 line = 16 ; column = 12 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 356 ; length = 1 line = 16 ; column = 15 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 358 ; length = 2 line = 16 ; column = 17 ; value ='v2'; }
{kind = TOKEN_COMMA; ; index = 360 ; length = 1 line = 16 ; column = 19 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 362 ; length = 3 line = 16 ; column = 21 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 365 ; length = 1 line = 16 ; column = 24 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 366 ; length = 1 line = 16 ; column = 25 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 370 ; length = 2 line = 17 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 373 ; length = 1 line = 17 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 375 ; length = 6 line = 17 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 381 ; length = 1 line = 17 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 382 ; length = 3 line = 17 ; column = 12 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 385 ; length = 1 line = 17 ; column = 15 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 387 ; length = 3 line = 17 ; column = 17 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 390 ; length = 1 line = 17 ; column = 20 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 392 ; length = 2 line = 17 ; column = 22 ; value ='v2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 394 ; length = 1 line = 17 ; column = 24 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 395 ; length = 1 line = 17 ; column = 25 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 399 ; length = 2 line = 18 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 402 ; length = 1 line = 18 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 404 ; length = 6 line = 18 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 410 ; length = 1 line = 18 ; column = 11 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 411 ; length = 2 line = 18 ; column = 12 ; value ='v3'; }
{kind = TOKEN_COMMA; ; index = 413 ; length = 1 line = 18 ; column = 14 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 415 ; length = 3 line = 18 ; column = 16 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 418 ; length = 1 line = 18 ; column = 19 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 419 ; length = 1 line = 18 ; column = 20 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 423 ; length = 2 line = 19 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 426 ; length = 1 line = 19 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 428 ; length = 6 line = 19 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 434 ; length = 1 line = 19 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 435 ; length = 3 line = 19 ; column = 12 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 438 ; length = 1 line = 19 ; column = 15 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 440 ; length = 2 line = 19 ; column = 17 ; value ='v3'; }
{kind = TOKEN_RIGHTPAREN; ; index = 442 ; length = 1 line = 19 ; column = 19 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 443 ; length = 1 line = 19 ; column = 20 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 447 ; length = 2 line = 20 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 450 ; length = 1 line = 20 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 452 ; length = 6 line = 20 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 458 ; length = 1 line = 20 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 459 ; length = 3 line = 20 ; column = 12 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 462 ; length = 1 line = 20 ; column = 15 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 463 ; length = 1 line = 20 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 472 ; length = 2 line = 23 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 475 ; length = 1 line = 23 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 477 ; length = 6 line = 23 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 483 ; length = 1 line = 23 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 484 ; length = 3 line = 23 ; column = 12 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 487 ; length = 1 line = 23 ; column = 15 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 489 ; length = 3 line = 23 ; column = 17 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 492 ; length = 1 line = 23 ; column = 20 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 494 ; length = 2 line = 23 ; column = 22 ; value ='v2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 496 ; length = 1 line = 23 ; column = 24 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 497 ; length = 1 line = 23 ; column = 25 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 501 ; length = 2 line = 24 ; column = 0 ; value ='v4'; }
{kind = TOKEN_ASSIGN; ; index = 504 ; length = 1 line = 24 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 506 ; length = 6 line = 24 ; column = 5 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 512 ; length = 1 line = 24 ; column = 11 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 513 ; length = 3 line = 24 ; column = 12 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 516 ; length = 1 line = 24 ; column = 15 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 517 ; length = 1 line = 24 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 524 ; length = 2 line = 26 ; column = 0 ; value ='v2'; }
{kind = TOKEN_DOT; ; index = 526 ; length = 1 line = 26 ; column = 2 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 527 ; length = 1 line = 26 ; column = 3 ; value ='x'; }
{kind = TOKEN_ASSIGN; ; index = 529 ; length = 1 line = 26 ; column = 5 ; value ='='; }
{kind = TOKEN_FLOATLITERAL; ; index = 531 ; length = 3 line = 26 ; column = 7 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 534 ; length = 1 line = 26 ; column = 10 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 538 ; length = 2 line = 27 ; column = 0 ; value ='v2'; }
{kind = TOKEN_DOT; ; index = 540 ; length = 1 line = 27 ; column = 2 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 541 ; length = 1 line = 27 ; column = 3 ; value ='y'; }
{kind = TOKEN_ASSIGN; ; index = 543 ; length = 1 line = 27 ; column = 5 ; value ='='; }
{kind = TOKEN_FLOATLITERAL; ; index = 545 ; length = 3 line = 27 ; column = 7 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 548 ; length = 1 line = 27 ; column = 10 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 554 ; length = 1 line = 29 ; column = 0 ; value ='p'; }
{kind = TOKEN_COLON; ; index = 556 ; length = 1 line = 29 ; column = 2 ; value =':'; }
{kind = TOKEN_ASSIGN; ; index = 557 ; length = 1 line = 29 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 559 ; length = 2 line = 29 ; column = 5 ; value ='v2'; }
{kind = TOKEN_DOT; ; index = 561 ; length = 1 line = 29 ; column = 7 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 562 ; length = 1 line = 29 ; column = 8 ; value ='x'; }
{kind = TOKEN_PLUS; ; index = 564 ; length = 1 line = 29 ; column = 10 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 566 ; length = 2 line = 29 ; column = 12 ; value ='v3'; }
{kind = TOKEN_DOT; ; index = 568 ; length = 1 line = 29 ; column = 14 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 569 ; length = 1 line = 29 ; column = 15 ; value ='z'; }
{kind = TOKEN_SEMICOLON; ; index = 570 ; length = 1 line = 29 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 574 ; length = 1 line = 30 ; column = 0 ; value ='q'; }
{kind = TOKEN_COLON; ; index = 576 ; length = 1 line = 30 ; column = 2 ; value =':'; }
{kind = TOKEN_ASSIGN; ; index = 577 ; length = 1 line = 30 ; column = 3 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 579 ; length = 2 line = 30 ; column = 5 ; value ='v4'; }
{kind = TOKEN_DOT; ; index = 581 ; length = 1 line = 30 ; column = 7 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 582 ; length = 1 line = 30 ; column = 8 ; value ='w'; }
{kind = TOKEN_PLUS; ; index = 584 ; length = 1 line = 30 ; column = 10 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 586 ; length = 2 line = 30 ; column = 12 ; value ='v2'; }
{kind = TOKEN_DOT; ; index = 588 ; length = 1 line = 30 ; column = 14 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 589 ; length = 1 line = 30 ; column = 15 ; value ='x'; }
{kind = TOKEN_SEMICOLON; ; index = 590 ; length = 1 line = 30 ; column = 16 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 596 ; length = 1 line = 32 ; column = 0 ; value ='m'; }
{kind = TOKEN_COLON; ; index = 598 ; length = 1 line = 32 ; column = 2 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 600 ; length = 8 line = 32 ; column = 4 ; value ='float4x4'; }
{kind = TOKEN_SEMICOLON; ; index = 608 ; length = 1 line = 32 ; column = 12 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 614 ; length = 1 line = 34 ; column = 0 ; value ='}'; }
{kind = TOKEN_EOF; ; index = 617 ; length = 0 line = 35 ; column = 0 ; value =''; }

View File

@@ -0,0 +1,25 @@
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
{kind = TOKEN_INTLITERAL; ; index = 27 ; length = 1 line = 2 ; column = 5 ; value ='0'; }
{kind = TOKEN_SEMICOLON; ; index = 28 ; length = 1 line = 2 ; column = 6 ; value =';'; }
{kind = TOKEN_FOR; ; index = 32 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
{kind = TOKEN_COLON; ; index = 38 ; length = 1 line = 3 ; column = 6 ; value =':'; }
{kind = TOKEN_INTLITERAL; ; index = 40 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
{kind = TOKEN_DOTDOT; ; index = 41 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
{kind = TOKEN_INTLITERAL; ; index = 43 ; length = 2 line = 3 ; column = 11 ; value ='10'; }
{kind = TOKEN_LEFTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 14 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 1 line = 4 ; column = 0 ; value ='x'; }
{kind = TOKEN_PLUSEQUALS; ; index = 53 ; length = 2 line = 4 ; column = 2 ; value ='+='; }
{kind = TOKEN_FLOATLITERAL; ; index = 56 ; length = 3 line = 4 ; column = 5 ; value ='1'; }
{kind = TOKEN_SEMICOLON; ; index = 59 ; length = 1 line = 4 ; column = 8 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 63 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
{kind = TOKEN_RIGHTBRACE; ; index = 66 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
{kind = TOKEN_EOF; ; index = 69 ; length = 0 line = 7 ; column = 0 ; value =''; }

View File

@@ -0,0 +1,23 @@
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
{kind = TOKEN_FLOATLITERAL; ; index = 27 ; length = 3 line = 2 ; column = 5 ; value ='0'; }
{kind = TOKEN_SEMICOLON; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value =';'; }
{kind = TOKEN_FOR; ; index = 34 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
{kind = TOKEN_COLON; ; index = 40 ; length = 1 line = 3 ; column = 6 ; value =':'; }
{kind = TOKEN_INTLITERAL; ; index = 42 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
{kind = TOKEN_DOTDOT; ; index = 43 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
{kind = TOKEN_INTLITERAL; ; index = 45 ; length = 2 line = 3 ; column = 11 ; value ='10'; }
{kind = TOKEN_IDENTIFIER; ; index = 48 ; length = 1 line = 3 ; column = 14 ; value ='x'; }
{kind = TOKEN_PLUSEQUALS; ; index = 50 ; length = 2 line = 3 ; column = 16 ; value ='+='; }
{kind = TOKEN_FLOATLITERAL; ; index = 53 ; length = 3 line = 3 ; column = 19 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 56 ; length = 1 line = 3 ; column = 22 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 59 ; length = 1 line = 4 ; column = 0 ; value ='}'; }
{kind = TOKEN_EOF; ; index = 62 ; length = 0 line = 5 ; column = 0 ; value =''; }

View File

@@ -0,0 +1,24 @@
{kind = TOKEN_VERTEX; ; index = 0 ; length = 6 line = 1 ; column = 0 ; value ='vertex'; }
{kind = TOKEN_IDENTIFIER; ; index = 7 ; length = 4 line = 1 ; column = 7 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 12 ; length = 2 line = 1 ; column = 12 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 15 ; length = 1 line = 1 ; column = 15 ; value ='('; }
{kind = TOKEN_RIGHTPAREN; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value =')'; }
{kind = TOKEN_LEFTBRACE; ; index = 18 ; length = 1 line = 1 ; column = 18 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 22 ; length = 1 line = 2 ; column = 0 ; value ='x'; }
{kind = TOKEN_COLON; ; index = 24 ; length = 1 line = 2 ; column = 2 ; value =':'; }
{kind = TOKEN_ASSIGN; ; index = 25 ; length = 1 line = 2 ; column = 3 ; value ='='; }
{kind = TOKEN_FLOATLITERAL; ; index = 27 ; length = 3 line = 2 ; column = 5 ; value ='0'; }
{kind = TOKEN_SEMICOLON; ; index = 30 ; length = 1 line = 2 ; column = 8 ; value =';'; }
{kind = TOKEN_FOR; ; index = 34 ; length = 3 line = 3 ; column = 0 ; value ='for'; }
{kind = TOKEN_IDENTIFIER; ; index = 38 ; length = 1 line = 3 ; column = 4 ; value ='i'; }
{kind = TOKEN_COLON; ; index = 40 ; length = 1 line = 3 ; column = 6 ; value =':'; }
{kind = TOKEN_INTLITERAL; ; index = 42 ; length = 1 line = 3 ; column = 8 ; value ='0'; }
{kind = TOKEN_DOTDOT; ; index = 43 ; length = 2 line = 3 ; column = 9 ; value ='..'; }
{kind = TOKEN_LEFTBRACE; ; index = 46 ; length = 1 line = 3 ; column = 12 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 51 ; length = 1 line = 4 ; column = 0 ; value ='x'; }
{kind = TOKEN_PLUSEQUALS; ; index = 53 ; length = 2 line = 4 ; column = 2 ; value ='+='; }
{kind = TOKEN_FLOATLITERAL; ; index = 56 ; length = 3 line = 4 ; column = 5 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 59 ; length = 1 line = 4 ; column = 8 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 63 ; length = 1 line = 5 ; column = 0 ; value ='}'; }
{kind = TOKEN_RIGHTBRACE; ; index = 66 ; length = 1 line = 6 ; column = 0 ; value ='}'; }
{kind = TOKEN_EOF; ; index = 69 ; length = 0 line = 7 ; column = 0 ; value =''; }

289
test/lex/large_block.golden Normal file
View File

@@ -0,0 +1,289 @@
{kind = TOKEN_IDENTIFIER; ; index = 0 ; length = 1 line = 1 ; column = 0 ; value ='p'; }
{kind = TOKEN_DOUBLECOLON; ; index = 2 ; length = 2 line = 1 ; column = 2 ; value ='::'; }
{kind = TOKEN_PROPERTIES; ; index = 5 ; length = 10 line = 1 ; column = 5 ; value ='properties'; }
{kind = TOKEN_LEFTBRACE; ; index = 16 ; length = 1 line = 1 ; column = 16 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 20 ; length = 5 line = 2 ; column = 0 ; value ='color'; }
{kind = TOKEN_COLON; ; index = 34 ; length = 1 line = 2 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 36 ; length = 6 line = 2 ; column = 16 ; value ='float4'; }
{kind = TOKEN_SEMICOLON; ; index = 42 ; length = 1 line = 2 ; column = 22 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 46 ; length = 13 line = 3 ; column = 0 ; value ='rect_position'; }
{kind = TOKEN_COLON; ; index = 60 ; length = 1 line = 3 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 62 ; length = 6 line = 3 ; column = 16 ; value ='float2'; }
{kind = TOKEN_SEMICOLON; ; index = 68 ; length = 1 line = 3 ; column = 22 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 72 ; length = 10 line = 4 ; column = 0 ; value ='rect_scale'; }
{kind = TOKEN_COLON; ; index = 86 ; length = 1 line = 4 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 88 ; length = 6 line = 4 ; column = 16 ; value ='float2'; }
{kind = TOKEN_SEMICOLON; ; index = 94 ; length = 1 line = 4 ; column = 22 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 98 ; length = 10 line = 5 ; column = 0 ; value ='resolution'; }
{kind = TOKEN_COLON; ; index = 112 ; length = 1 line = 5 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 114 ; length = 6 line = 5 ; column = 16 ; value ='float2'; }
{kind = TOKEN_SEMICOLON; ; index = 120 ; length = 1 line = 5 ; column = 22 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 124 ; length = 7 line = 6 ; column = 0 ; value ='texture'; }
{kind = TOKEN_COLON; ; index = 138 ; length = 1 line = 6 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 140 ; length = 9 line = 6 ; column = 16 ; value ='Texture2D'; }
{kind = TOKEN_SEMICOLON; ; index = 149 ; length = 1 line = 6 ; column = 25 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 153 ; length = 7 line = 7 ; column = 0 ; value ='sampler'; }
{kind = TOKEN_COLON; ; index = 167 ; length = 1 line = 7 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 169 ; length = 7 line = 7 ; column = 16 ; value ='Sampler'; }
{kind = TOKEN_SEMICOLON; ; index = 176 ; length = 1 line = 7 ; column = 23 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 179 ; length = 1 line = 8 ; column = 0 ; value ='}'; }
{kind = TOKEN_IDENTIFIER; ; index = 184 ; length = 8 line = 10 ; column = 0 ; value ='PS_Input'; }
{kind = TOKEN_DOUBLECOLON; ; index = 193 ; length = 2 line = 10 ; column = 9 ; value ='::'; }
{kind = TOKEN_STRUCT; ; index = 196 ; length = 6 line = 10 ; column = 12 ; value ='struct'; }
{kind = TOKEN_LEFTBRACE; ; index = 203 ; length = 1 line = 10 ; column = 19 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 207 ; length = 2 line = 11 ; column = 0 ; value ='uv'; }
{kind = TOKEN_COLON; ; index = 210 ; length = 1 line = 11 ; column = 3 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 212 ; length = 6 line = 11 ; column = 5 ; value ='float2'; }
{kind = TOKEN_AT; ; index = 219 ; length = 1 line = 11 ; column = 12 ; value ='@'; }
{kind = TOKEN_IDENTIFIER; ; index = 220 ; length = 2 line = 11 ; column = 13 ; value ='uv'; }
{kind = TOKEN_SEMICOLON; ; index = 222 ; length = 1 line = 11 ; column = 15 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 226 ; length = 3 line = 12 ; column = 0 ; value ='pos'; }
{kind = TOKEN_COLON; ; index = 230 ; length = 1 line = 12 ; column = 4 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 232 ; length = 6 line = 12 ; column = 6 ; value ='float4'; }
{kind = TOKEN_AT; ; index = 239 ; length = 1 line = 12 ; column = 13 ; value ='@'; }
{kind = TOKEN_IDENTIFIER; ; index = 240 ; length = 3 line = 12 ; column = 14 ; value ='pos'; }
{kind = TOKEN_SEMICOLON; ; index = 243 ; length = 1 line = 12 ; column = 17 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 246 ; length = 1 line = 13 ; column = 0 ; value ='}'; }
{kind = TOKEN_VERTEX; ; index = 251 ; length = 6 line = 15 ; column = 0 ; value ='vertex'; }
{kind = TOKEN_IDENTIFIER; ; index = 258 ; length = 4 line = 15 ; column = 7 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 263 ; length = 2 line = 15 ; column = 12 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 266 ; length = 1 line = 15 ; column = 15 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 267 ; length = 3 line = 15 ; column = 16 ; value ='pos'; }
{kind = TOKEN_COLON; ; index = 271 ; length = 1 line = 15 ; column = 20 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 273 ; length = 6 line = 15 ; column = 22 ; value ='float4'; }
{kind = TOKEN_AT; ; index = 280 ; length = 1 line = 15 ; column = 29 ; value ='@'; }
{kind = TOKEN_IDENTIFIER; ; index = 281 ; length = 8 line = 15 ; column = 30 ; value ='position'; }
{kind = TOKEN_RIGHTPAREN; ; index = 289 ; length = 1 line = 15 ; column = 38 ; value =')'; }
{kind = TOKEN_ARROW; ; index = 291 ; length = 2 line = 15 ; column = 40 ; value ='->'; }
{kind = TOKEN_IDENTIFIER; ; index = 294 ; length = 8 line = 15 ; column = 43 ; value ='PS_Input'; }
{kind = TOKEN_LEFTBRACE; ; index = 303 ; length = 1 line = 15 ; column = 52 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 307 ; length = 3 line = 16 ; column = 0 ; value ='res'; }
{kind = TOKEN_COLON; ; index = 316 ; length = 1 line = 16 ; column = 9 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 318 ; length = 6 line = 16 ; column = 11 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 325 ; length = 1 line = 16 ; column = 18 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 327 ; length = 1 line = 16 ; column = 20 ; value ='p'; }
{kind = TOKEN_DOT; ; index = 328 ; length = 1 line = 16 ; column = 21 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 329 ; length = 10 line = 16 ; column = 22 ; value ='resolution'; }
{kind = TOKEN_SEMICOLON; ; index = 339 ; length = 1 line = 16 ; column = 32 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 343 ; length = 5 line = 17 ; column = 0 ; value ='scale'; }
{kind = TOKEN_COLON; ; index = 352 ; length = 1 line = 17 ; column = 9 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 354 ; length = 6 line = 17 ; column = 11 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 361 ; length = 1 line = 17 ; column = 18 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 363 ; length = 1 line = 17 ; column = 20 ; value ='p'; }
{kind = TOKEN_DOT; ; index = 364 ; length = 1 line = 17 ; column = 21 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 365 ; length = 10 line = 17 ; column = 22 ; value ='rect_scale'; }
{kind = TOKEN_SEMICOLON; ; index = 375 ; length = 1 line = 17 ; column = 32 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 379 ; length = 8 line = 18 ; column = 0 ; value ='rect_pos'; }
{kind = TOKEN_COLON; ; index = 388 ; length = 1 line = 18 ; column = 9 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 390 ; length = 6 line = 18 ; column = 11 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 397 ; length = 1 line = 18 ; column = 18 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 399 ; length = 1 line = 18 ; column = 20 ; value ='p'; }
{kind = TOKEN_DOT; ; index = 400 ; length = 1 line = 18 ; column = 21 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 401 ; length = 13 line = 18 ; column = 22 ; value ='rect_position'; }
{kind = TOKEN_SEMICOLON; ; index = 414 ; length = 1 line = 18 ; column = 35 ; value =';'; }
{kind = TOKEN_SEMICOLON; ; index = 415 ; length = 1 line = 18 ; column = 36 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 421 ; length = 6 line = 20 ; column = 0 ; value ='center'; }
{kind = TOKEN_COLON; ; index = 428 ; length = 1 line = 20 ; column = 7 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 430 ; length = 6 line = 20 ; column = 9 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 437 ; length = 1 line = 20 ; column = 16 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 439 ; length = 8 line = 20 ; column = 18 ; value ='rect_pos'; }
{kind = TOKEN_SEMICOLON; ; index = 447 ; length = 1 line = 20 ; column = 26 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 451 ; length = 9 line = 21 ; column = 0 ; value ='half_size'; }
{kind = TOKEN_COLON; ; index = 462 ; length = 1 line = 21 ; column = 11 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 464 ; length = 6 line = 21 ; column = 13 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 471 ; length = 1 line = 21 ; column = 20 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 473 ; length = 6 line = 21 ; column = 22 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 479 ; length = 1 line = 21 ; column = 28 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 480 ; length = 5 line = 21 ; column = 29 ; value ='scale'; }
{kind = TOKEN_DOT; ; index = 485 ; length = 1 line = 21 ; column = 34 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 486 ; length = 1 line = 21 ; column = 35 ; value ='x'; }
{kind = TOKEN_SLASH; ; index = 488 ; length = 1 line = 21 ; column = 37 ; value ='/'; }
{kind = TOKEN_INTLITERAL; ; index = 490 ; length = 1 line = 21 ; column = 39 ; value ='2'; }
{kind = TOKEN_COMMA; ; index = 491 ; length = 1 line = 21 ; column = 40 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 493 ; length = 5 line = 21 ; column = 42 ; value ='scale'; }
{kind = TOKEN_DOT; ; index = 498 ; length = 1 line = 21 ; column = 47 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 499 ; length = 1 line = 21 ; column = 48 ; value ='y'; }
{kind = TOKEN_SLASH; ; index = 501 ; length = 1 line = 21 ; column = 50 ; value ='/'; }
{kind = TOKEN_INTLITERAL; ; index = 503 ; length = 1 line = 21 ; column = 52 ; value ='2'; }
{kind = TOKEN_RIGHTPAREN; ; index = 504 ; length = 1 line = 21 ; column = 53 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 505 ; length = 1 line = 21 ; column = 54 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 509 ; length = 7 line = 22 ; column = 0 ; value ='dst_pos'; }
{kind = TOKEN_COLON; ; index = 520 ; length = 1 line = 22 ; column = 11 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 522 ; length = 6 line = 22 ; column = 13 ; value ='float4'; }
{kind = TOKEN_ASSIGN; ; index = 529 ; length = 1 line = 22 ; column = 20 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 531 ; length = 6 line = 22 ; column = 22 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 537 ; length = 1 line = 22 ; column = 28 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 538 ; length = 3 line = 22 ; column = 29 ; value ='pos'; }
{kind = TOKEN_DOT; ; index = 541 ; length = 1 line = 22 ; column = 32 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 542 ; length = 1 line = 22 ; column = 33 ; value ='x'; }
{kind = TOKEN_STAR; ; index = 544 ; length = 1 line = 22 ; column = 35 ; value ='*'; }
{kind = TOKEN_IDENTIFIER; ; index = 546 ; length = 9 line = 22 ; column = 37 ; value ='half_size'; }
{kind = TOKEN_DOT; ; index = 555 ; length = 1 line = 22 ; column = 46 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 556 ; length = 1 line = 22 ; column = 47 ; value ='x'; }
{kind = TOKEN_PLUS; ; index = 558 ; length = 1 line = 22 ; column = 49 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 560 ; length = 6 line = 22 ; column = 51 ; value ='center'; }
{kind = TOKEN_DOT; ; index = 566 ; length = 1 line = 22 ; column = 57 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 567 ; length = 1 line = 22 ; column = 58 ; value ='x'; }
{kind = TOKEN_COMMA; ; index = 568 ; length = 1 line = 22 ; column = 59 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 570 ; length = 3 line = 22 ; column = 61 ; value ='pos'; }
{kind = TOKEN_DOT; ; index = 573 ; length = 1 line = 22 ; column = 64 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 574 ; length = 1 line = 22 ; column = 65 ; value ='y'; }
{kind = TOKEN_STAR; ; index = 576 ; length = 1 line = 22 ; column = 67 ; value ='*'; }
{kind = TOKEN_IDENTIFIER; ; index = 578 ; length = 9 line = 22 ; column = 69 ; value ='half_size'; }
{kind = TOKEN_DOT; ; index = 587 ; length = 1 line = 22 ; column = 78 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 588 ; length = 1 line = 22 ; column = 79 ; value ='y'; }
{kind = TOKEN_PLUS; ; index = 590 ; length = 1 line = 22 ; column = 81 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 592 ; length = 6 line = 22 ; column = 83 ; value ='center'; }
{kind = TOKEN_DOT; ; index = 598 ; length = 1 line = 22 ; column = 89 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 599 ; length = 1 line = 22 ; column = 90 ; value ='y'; }
{kind = TOKEN_COMMA; ; index = 600 ; length = 1 line = 22 ; column = 91 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 602 ; length = 3 line = 22 ; column = 93 ; value ='0'; }
{kind = TOKEN_COMMA; ; index = 605 ; length = 1 line = 22 ; column = 96 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 607 ; length = 3 line = 22 ; column = 98 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 610 ; length = 1 line = 22 ; column = 101 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 611 ; length = 1 line = 22 ; column = 102 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 617 ; length = 6 line = 24 ; column = 0 ; value ='result'; }
{kind = TOKEN_COLON; ; index = 624 ; length = 1 line = 24 ; column = 7 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 626 ; length = 8 line = 24 ; column = 9 ; value ='PS_Input'; }
{kind = TOKEN_SEMICOLON; ; index = 634 ; length = 1 line = 24 ; column = 17 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 640 ; length = 6 line = 26 ; column = 0 ; value ='src_p0'; }
{kind = TOKEN_COLON; ; index = 647 ; length = 1 line = 26 ; column = 7 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 649 ; length = 6 line = 26 ; column = 9 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 656 ; length = 1 line = 26 ; column = 16 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 658 ; length = 6 line = 26 ; column = 18 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 664 ; length = 1 line = 26 ; column = 24 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 665 ; length = 3 line = 26 ; column = 25 ; value ='0'; }
{kind = TOKEN_COMMA; ; index = 668 ; length = 1 line = 26 ; column = 28 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 670 ; length = 3 line = 26 ; column = 30 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 673 ; length = 1 line = 26 ; column = 33 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 674 ; length = 1 line = 26 ; column = 34 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 678 ; length = 6 line = 27 ; column = 0 ; value ='src_p1'; }
{kind = TOKEN_COLON; ; index = 685 ; length = 1 line = 27 ; column = 7 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 687 ; length = 6 line = 27 ; column = 9 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 694 ; length = 1 line = 27 ; column = 16 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 696 ; length = 6 line = 27 ; column = 18 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 702 ; length = 1 line = 27 ; column = 24 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 703 ; length = 3 line = 27 ; column = 25 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 706 ; length = 1 line = 27 ; column = 28 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 708 ; length = 3 line = 27 ; column = 30 ; value ='0'; }
{kind = TOKEN_RIGHTPAREN; ; index = 711 ; length = 1 line = 27 ; column = 33 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 712 ; length = 1 line = 27 ; column = 34 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 718 ; length = 13 line = 29 ; column = 0 ; value ='src_half_size'; }
{kind = TOKEN_COLON; ; index = 732 ; length = 1 line = 29 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 734 ; length = 6 line = 29 ; column = 16 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 741 ; length = 1 line = 29 ; column = 23 ; value ='='; }
{kind = TOKEN_LEFTPAREN; ; index = 743 ; length = 1 line = 29 ; column = 25 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 744 ; length = 6 line = 29 ; column = 26 ; value ='src_p1'; }
{kind = TOKEN_MINUS; ; index = 751 ; length = 1 line = 29 ; column = 33 ; value ='-'; }
{kind = TOKEN_IDENTIFIER; ; index = 753 ; length = 6 line = 29 ; column = 35 ; value ='src_p0'; }
{kind = TOKEN_RIGHTPAREN; ; index = 759 ; length = 1 line = 29 ; column = 41 ; value =')'; }
{kind = TOKEN_SLASH; ; index = 761 ; length = 1 line = 29 ; column = 43 ; value ='/'; }
{kind = TOKEN_INTLITERAL; ; index = 763 ; length = 1 line = 29 ; column = 45 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 764 ; length = 1 line = 29 ; column = 46 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 768 ; length = 10 line = 30 ; column = 0 ; value ='src_center'; }
{kind = TOKEN_COLON; ; index = 782 ; length = 1 line = 30 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 784 ; length = 6 line = 30 ; column = 16 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 791 ; length = 1 line = 30 ; column = 23 ; value ='='; }
{kind = TOKEN_LEFTPAREN; ; index = 793 ; length = 1 line = 30 ; column = 25 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 794 ; length = 6 line = 30 ; column = 26 ; value ='src_p1'; }
{kind = TOKEN_PLUS; ; index = 801 ; length = 1 line = 30 ; column = 33 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 803 ; length = 6 line = 30 ; column = 35 ; value ='src_p0'; }
{kind = TOKEN_RIGHTPAREN; ; index = 809 ; length = 1 line = 30 ; column = 41 ; value =')'; }
{kind = TOKEN_SLASH; ; index = 811 ; length = 1 line = 30 ; column = 43 ; value ='/'; }
{kind = TOKEN_INTLITERAL; ; index = 813 ; length = 1 line = 30 ; column = 45 ; value ='2'; }
{kind = TOKEN_SEMICOLON; ; index = 814 ; length = 1 line = 30 ; column = 46 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 818 ; length = 7 line = 31 ; column = 0 ; value ='src_pos'; }
{kind = TOKEN_COLON; ; index = 832 ; length = 1 line = 31 ; column = 14 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 834 ; length = 6 line = 31 ; column = 16 ; value ='float2'; }
{kind = TOKEN_ASSIGN; ; index = 841 ; length = 1 line = 31 ; column = 23 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 843 ; length = 6 line = 31 ; column = 25 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 849 ; length = 1 line = 31 ; column = 31 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 850 ; length = 3 line = 31 ; column = 32 ; value ='pos'; }
{kind = TOKEN_DOT; ; index = 853 ; length = 1 line = 31 ; column = 35 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 854 ; length = 1 line = 31 ; column = 36 ; value ='x'; }
{kind = TOKEN_COMMA; ; index = 855 ; length = 1 line = 31 ; column = 37 ; value =','; }
{kind = TOKEN_IDENTIFIER; ; index = 857 ; length = 3 line = 31 ; column = 39 ; value ='pos'; }
{kind = TOKEN_DOT; ; index = 860 ; length = 1 line = 31 ; column = 42 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 861 ; length = 1 line = 31 ; column = 43 ; value ='y'; }
{kind = TOKEN_RIGHTPAREN; ; index = 862 ; length = 1 line = 31 ; column = 44 ; value =')'; }
{kind = TOKEN_STAR; ; index = 864 ; length = 1 line = 31 ; column = 46 ; value ='*'; }
{kind = TOKEN_IDENTIFIER; ; index = 866 ; length = 13 line = 31 ; column = 48 ; value ='src_half_size'; }
{kind = TOKEN_PLUS; ; index = 880 ; length = 1 line = 31 ; column = 62 ; value ='+'; }
{kind = TOKEN_IDENTIFIER; ; index = 882 ; length = 10 line = 31 ; column = 64 ; value ='src_center'; }
{kind = TOKEN_SEMICOLON; ; index = 892 ; length = 1 line = 31 ; column = 74 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 898 ; length = 6 line = 33 ; column = 0 ; value ='result'; }
{kind = TOKEN_DOT; ; index = 904 ; length = 1 line = 33 ; column = 6 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 905 ; length = 2 line = 33 ; column = 7 ; value ='uv'; }
{kind = TOKEN_ASSIGN; ; index = 908 ; length = 1 line = 33 ; column = 10 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 910 ; length = 6 line = 33 ; column = 12 ; value ='float2'; }
{kind = TOKEN_LEFTPAREN; ; index = 916 ; length = 1 line = 33 ; column = 18 ; value ='('; }
{kind = TOKEN_INTLITERAL; ; index = 917 ; length = 1 line = 33 ; column = 19 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 918 ; length = 1 line = 33 ; column = 20 ; value =','; }
{kind = TOKEN_INTLITERAL; ; index = 920 ; length = 1 line = 33 ; column = 22 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 921 ; length = 1 line = 33 ; column = 23 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 922 ; length = 1 line = 33 ; column = 24 ; value =';'; }
{kind = TOKEN_IDENTIFIER; ; index = 926 ; length = 6 line = 34 ; column = 0 ; value ='result'; }
{kind = TOKEN_DOT; ; index = 932 ; length = 1 line = 34 ; column = 6 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 933 ; length = 3 line = 34 ; column = 7 ; value ='pos'; }
{kind = TOKEN_ASSIGN; ; index = 937 ; length = 1 line = 34 ; column = 11 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 939 ; length = 6 line = 34 ; column = 13 ; value ='float4'; }
{kind = TOKEN_LEFTPAREN; ; index = 945 ; length = 1 line = 34 ; column = 19 ; value ='('; }
{kind = TOKEN_FLOATLITERAL; ; index = 946 ; length = 3 line = 34 ; column = 20 ; value ='2'; }
{kind = TOKEN_STAR; ; index = 950 ; length = 1 line = 34 ; column = 24 ; value ='*'; }
{kind = TOKEN_IDENTIFIER; ; index = 952 ; length = 7 line = 34 ; column = 26 ; value ='dst_pos'; }
{kind = TOKEN_DOT; ; index = 959 ; length = 1 line = 34 ; column = 33 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 960 ; length = 1 line = 34 ; column = 34 ; value ='x'; }
{kind = TOKEN_SLASH; ; index = 962 ; length = 1 line = 34 ; column = 36 ; value ='/'; }
{kind = TOKEN_IDENTIFIER; ; index = 964 ; length = 3 line = 34 ; column = 38 ; value ='res'; }
{kind = TOKEN_DOT; ; index = 967 ; length = 1 line = 34 ; column = 41 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 968 ; length = 1 line = 34 ; column = 42 ; value ='x'; }
{kind = TOKEN_MINUS; ; index = 970 ; length = 1 line = 34 ; column = 44 ; value ='-'; }
{kind = TOKEN_INTLITERAL; ; index = 972 ; length = 1 line = 34 ; column = 46 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 973 ; length = 1 line = 34 ; column = 47 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 975 ; length = 3 line = 34 ; column = 49 ; value ='2'; }
{kind = TOKEN_STAR; ; index = 979 ; length = 1 line = 34 ; column = 53 ; value ='*'; }
{kind = TOKEN_IDENTIFIER; ; index = 981 ; length = 7 line = 34 ; column = 55 ; value ='dst_pos'; }
{kind = TOKEN_DOT; ; index = 988 ; length = 1 line = 34 ; column = 62 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 989 ; length = 1 line = 34 ; column = 63 ; value ='y'; }
{kind = TOKEN_SLASH; ; index = 991 ; length = 1 line = 34 ; column = 65 ; value ='/'; }
{kind = TOKEN_IDENTIFIER; ; index = 993 ; length = 3 line = 34 ; column = 67 ; value ='res'; }
{kind = TOKEN_DOT; ; index = 996 ; length = 1 line = 34 ; column = 70 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 997 ; length = 1 line = 34 ; column = 71 ; value ='y'; }
{kind = TOKEN_MINUS; ; index = 999 ; length = 1 line = 34 ; column = 73 ; value ='-'; }
{kind = TOKEN_INTLITERAL; ; index = 1001 ; length = 1 line = 34 ; column = 75 ; value ='1'; }
{kind = TOKEN_COMMA; ; index = 1002 ; length = 1 line = 34 ; column = 76 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 1004 ; length = 3 line = 34 ; column = 78 ; value ='0'; }
{kind = TOKEN_COMMA; ; index = 1007 ; length = 1 line = 34 ; column = 81 ; value =','; }
{kind = TOKEN_FLOATLITERAL; ; index = 1009 ; length = 3 line = 34 ; column = 83 ; value ='1'; }
{kind = TOKEN_RIGHTPAREN; ; index = 1012 ; length = 1 line = 34 ; column = 86 ; value =')'; }
{kind = TOKEN_SEMICOLON; ; index = 1013 ; length = 1 line = 34 ; column = 87 ; value =';'; }
{kind = TOKEN_RETURN; ; index = 1019 ; length = 6 line = 36 ; column = 0 ; value ='return'; }
{kind = TOKEN_IDENTIFIER; ; index = 1026 ; length = 6 line = 36 ; column = 7 ; value ='result'; }
{kind = TOKEN_SEMICOLON; ; index = 1032 ; length = 1 line = 36 ; column = 13 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 1035 ; length = 1 line = 37 ; column = 0 ; value ='}'; }
{kind = TOKEN_PIXEL; ; index = 1040 ; length = 5 line = 39 ; column = 0 ; value ='pixel'; }
{kind = TOKEN_IDENTIFIER; ; index = 1046 ; length = 4 line = 39 ; column = 6 ; value ='main'; }
{kind = TOKEN_DOUBLECOLON; ; index = 1051 ; length = 2 line = 39 ; column = 11 ; value ='::'; }
{kind = TOKEN_LEFTPAREN; ; index = 1054 ; length = 1 line = 39 ; column = 14 ; value ='('; }
{kind = TOKEN_IDENTIFIER; ; index = 1055 ; length = 5 line = 39 ; column = 15 ; value ='input'; }
{kind = TOKEN_COLON; ; index = 1061 ; length = 1 line = 39 ; column = 21 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 1063 ; length = 8 line = 39 ; column = 23 ; value ='PS_Input'; }
{kind = TOKEN_RIGHTPAREN; ; index = 1071 ; length = 1 line = 39 ; column = 31 ; value =')'; }
{kind = TOKEN_ARROW; ; index = 1073 ; length = 2 line = 39 ; column = 33 ; value ='->'; }
{kind = TOKEN_IDENTIFIER; ; index = 1076 ; length = 6 line = 39 ; column = 36 ; value ='float4'; }
{kind = TOKEN_AT; ; index = 1083 ; length = 1 line = 39 ; column = 43 ; value ='@'; }
{kind = TOKEN_IDENTIFIER; ; index = 1084 ; length = 7 line = 39 ; column = 44 ; value ='target0'; }
{kind = TOKEN_LEFTBRACE; ; index = 1092 ; length = 1 line = 39 ; column = 52 ; value ='{'; }
{kind = TOKEN_IDENTIFIER; ; index = 1096 ; length = 5 line = 40 ; column = 0 ; value ='color'; }
{kind = TOKEN_COLON; ; index = 1102 ; length = 1 line = 40 ; column = 6 ; value =':'; }
{kind = TOKEN_IDENTIFIER; ; index = 1104 ; length = 6 line = 40 ; column = 8 ; value ='float4'; }
{kind = TOKEN_ASSIGN; ; index = 1111 ; length = 1 line = 40 ; column = 15 ; value ='='; }
{kind = TOKEN_IDENTIFIER; ; index = 1113 ; length = 1 line = 40 ; column = 17 ; value ='p'; }
{kind = TOKEN_DOT; ; index = 1114 ; length = 1 line = 40 ; column = 18 ; value ='.'; }
{kind = TOKEN_IDENTIFIER; ; index = 1115 ; length = 5 line = 40 ; column = 19 ; value ='color'; }
{kind = TOKEN_SEMICOLON; ; index = 1120 ; length = 1 line = 40 ; column = 24 ; value =';'; }
{kind = TOKEN_RETURN; ; index = 1124 ; length = 6 line = 41 ; column = 0 ; value ='return'; }
{kind = TOKEN_IDENTIFIER; ; index = 1131 ; length = 5 line = 41 ; column = 7 ; value ='color'; }
{kind = TOKEN_SEMICOLON; ; index = 1136 ; length = 1 line = 41 ; column = 12 ; value =';'; }
{kind = TOKEN_RIGHTBRACE; ; index = 1139 ; length = 1 line = 42 ; column = 0 ; value ='}'; }
{kind = TOKEN_EOF; ; index = 1142 ; length = 0 line = 43 ; column = 0 ; value =''; }

BIN
test/lex/load_test.golden Normal file

Binary file not shown.

View File

@@ -1,5 +1,6 @@
test/assign_arithmetic_expression.ink lex test/assign_arithmetic_expression.ink lex
test/basic_property_and_return_value.ink lex test/basic_property_and_return_value.ink lex
test/builtin_types.ink lex
test/complicated_computation.ink lex test/complicated_computation.ink lex
test/constant_buffer.ink lex test/constant_buffer.ink lex
test/else_if_after_else.ink lex test/else_if_after_else.ink lex
@@ -10,6 +11,9 @@ test/field_assignment.ink lex
test/field_without_type_specifier.ink lex test/field_without_type_specifier.ink lex
test/float_suffix.ink lex test/float_suffix.ink lex
test/float_if_cond.ink lex test/float_if_cond.ink lex
test/for_i_loop.ink lex
test/for_i_one_liner.ink lex
test/for_no_iter.ink lex
test/function_call.ink lex test/function_call.ink lex
test/function_call_out_of_order_declaration.ink lex test/function_call_out_of_order_declaration.ink lex
test/function_call_return.ink lex test/function_call_return.ink lex
@@ -18,6 +22,7 @@ test/function_with_int_return.ink lex
test/if_cond_assign.ink lex test/if_cond_assign.ink lex
test/if_if_if.ink lex test/if_if_if.ink lex
test/inferred_types.ink lex test/inferred_types.ink lex
test/large_block.ink lex
test/meta_block.ink lex test/meta_block.ink lex
test/multiple_functions.ink lex test/multiple_functions.ink lex
test/multiple_semicolons_everywhere.ink lex test/multiple_semicolons_everywhere.ink lex

5
test/load_test.ink Normal file
View File

@@ -0,0 +1,5 @@
#load "some_file.ink";
vertex main :: () {
v2 : float2 = float2(2.0, 2.0);
}

View File

@@ -0,0 +1,27 @@
(program
(fun vertex vs_main
[]
(:= v2 float2 (float2 2 2))
(= v2 (float2 2))
(= v2 (float2 v2))
(:= v3 float3 (float3 2 2 2))
(= v3 (float3 v2 1))
(= v3 (float3 1 v2))
(= v3 (float3 1))
(= v3 (float3 v3))
(:= v4 float4 (float4 2 2 2 2))
(= v4 (float4 v4))
(= v4 (float4 v2 v2))
(= v4 (float4 v2 1 1))
(= v4 (float4 1 v2 1))
(= v4 (float4 1 1 v2))
(= v4 (float4 v3 2))
(= v4 (float4 2 v3))
(= v4 (float4 2))
(= v4 (float4 1 1 v2))
(= v4 (float4 2))
(= v2.x 2)
(= v2.y 2)
(:= p (+ v2.x v3.z))
(:= q (+ v4.w v2.x))
(:= m float4x4)))

View File

@@ -0,0 +1,6 @@
(program
(fun vertex vs_main
[]
(:= x 0)
(for i : 0..10
(+= x 1))))

View File

@@ -0,0 +1,4 @@
test/for_i_one_liner.ink:3,0: error: Unable to parse statement here. 'for' currently expects a brace-enclosed block as a body.
for i : 0..10 x += 2.0;
^^^


View File

@@ -0,0 +1,9 @@
test/for_no_iter.ink:3,9: error: Expected expression after '..'. Expected end of iterator.
for i : 0.. {
x += 2.0;
^^
test/for_no_iter.ink:3,0: error: Unable to parse statement here.
for i : 0.. {
x += 2.0;
^^^


View File

@@ -1,4 +1,4 @@
test/if_if_if.ink:2,3: error: Expected expression after 'if'. test/if_if_if.ink:2,0: error: Expected expression after 'if'. Expected if condition.
if if if 0 > 100 { if if if 0 > 100 {
^^ ^^
 

View File

@@ -0,0 +1,35 @@
(program
(properties p
[(:= color float4)
(:= rect_position float2)
(:= rect_scale float2)
(:= resolution float2)
(:= texture Texture2D)
(:= sampler Sampler)])
(struct PS_Input
[(:= uv float2 (@uv))
(:= pos float4 (@pos))])
(fun vertex vs_main -> PS_Input
[(:= pos float4 (@position))]
(:= res float2 p.resolution)
(:= scale float2 p.rect_scale)
(:= rect_pos float2 p.rect_position)
(:= center float2 rect_pos)
(:= half_size float2 (float2 (/ scale.x 2) (/ scale.y 2)))
(:= dst_pos float4 (float4 (+ (* pos.x half_size.x) center.x) (+ (* pos.y half_size.y) center.y) 0 1))
(:= result PS_Input)
(:= src_p0 float2 (float2 0 1))
(:= src_p1 float2 (float2 1 0))
(:= src_half_size float2 (/ (- src_p1 src_p0) 2))
(:= src_center float2 (/ (+ src_p1 src_p0) 2))
(:= src_pos float2 (+ (* (float2 pos.x pos.y) src_half_size) src_center))
(= result.uv (float2 1 1))
(= result.pos (float4 (- (/ (* 2 dst_pos.x) res.x) 1) (- (/ (* 2 dst_pos.y) res.y) 1) 0 1))
(return result))
(fun pixel ps_main -> float4 (@target0)
[(:= input PS_Input)]
(:= color float4 p.color)
(return color)))

View File

@@ -1,5 +1,6 @@
test/assign_arithmetic_expression.ink parse test/assign_arithmetic_expression.ink parse
test/basic_property_and_return_value.ink parse test/basic_property_and_return_value.ink parse
test/builtin_types.ink parse
test/complicated_computation.ink parse test/complicated_computation.ink parse
test/constant_buffer.ink parse test/constant_buffer.ink parse
test/else_if_after_else.ink parse test/else_if_after_else.ink parse
@@ -10,6 +11,9 @@ test/field_assignment.ink parse
test/field_without_type_specifier.ink parse test/field_without_type_specifier.ink parse
test/float_if_cond.ink parse test/float_if_cond.ink parse
test/float_suffix.ink parse test/float_suffix.ink parse
test/for_i_loop.ink parse
test/for_i_one_liner.ink parse
test/for_no_iter.ink parse
test/function_call.ink parse test/function_call.ink parse
test/function_call_out_of_order_declaration.ink parse test/function_call_out_of_order_declaration.ink parse
test/function_call_return.ink parse test/function_call_return.ink parse
@@ -18,6 +22,7 @@ test/function_with_int_return.ink parse
test/if_cond_assign.ink parse test/if_cond_assign.ink parse
test/if_if_if.ink parse test/if_if_if.ink parse
test/inferred_types.ink parse test/inferred_types.ink parse
test/large_block.ink parse
test/meta_block.ink parse test/meta_block.ink parse
test/multiple_functions.ink parse test/multiple_functions.ink parse
test/multiple_semicolons_everywhere.ink parse test/multiple_semicolons_everywhere.ink parse

View File

@@ -1,7 +1,7 @@
scope (global) [ scope (global) [
[properties] : {color : float4}
[pixel__ps_main] : () -> float4 [pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float3) -> float3 [vertex__vs_main] : (pos : float3) -> float3
[properties] : {color : float4}
scope (properties) [ scope (properties) [
[color] : float4 [color] : float4
] ]

View File

@@ -0,0 +1,11 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[v2] : float2
[v4] : float4
[v3] : float3
[p] : float
[m] : float4x4
[q] : float
]
]

View File

@@ -1,7 +1,7 @@
scope (global) [ scope (global) [
[camera] : {projection : float4x4, view : float4x4}
[pixel__ps_main] : () -> float4 [pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float4) -> float4 [vertex__vs_main] : (pos : float4) -> float4
[camera] : {projection : float4x4, view : float4x4}
scope (camera) [ scope (camera) [
[projection] : float4x4 [projection] : float4x4
[view] : float4x4 [view] : float4x4

View File

@@ -0,0 +1,7 @@
scope (global) [
[vertex__vs_main] : ()
scope (vertex__vs_main) [
[i] : int
[x] : int
]
]

View File

@@ -1,7 +1,7 @@
scope (global) [ scope (global) [
[props] : {color : float4}
[pixel__ps_main] : () -> float4 [pixel__ps_main] : () -> float4
[vertex__vs_main] : (pos : float4) -> float4 [vertex__vs_main] : (pos : float4) -> float4
[props] : {color : float4}
scope (props) [ scope (props) [
[color] : float4 [color] : float4
] ]

View File

@@ -7,20 +7,15 @@
 result : float4 = float4(1.0, foo * res, 0.0, 1.0);  result : float4 = float4(1.0, foo * res, 0.0, 1.0);
^ ^
 Possible overloads:  Possible overloads:
 foreign float4 :: (float, float, float, float) -> float4; (test/wrong_multiply.ink:86)  float4 :: (float, float, float, float); (test/wrong_multiply.ink:0)
 foreign float4 :: (float4) -> float4; (test/wrong_multiply.ink:87)  float4 :: (float2, float2); (test/wrong_multiply.ink:0)
 foreign float4 :: (float2, float2) -> float4; (test/wrong_multiply.ink:88)  float4 :: (float2, float, float); (test/wrong_multiply.ink:0)
 foreign float4 :: (float2, float, float) -> float4; (test/wrong_multiply.ink:89)  float4 :: (float, float2, float); (test/wrong_multiply.ink:0)
 foreign float4 :: (float, float2, float) -> float4; (test/wrong_multiply.ink:90)  float4 :: (float, float, float2); (test/wrong_multiply.ink:0)
 foreign float4 :: (float, float2, float) -> float4; (test/wrong_multiply.ink:90)  float4 :: (float, float3); (test/wrong_multiply.ink:0)
 foreign float4 :: (float, float, float2) -> float4; (test/wrong_multiply.ink:91)  float4 :: (float3, float); (test/wrong_multiply.ink:0)
 foreign float4 :: (float, float, float2) -> float4; (test/wrong_multiply.ink:91)  float4 :: (float4); (test/wrong_multiply.ink:0)
 foreign float4 :: (float3, float) -> float4; (test/wrong_multiply.ink:92)  float4 :: (float); (test/wrong_multiply.ink:0)
 foreign float4 :: (float3, float) -> float4; (test/wrong_multiply.ink:92)
 foreign float4 :: (float, float3) -> float4; (test/wrong_multiply.ink:93)
 foreign float4 :: (float, float3) -> float4; (test/wrong_multiply.ink:93)
 foreign float4 :: (float) -> float4; (test/wrong_multiply.ink:94)
 foreign float4 :: (float) -> float4; (test/wrong_multiply.ink:94)
test/wrong_multiply.ink:4,34: error: Type mismatch. Expected float got float2 test/wrong_multiply.ink:4,34: error: Type mismatch. Expected float got float2
 found:  found:

View File

@@ -7,20 +7,15 @@
 color : float4 = float4(y, 1.0, 1.0, 1.0);  color : float4 = float4(y, 1.0, 1.0, 1.0);
^ ^
 Possible overloads:  Possible overloads:
 foreign float4 :: (float, float, float, float) -> float4; (test/wrong_type_for_function.ink:86)  float4 :: (float, float, float, float); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float4) -> float4; (test/wrong_type_for_function.ink:87)  float4 :: (float2, float2); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float2, float2) -> float4; (test/wrong_type_for_function.ink:88)  float4 :: (float2, float, float); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float2, float, float) -> float4; (test/wrong_type_for_function.ink:89)  float4 :: (float, float2, float); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float, float2, float) -> float4; (test/wrong_type_for_function.ink:90)  float4 :: (float, float, float2); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float, float2, float) -> float4; (test/wrong_type_for_function.ink:90)  float4 :: (float, float3); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float, float, float2) -> float4; (test/wrong_type_for_function.ink:91)  float4 :: (float3, float); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float, float, float2) -> float4; (test/wrong_type_for_function.ink:91)  float4 :: (float4); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float3, float) -> float4; (test/wrong_type_for_function.ink:92)  float4 :: (float); (test/wrong_type_for_function.ink:0)
 foreign float4 :: (float3, float) -> float4; (test/wrong_type_for_function.ink:92)
 foreign float4 :: (float, float3) -> float4; (test/wrong_type_for_function.ink:93)
 foreign float4 :: (float, float3) -> float4; (test/wrong_type_for_function.ink:93)
 foreign float4 :: (float) -> float4; (test/wrong_type_for_function.ink:94)
 foreign float4 :: (float) -> float4; (test/wrong_type_for_function.ink:94)
test/wrong_type_for_function.ink:11,24: error: Type mismatch. Expected float got float2 test/wrong_type_for_function.ink:11,24: error: Type mismatch. Expected float got float2
 found:  found:

View File

@@ -1,12 +1,13 @@
test/assign_arithmetic_expression.ink semant test/assign_arithmetic_expression.ink semant
test/basic_property_and_return_value.ink semant test/basic_property_and_return_value.ink semant
test/builtin_types.ink semant
test/complicated_computation.ink semant test/complicated_computation.ink semant
test/constant_buffer.ink semant test/constant_buffer.ink semant
test/empty_struct.ink semant test/empty_struct.ink semant
test/empty_vertex_main.ink semant test/empty_vertex_main.ink semant
test/empty_vertex_main_with_position_parameter.ink semant test/empty_vertex_main_with_position_parameter.ink semant
test/field_assignment.ink semant test/field_assignment.ink semant
test/for_i_loop.ink semant
test/function_call.ink semant test/function_call.ink semant
test/function_call_out_of_order_declaration.ink semant test/function_call_out_of_order_declaration.ink semant
test/function_call_return.ink semant test/function_call_return.ink semant