MCPcopy Create free account
hub / github.com/decaf-emu/decaf-emu / assembleShaderCode

Function assembleShaderCode

tools/latte-assembler/src/assembler_parse.cpp:4–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#include "grammar.h"
3
4bool
5assembleShaderCode(Shader &shader,
6 std::string_view code)
7{
8 peg::parser parser;
9 parser.log = [&](size_t ln, size_t col, const std::string &msg) {
10 std::cout << "Error parsing grammar:" << ln << ":" << col << ": " << msg << std::endl;
11 };
12
13 if (!parser.load_grammar(LatteGrammar)) {
14 return false;
15 }
16
17 parser.log = [&](size_t ln, size_t col, const std::string &msg) {
18 std::cout << shader.path << ":" << ln << ":" << col << ": " << msg << std::endl;
19 };
20
21 parser.enable_ast();
22
23 std::shared_ptr<peg::Ast> ast;
24 if (!parser.parse_n(code.data(), code.size(), ast)) {
25 return false;
26 }
27
28 ast = peg::AstOptimizer(false).optimize(ast);
29 assembleAST(shader, ast);
30 return true;
31}

Callers 2

assembleFileFunction · 0.85
mainFunction · 0.85

Calls 4

assembleASTFunction · 0.85
optimizeMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected