A bunch of new allocation related stuff.

This commit is contained in:
2025-09-10 06:59:29 +02:00
parent f4a9592f26
commit ceafd197f5
18 changed files with 852 additions and 170 deletions

View File

@@ -628,19 +628,31 @@ emit_declaration :: (state : *Codegen_State, node : *AST_Node) {
}
codegen :: (result : *Compile_Result) {
codegen(result, .HLSL);
}
codegen :: (result : *Compile_Result, output_language : Output_Language, allocator := temp) {
if result.had_error {
return;
}
state : Codegen_State;
state.result = result;
state.current_scope = cast(Scope_Handle)1;
state.output_language = .HLSL;
init_string_builder(*state.builder);
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
codegen(*state);
state : Codegen_State;
state.result = result;
state.current_scope = cast(Scope_Handle)1;
state.output_language = output_language;
init_string_builder(*state.builder);
codegen(*state);
}
}
#scope_file
codegen :: (state : *Codegen_State) {
found_function : bool = false;
// found_struct : bool = false;
@@ -679,15 +691,5 @@ codegen :: (state : *Codegen_State) {
state.result.codegen_result_text = builder_to_string(*state.builder);
}
codegen :: (result : *Compile_Result, output_language : Output_Language) {
codegen_state : Codegen_State;
codegen_state.result = result;
codegen_state.current_scope = cast(Scope_Handle)1;
codegen_state.output_language = output_language;
init_string_builder(*codegen_state.builder);
codegen(*codegen_state);
}
#scope_module
#import "ncore";

76
Ink.jai
View File

@@ -72,9 +72,11 @@ Test_Suite :: struct {
results : [..]Result;
}
get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := context.allocator) -> string {
path := parse_path(file_path);
file_without_extension := split(path.words[path.words.count - 1], ".");
get_golden_path :: (file_path : string, stage : Stage_Flags) -> string {
sc := get_scratch();
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.allocator = temp;
@@ -82,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
path.words.count -= 1;
path.words.allocator = sc.allocator;
if stage == {
case .Lexer; {
@@ -112,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);
builder.allocator = sc.allocator;
append(*builder, file_without_extension[0]);
append(*builder, ".");
append(*builder, GOLDEN_EXTENSION);
golden_path := builder_to_string(*builder);
golden_path := builder_to_string(*builder,, sc.allocator);
array_add(*path.words, golden_path);
final_path := path_to_string(path);
@@ -124,6 +128,8 @@ get_golden_path :: (file_path : string, stage : Stage_Flags, allocator := contex
}
do_golden_comparison :: (golden_path : string, comparison_text : string, result_data : *Result, output_type : Output_Type) {
sc := get_scratch();
defer scratch_end(sc);
if output_type & .Golden {
// Output the comparison file
write_entire_file(golden_path, comparison_text);
@@ -138,15 +144,15 @@ do_golden_comparison :: (golden_path : string, comparison_text : string, result_
return;
}
golden_text, ok := read_entire_file(golden_path);
golden_text, ok := read_entire_file(golden_path,, sc.allocator);
if !ok {
result_data.info_text = tprint("Unable to open golden file %\n", golden_path);
result_data.type = .Golden_File_Not_Found;
return;
}
comp := replace(comparison_text, "\r\n", "\n");
gold := replace(golden_text, "\r\n", "\n");
comp := replace(comparison_text, "\r\n", "\n",, sc.allocator);
gold := replace(golden_text, "\r\n", "\n",, sc.allocator);
result := compare(comp, gold) == 0;
if !result {
result_data.type = .Failed;
@@ -314,7 +320,7 @@ run_semantic_analysis_test :: (result : *Compile_Result, output_type : Output_Ty
}
run_semantic_analysis_test :: (file_path : string, result : *Compile_Result, output_type : Output_Type = 0) -> Result {
result.file = make_file(result, file_path);
result.file = make_file(result, file_path,, result.allocator);
result.allocator = make_arena(Megabytes(128));
result_data : Result;
@@ -344,8 +350,8 @@ make_test_case :: (path : string, stage_flags : Stage_Flags, allocator := contex
run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]Result, output_type : Output_Type = 0) {
compile_result : Compile_Result;
compile_result.file = make_file(*compile_result, file_path);
compile_result.allocator = make_arena(Megabytes(128));
compile_result.file = make_file(*compile_result, file_path,, compile_result.allocator);
result : Result;
if stage_flags & .Lexer {
@@ -404,7 +410,6 @@ run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_
}
run_test_new(test_case.path, test_case.stage_flags, results, output_type);
// run_test(test_case.path, test_case.stage_flags, results, output_type);
}
record_result :: (results : *[..]Result, result : Result) {
@@ -472,23 +477,25 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
}
}
print("%\n", builder_to_string(*builder));
print("%\n", builder_to_string(*builder,, temp));
}
read_suite :: (file_path : string, suite : *Test_Suite) -> 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 {
log_error("Unable to read suite file %\n", file_path);
return false;
}
path := parse_path(file_path);
file_without_extension := split(path.words[path.words.count - 1], ".");
suite.name = copy_string(file_without_extension[0]);
split_lines := split(bytes, "\n");
path := parse_path(file_path,, sc.allocator);
file_without_extension := split(path.words[path.words.count - 1], ".",, sc.allocator);
suite.name = copy_string(file_without_extension[0],, temp);
split_lines := split(bytes, "\n",, sc.allocator);
for split_line : split_lines {
line := split(split_line, " ");
line := split(split_line, " ",, sc.allocator);
if line[0].count == 0 {
continue;
}
@@ -498,7 +505,7 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
}
if line.count == 1 {
line = split(split_line, "\t");
line = split(split_line, "\t",, sc.allocator);
if line.count == 1 {
log_error("Invalid line - % - \n", it_index + 1);
continue;
@@ -521,7 +528,7 @@ read_suite :: (file_path : string, suite : *Test_Suite) -> bool {
stage_flags |= .Compile;
}
}
test_case := make_test_case(test_case_path, stage_flags);
test_case := make_test_case(test_case_path, stage_flags, temp);
array_add(*suite.test_cases, test_case);
}
@@ -584,7 +591,10 @@ evaluate_result :: (result : Result) {
main :: () {
args := get_command_line_arguments();
init_context_allocators();
suites : [..]Test_Suite;
suites.allocator = temp;
output_type : Output_Type = 0;
Argument_Parse_State :: enum {
@@ -597,6 +607,8 @@ main :: () {
arg_parse_state : Argument_Parse_State;
current_suite : *Test_Suite;
local_temp := make_arena(Megabytes(128));
path : string;
for i: 1..args.count - 1 {
@@ -632,12 +644,14 @@ main :: () {
} else if arg == "-compile" {
current_suite.test_cases[cases - 1].stage_flags |= .Compile;
} else if contains(arg, ".") {
path_split := split(arg, "\\");
split_path := split(path_split[path_split.count - 1], ".");
sc := get_scratch();
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];
if extension == SHADER_EXTENSION {
path := copy_string(arg);
test_case := make_test_case(path, 0);
path := copy_string(arg,, local_temp);
test_case := make_test_case(path, 0, local_temp);
array_add(*current_suite.test_cases, test_case);
} else {
print("%Invalid file as argument % %\n", red(), arg, reset_color());
@@ -648,8 +662,10 @@ main :: () {
}
case .None; {
if contains(arg, ".") {
path_split := split(arg, "\\");
split_path := split(path_split[path_split.count - 1], ".");
sc := get_scratch();
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];
if extension == SHADER_EXTENSION {
@@ -660,12 +676,14 @@ main :: () {
if !current_suite {
suite : Test_Suite;
suite.results.allocator = local_temp;
suite.test_cases.allocator = local_temp;
array_add(*suites, suite);
current_suite = *suites[0];
}
arg_parse_state = .Run_Test;
path := copy_string(arg);
test_case := make_test_case(path, 0);
path := copy_string(arg,, local_temp);
test_case := make_test_case(path, 0, local_temp);
array_add(*current_suite.test_cases, test_case);
} else if extension == SUITE_EXTENSION {
if arg_parse_state == .Run_Test {
@@ -676,6 +694,8 @@ main :: () {
path := copy_string(arg);
suite : Test_Suite;
suite.results.allocator = local_temp;
suite.test_cases.allocator = local_temp;
read_suite(path, *suite);
array_add(*suites, suite);
current_suite = *suites[0];
@@ -690,4 +710,6 @@ main :: () {
for suite : suites {
run_test_suite(*suite, output_type);
}
clear(local_temp);
}

View File

@@ -565,21 +565,28 @@ scan_next_token :: (lexer : *Lexer) -> *Token {
// return error_token(lexer, tprint("Invalid token: %", s));
}
lex :: (result : *Compile_Result) {
lex :: (result : *Compile_Result, allocator := temp) {
if result.had_error {
return;
}
lexer : Lexer;
lexer.result = result;
lexer.result.tokens.allocator = result.allocator;
array_reserve(*lexer.result.tokens, 1024 * 1024);
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
init_lexer_from_string(*lexer, result.file.source);
lexer.path = result.file.path;
token : *Token = scan_next_token(*lexer);
while token && token.kind != .TOKEN_EOF {
token = scan_next_token(*lexer);
lexer : Lexer;
lexer.result = result;
lexer.result.tokens.allocator = result.allocator;
array_reserve(*lexer.result.tokens, 1024 * 1024);
init_lexer_from_string(*lexer, result.file.source);
lexer.path = result.file.path;
token : *Token = scan_next_token(*lexer);
while token && token.kind != .TOKEN_EOF {
token = scan_next_token(*lexer);
}
}
}
@@ -765,9 +772,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 {
sc := get_scratch();
defer scratch_end(sc);
builder : String_Builder;
init_string_builder(*builder,, allocator);
print_from_source_location(*builder, source_location);
init_string_builder(*builder,, sc.allocator);
print_from_source_location(*builder, source_location,, sc.allocator);
return builder_to_string(*builder,, allocator);
}

View File

@@ -165,8 +165,10 @@ unexpected_token :: (state : *Parse_State, token : Token, message : string) {
/*
*/
sc := get_scratch();
defer scratch_end(sc);
builder : String_Builder;
init_string_builder(*builder,, temp);
init_string_builder(*builder,, sc.allocator);
print_to_builder(*builder, "%\n\n", message);
@@ -189,7 +191,7 @@ unexpected_token :: (state : *Parse_State, token : Token, message : string) {
indent(*builder, 1);
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);
}
@@ -372,7 +374,8 @@ make_node :: (nodes : *[..]AST_Node, kind : AST_Kind, allocator : Allocator) ->
node : AST_Node;
node.kind = kind;
node.children.allocator = allocator;
node.children.allocator = allocator;
node.hint_tokens.allocator = allocator;
array_add(nodes, node);
return *(nodes.*[nodes.count - 1]);
@@ -388,7 +391,7 @@ make_node :: (parse_state : *Parse_State, kind : AST_Kind) -> *AST_Node {
// return node;
// }
make_builtin_token :: (builder : *String_Builder, kind : Token_Kind, text : string, col : *int, line : *int) -> Token {
make_builtin_token :: (tokens : *[..]Token, builder : *String_Builder, kind : Token_Kind, text : string, col : *int, line : *int) -> *Token {
tok : Token;
tok.kind = kind;
@@ -418,55 +421,172 @@ make_builtin_token :: (builder : *String_Builder, kind : Token_Kind, text : stri
tok.length = text.count;
tok.builtin = true;
return tok;
array_add(tokens, tok);
return *(tokens.*)[tokens.count - 1];
}
new_builtin_struct_node :: (result : *Compile_Result, name : string, members : []Arg, allocator : Allocator) -> *AST_Node {
sc := get_scratch(result, allocator);
sc := get_scratch(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(*result.nodes, .Struct, allocator);
source_location : Source_Range;
col := 0;
line := 0;
tok_index := result.tokens.count;
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line));
ident_token := make_builtin_token(*result.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
source_location.begin = ident_token;
append(*builder, " ");
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_DOUBLECOLON, "::", *col, *line));
make_builtin_token(*result.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
append(*builder, " ");
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_STRUCT, "struct", *col, *line));
make_builtin_token(*result.tokens, *builder, .TOKEN_STRUCT, "struct", *col, *line);
append(*builder, " ");
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_LEFTBRACE, "{", *col, *line));
make_builtin_token(*result.tokens, *builder, .TOKEN_LEFTBRACE, "{", *col, *line);
append(*builder, "\n");
line += 1;
col = 0;
field_list := make_node(*result.nodes, .FieldList, allocator);
add_child(node, field_list);
for member : members {
// @Incomplete: Missing field list
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_IDENTIFIER, tprint("%", member.name), *col, *line));
field := make_node(*result.nodes, .Field, allocator);
field_source_loc : Source_Range;
field_ident := make_builtin_token(*result.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, " ");
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_COLON, ":", *col, *line));
make_builtin_token(*result.tokens, *builder, .TOKEN_COLON, ":", *col, *line);
append(*builder, " ");
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line));
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_SEMICOLON, ";", *col, *line));
make_builtin_token(*result.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
semicolon_tok := make_builtin_token(*result.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);
}
array_add(*result.tokens, make_builtin_token(*builder, .TOKEN_RIGHTBRACE, "}", *col, *line));
brace_token := make_builtin_token(*result.tokens, *builder, .TOKEN_RIGHTBRACE, "}", *col, *line);
append(*builder, "\n");
source_location.end = brace_token;
source := builder_to_string(*builder,, 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..result.tokens.count - 1 {
tok := *result.tokens[i];
tok := result.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];
}
print_from_source_location(source_location, temp);
return node;
}
new_builtin_function_node :: (result : *Compile_Result, name : string, members : []Arg, return_var : Arg, allocator : Allocator) -> *AST_Node {
sc := get_scratch(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(*result.nodes, .Function, allocator);
source_location : Source_Range;
col := 0;
line := 0;
tok_index := result.tokens.count;
ident_token := make_builtin_token(*result.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", name), *col, *line);
source_location.begin = ident_token;
append(*builder, " ");
make_builtin_token(*result.tokens, *builder, .TOKEN_DOUBLECOLON, "::", *col, *line);
append(*builder, " ");
make_builtin_token(*result.tokens, *builder, .TOKEN_LEFTPAREN, "(", *col, *line);
field_list := make_node(*result.nodes, .FieldList, allocator);
add_child(node, field_list);
for member : members {
field := make_node(*result.nodes, .Field, allocator);
field_source_loc : Source_Range;
field_ident := make_builtin_token(*result.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(*result.tokens, *builder, .TOKEN_COLON, ":", *col, *line);
append(*builder, " ");
type_tok := make_builtin_token(*result.tokens, *builder, .TOKEN_IDENTIFIER, tprint("%", member.typename), *col, *line);
if it_index < members.count - 1 {
make_builtin_token(*result.tokens, *builder, .TOKEN_COMMA, ";", *col, *line);
}
field_source_loc.end = type_tok;
field.source_location = field_source_loc;
add_child(field_list, field);
}
make_builtin_token(*result.tokens, *builder, .TOKEN_RIGHTPAREN, ")", *col, *line);
semicolon_tok := make_builtin_token(*result.tokens, *builder, .TOKEN_SEMICOLON, ";", *col, *line);
source_location.end = semicolon_tok;
source := builder_to_string(*builder,, 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..result.tokens.count - 1 {
tok := result.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];
}
print_from_source_location(source_location, temp);
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) {
child.parent = node;
array_add(*node.children, child);
@@ -1461,28 +1581,35 @@ declaration :: (parse_state : *Parse_State) -> *AST_Node {
return decl_node;
}
parse :: (result : *Compile_Result) {
parse :: (result : *Compile_Result, allocator := temp) {
if result.had_error {
return;
}
parse_state : Parse_State;
result.nodes.allocator = result.allocator;
array_reserve(*result.nodes, 4096);
parse_state.current_token_index = 0;
parse_state.result = result;
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
advance(*parse_state);
parse_state : Parse_State;
result.nodes.allocator = result.allocator;
array_reserve(*result.nodes, 4096);
parse_state.current_token_index = 0;
parse_state.result = result;
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;
advance(*parse_state);
while !check(*parse_state, .TOKEN_EOF) {
decl := declaration(*parse_state);
if decl {
add_child(program, decl);
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);
}
}
}
}

View File

@@ -90,8 +90,6 @@ Type_Variable_Handle :: #type, distinct u32;
Scope_Stack :: struct {
allocator : Allocator;
arena : Arena;
stack : [..]Scope;
}
@@ -126,6 +124,8 @@ Scope :: struct {
builtin : bool;
kind : Scope_Kind;
allocator : Allocator;
}
Scope_Handle :: #type, distinct u32;
@@ -621,6 +621,8 @@ push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Glo
count := checker.result.scope_stack.stack.count;
scope := *checker.result.scope_stack.stack[count - 1];
scope.allocator = make_arena(Kilobytes(512));
scope.table.allocator = scope.allocator;
scope.parent = checker.current_scope;
scope.name = name;
scope.kind = kind;
@@ -628,7 +630,7 @@ push_scope :: (checker : *Semantic_Checker, name := "", kind : Scope_Kind = .Glo
scope.builtin = true;
}
scope.children.allocator = checker.result.scope_stack.allocator;
scope.children.allocator = checker.result.scope_stack.stack.allocator;
if checker.current_scope {
scope := get_current_scope(checker);
@@ -721,18 +723,19 @@ Arg :: struct {
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);
// @Incomplete: Skip for now. This is solely for error reporting?
// At least let's not make a big deal out of it for now.
// We could report builtin nodes in a special way instead of with an actual source location.
builtin_node := new_builtin_struct_node(checker.result, name, members, checker.result.allocator);
symbol : Defined_Symbol;
symbol.name = name;
// symbol.source_node = builtin_node;
symbol.source_node = builtin_node;
symbol.builtin = true;
symbol.type_variable = handle;
add_symbol_to_scope(checker.state, *checker.result.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;
@@ -746,7 +749,10 @@ new_builtin_struct :: (checker : *Semantic_Checker, name : string, members : []A
member_symbol : Defined_Symbol;
member_symbol.name = member.name;
member_symbol.type_variable = member_handle;
add_symbol_to_scope(checker.state, *checker.result.scope_stack, checker.current_scope, member.name, symbol);
add_symbol_to_scope(checker.state, *checker.result.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);
}
@@ -756,36 +762,60 @@ new_builtin_struct :: (checker : *Semantic_Checker, name : string, members : []A
return from_handle(checker, handle), handle;
}
// new_builtin_function :: (checker : *Semantic_Checker, name : string, args : []Arg) -> *Type_Variable, Type_Variable_Handle {
// tv, handle := new_builtin_type_variable(checker, .Function, .Declaration, name);
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);
// // @Incomplete: Skip for now. This is solely for error reporting?
// // At least let's not make a big deal out of it for now.
// // We could report builtin nodes in a special way instead of with an actual source location.
// // builtin_node := new_builtin_struct_node(checker.result.nodes, members, checker.result.allocator;
builtin_node := new_builtin_function_node(checker.result, name, args, return_arg, checker.result.allocator);
// 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.result.scope_stack, checker.current_scope, name, symbol);
function : Defined_Symbol;
function.name = name;
function.source_node = builtin_node;
function.type_variable = handle;
// scope, scope_handle := push_scope(checker, name, .Struct);
// tv.scope = scope_handle;
// for arg : args {
// typename : string;
// kind := get_type_from_identifier(checker, checker.current_scope, arg, *typename);
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.result.scope_stack, checker.current_scope, name, symbol);
} else {
array_add(*find_result.functions, function);
}
// arg_var, arg_handle := new_builtin_type_variable(checker, kind, .Expression, typename);
// add_child(checker, handle, arg_handle);
// }
tv.source_node = builtin_node;
// pop_scope(checker);
field_list := get_field_list(builtin_node);
// return from_handle(checker, handle), handle;
// }
scope, scope_handle := push_scope(checker, name, .Struct);
tv.scope = scope_handle;
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_symbol : Defined_Symbol;
arg_symbol.name = arg.name;
arg_symbol.type_variable = arg_handle;
add_symbol_to_scope(checker.state, *checker.result.scope_stack, checker.current_scope, arg.name, arg_symbol);
field_list.children[it_index].type_variable = arg_handle;
arg_var.source_node = field_list.children[it_index];
add_child(checker, handle, arg_handle);
}
pop_scope(checker);
return from_handle(checker, handle), handle;
}
add_child :: (variable : *Type_Variable, child : Type_Variable_Handle) {
assert(variable.children.count < Type_Variable.MAX_TYPE_VARIABLE_CHILDREN);
@@ -808,11 +838,11 @@ init_semantic_checker :: (checker : *Semantic_Checker, root : *AST_Node, path :
checker.program_root = root;
checker.path = path;
// @Incomplete(niels): Use other allocator and/or add static array with convenience functions
checker.result.type_variables.allocator = checker.result.allocator;
array_reserve(*checker.result.type_variables, 2048);
checker.result.scope_stack.allocator = make_arena(Megabytes(8));
checker.result.scope_stack.stack.allocator = checker.result.scope_stack.allocator;
array_reserve(*checker.result.scope_stack.stack, 256);
global_scope, global_handle := push_scope(checker, kind = .Global);
@@ -1040,7 +1070,6 @@ declare_cbuffer :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Varia
get_actual_function_name :: (node : *AST_Node) -> string {
name_to_check := node.name;
if node.vertex_entry_point {
name_to_check = sprint("%__%", VERTEX_MAIN_FUNCTION_PREFIX, node.name);
} else if node.pixel_entry_point {
name_to_check = sprint("%__%", PIXEL_MAIN_FUNCTION_PREFIX, node.name);
@@ -1087,6 +1116,7 @@ declare_function :: (checker : *Semantic_Checker, node : *AST_Node, builtin : bo
symbol.name = name_to_check;
symbol.source_node = node;
symbol.type_variable = 0;
symbol.functions.allocator = get_current_scope(checker).allocator;
array_reserve(*symbol.functions, 32);
array_add(*symbol.functions, function);
@@ -1768,7 +1798,6 @@ types_compatible :: (checker : *Semantic_Checker, lhs : Type_Variable_Handle, rh
return true;
}
}
return false;
}
@@ -1776,9 +1805,54 @@ add_builtins_new :: (checker : *Semantic_Checker) {
checker.state = .Adding_Builtins;
float_name := Typenames[Type_Kind.Float];
new_builtin_struct(checker, "float2", .[.{"x", float_name}, .{"y", float_name}]);
new_builtin_struct(checker, "float3", .[.{"x", float_name}, .{"y", float_name}, .{"z", float_name}]);
new_builtin_struct(checker, "float4", .[.{"x", float_name}, .{"y", float_name}, .{"z", float_name}, .{"w", float_name}]);
int_name := Typenames[Type_Kind.Int];
arg :: (name : string, kind : Type_Kind) -> Arg {
return .{ name, Typenames[kind] };
}
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%%", 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%%", 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("x"), farg("y")], .{ "res", "float2" });
new_builtin_function(checker, "float2", .[.{"v", "float2"}], .{ "res", "float2" });
new_builtin_function(checker, "float3", .[farg("x"), farg("y"), farg("z")], .{ "res", "float3" });
checker.state = .Type_Checking;
}
@@ -1819,7 +1893,7 @@ add_builtins :: (checker : *Semantic_Checker) {
checker.result.root = null;
tokens : [..]Token;
scratch := get_scratch(checker.result);
scratch := get_scratch();
defer scratch_end(scratch);
tokens.allocator = scratch.allocator;
array_reserve(*tokens, 1024 * 1024);
@@ -1846,26 +1920,35 @@ type_check :: (checker : *Semantic_Checker, root : *AST_Node) {
traverse(checker, root);
}
check :: (result : *Compile_Result) {
check :: (result : *Compile_Result, allocator : Allocator = temp) {
if result.had_error {
return;
}
checker : Semantic_Checker;
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
checker.current_buffer_index = 0;
checker.current_sampler_index = 0;
checker.current_texture_index = 0;
checker.result = result;
checker : Semantic_Checker;
init_semantic_checker(*checker, result.root, result.file.path);
checker.current_buffer_index = 0;
checker.current_sampler_index = 0;
checker.current_texture_index = 0;
checker.result = result;
// add_builtins_new(*checker);
add_builtins(*checker);
init_semantic_checker(*checker, result.root, result.file.path);
add_builtins_new(*checker);
// add_builtins(*checker);
type_check(*checker, result.root);
result.had_error |= checker.had_error;
}
type_check(*checker, result.root);
result.had_error |= checker.had_error;
}
// ===========================================================
@@ -2101,7 +2184,7 @@ print_type_variable :: (builder : *String_Builder, variables : []Type_Variable,
source_location.end = right_most.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; {
if variable.return_type_variable{
@@ -2128,7 +2211,7 @@ print_type_variable :: (builder : *String_Builder, variables : []Type_Variable,
append(builder, ")");
}
case; {
print_from_source_location(builder, node.source_location);
print("%\n", print_from_source_location(builder, node.source_location,, temp));
}
}
}

View File

@@ -181,23 +181,34 @@ Compile_Result :: struct {
messages : [..]Compiler_Message;
allocator : Allocator;
// arena : Arena;
// scratch_arenas : [2]Arena;
scratch_allocators : [2]Allocator;
// string_allocator : Allocator;
}
get_scratch :: (result : *Compile_Result, conflict : Allocator = .{}) -> Scratch {
arena := cast(*Arena)conflict.data;
if result.scratch_allocators[0].data == null {
result.scratch_allocators[0] = make_arena(Megabytes(128));
result.scratch_allocators[1] = make_arena(Megabytes(128));
}
#add_context scratch_allocators : [2]Allocator;
#add_context scratch_id : int = 0;
if arena == get_arena(result.scratch_allocators[0]) {
return scratch_begin(*result.scratch_allocators[1]);
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));
}
return scratch_begin(*result.scratch_allocators[0]);
}
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 : *Compile_Result, format : string, args : .. Any) {
@@ -494,19 +505,29 @@ generate_output_data :: (result : *Compile_Result) {
}
}
compile_file :: (compiler : *Shader_Compiler, path : string) -> Compile_Result {
compile_file :: (compiler : *Shader_Compiler, path : string, allocator : Allocator = temp) -> Compile_Result {
result : Compile_Result;
result.allocator = make_arena(Megabytes(128));
new_context := context;
new_context.allocator = allocator;
push_context new_context {
init_context_allocators();
defer clear_context_allocators();
result.file = make_file(*result, path);
result.environment = compiler.environment;
lex(*result);
parse(*result);
check(*result);
codegen(*result);
generate_output_data(*result);
result.allocator = make_arena(Megabytes(128));
result.file = make_file(*result, path);
result.environment = compiler.environment;
lex(*result);
parse(*result);
check(*result);
codegen(*result);
generate_output_data(*result);
}
return result;
}

13
test/builtin_types.ink Normal file
View File

@@ -0,0 +1,13 @@
vertex main :: () {
v2 : float2 = float2(2.0, 2.0);
v3 : float3 = float3(2.0, 2.0, 2.0);
v4 : float4;// = float4(2.0, 2.0, 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,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

@@ -10,6 +10,9 @@ test/field_assignment.ink lex
test/field_without_type_specifier.ink lex
test/float_suffix.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_out_of_order_declaration.ink lex
test/function_call_return.ink lex
@@ -18,6 +21,7 @@ test/function_with_int_return.ink lex
test/if_cond_assign.ink lex
test/if_if_if.ink lex
test/inferred_types.ink lex
test/large_block.ink lex
test/meta_block.ink lex
test/multiple_functions.ink lex
test/multiple_semicolons_everywhere.ink lex

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

@@ -11,6 +11,8 @@ test/field_without_type_specifier.ink parse
test/float_if_cond.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_out_of_order_declaration.ink parse
test/function_call_return.ink parse
@@ -19,6 +21,7 @@ test/function_with_int_return.ink parse
test/if_cond_assign.ink parse
test/if_if_if.ink parse
test/inferred_types.ink parse
test/large_block.ink parse
test/meta_block.ink parse
test/multiple_functions.ink parse
test/multiple_semicolons_everywhere.ink parse

View File

@@ -7,6 +7,8 @@ test/empty_struct.ink semant
test/empty_vertex_main.ink semant
test/empty_vertex_main_with_position_parameter.ink semant
test/field_assignment.ink semant
test/for_i_loop.ink semant
test/for_i_one_liner.ink semant
test/function_call.ink semant
test/function_call_out_of_order_declaration.ink semant
test/function_call_return.ink semant