diff --git a/Ast/include/Luau/Ast.h b/Ast/include/Luau/Ast.h index fdef14c07..2136b3da2 100644 --- a/Ast/include/Luau/Ast.h +++ b/Ast/include/Luau/Ast.h @@ -208,6 +208,7 @@ class AstAttr : public AstNode { Checked, Native, + Shader, }; AstAttr(const Location& location, Type type); diff --git a/Ast/include/Luau/Lexer.h b/Ast/include/Luau/Lexer.h index fc77dacf1..f0187f245 100644 --- a/Ast/include/Luau/Lexer.h +++ b/Ast/include/Luau/Lexer.h @@ -79,7 +79,6 @@ struct Lexeme PowAssign, ConcatAssign, //GIDEROS ADDED - DivInt, MaxOf, MinOf, AngToRad, diff --git a/Ast/src/Parser.cpp b/Ast/src/Parser.cpp index 8fd3fbf52..a308141fb 100644 --- a/Ast/src/Parser.cpp +++ b/Ast/src/Parser.cpp @@ -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) diff --git a/Compiler/src/Compiler.cpp b/Compiler/src/Compiler.cpp index a66223ce3..a16999b7c 100644 --- a/Compiler/src/Compiler.cpp +++ b/Compiler/src/Compiler.cpp @@ -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);