Skip to content

Commit

Permalink
Add @shader attribute for functions (enable pseudocode)
Browse files Browse the repository at this point in the history
Const vectors less than four values are padded with nan instead of 0
  • Loading branch information
Nicolas BOUQUET committed Oct 30, 2024
1 parent 4df1eaf commit 1fd3297
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions Ast/include/Luau/Ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class AstAttr : public AstNode
{
Checked,
Native,
Shader,
};

AstAttr(const Location& location, Type type);
Expand Down
1 change: 0 additions & 1 deletion Ast/include/Luau/Lexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ struct Lexeme
PowAssign,
ConcatAssign,
//GIDEROS ADDED
DivInt,
MaxOf,
MinOf,
AngToRad,
Expand Down
6 changes: 5 additions & 1 deletion Ast/src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ struct AttributeEntry
AstAttr::Type type;
};

AttributeEntry kAttributeEntries[] = {{"@checked", AstAttr::Type::Checked}, {"@native", AstAttr::Type::Native}, {nullptr, AstAttr::Type::Checked}};
AttributeEntry kAttributeEntries[] = {
{"@checked", AstAttr::Type::Checked},
{"@native", AstAttr::Type::Native},
{"@shader", AstAttr::Type::Shader},
{nullptr, AstAttr::Type::Checked}};

ParseError::ParseError(const Location& location, const std::string& message)
: location(location)
Expand Down
10 changes: 8 additions & 2 deletions Compiler/src/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,17 @@ struct Compiler
bool self = func->self != 0;
uint32_t fid = bytecode.beginFunction(uint8_t(self + func->args.size), func->vararg);

if (func->returnAnnotation) {
bool isShader=false;
for (auto it:func->attributes) {
if (it->type==AstAttr::Shader) isShader=true;
}
if ((!isShader)&&(func->returnAnnotation)) {
AstTypeReference *returnType=(AstTypeReference *)func->returnAnnotation->types.data[0];
if (returnType->name=="Shader")
bytecode.setPseudoCode(generatePseudoCode(func));
isShader=true;
}
if (isShader)
bytecode.setPseudoCode(generatePseudoCode(func));

setDebugLine(func);

Expand Down

0 comments on commit 1fd3297

Please sign in to comment.