Commit 0dc9b63e authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] explicit exports of macros to CSA

Macros are now inaccessible from CSA except if their declaration is
marked with the "export" keyword. The implicit field accessors for class
fields are always exported.

In this CL, unwarranted access from CSA is prevented by appending a
pseudo-random suffix to non-exported names. This is to be replaced by
something more principled, namely by not including these macros at all in
the headers included from CSA.

Bug: v8:7793
Change-Id: I3ffb2e91a616623f81b4b4508e001ad0cf65d2c2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1615258
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61672}
parent 42fee61a
...@@ -31,6 +31,7 @@ namespace arguments { ...@@ -31,6 +31,7 @@ namespace arguments {
// It is difficult to actually check/assert this, since interpreted or JITted // It is difficult to actually check/assert this, since interpreted or JITted
// frames are StandardFrames, but so are hand-written builtins. Doing that // frames are StandardFrames, but so are hand-written builtins. Doing that
// more refined check would be prohibitively expensive. // more refined check would be prohibitively expensive.
@export
macro GetArgumentsFrameAndCount(implicit context: Context)(f: JSFunction): macro GetArgumentsFrameAndCount(implicit context: Context)(f: JSFunction):
ArgumentsInfo { ArgumentsInfo {
let frame: Frame = LoadParentFramePointer(); let frame: Frame = LoadParentFramePointer();
......
...@@ -2725,8 +2725,6 @@ extern macro IsJSArrayMap(Map): bool; ...@@ -2725,8 +2725,6 @@ extern macro IsJSArrayMap(Map): bool;
extern macro IsExtensibleMap(Map): bool; extern macro IsExtensibleMap(Map): bool;
extern macro IsJSValue(HeapObject): bool; extern macro IsJSValue(HeapObject): bool;
extern macro IsCustomElementsReceiverInstanceType(int32): bool; extern macro IsCustomElementsReceiverInstanceType(int32): bool;
extern macro IsFastJSArrayWithNoCustomIteration(implicit context: Context)(
Object): bool;
extern macro Typeof(Object): Object; extern macro Typeof(Object): Object;
// Return true iff number is NaN. // Return true iff number is NaN.
...@@ -2815,6 +2813,7 @@ struct KeyValuePair { ...@@ -2815,6 +2813,7 @@ struct KeyValuePair {
// Macro definitions for compatibility that expose functionality to the CSA // Macro definitions for compatibility that expose functionality to the CSA
// using "legacy" APIs. In Torque code, these should not be used. // using "legacy" APIs. In Torque code, these should not be used.
@export
macro IsFastJSArray(o: Object, context: Context): bool { macro IsFastJSArray(o: Object, context: Context): bool {
try { try {
// Long-term, it's likely not a good idea to have this slow-path test here, // Long-term, it's likely not a good idea to have this slow-path test here,
...@@ -2828,16 +2827,18 @@ macro IsFastJSArray(o: Object, context: Context): bool { ...@@ -2828,16 +2827,18 @@ macro IsFastJSArray(o: Object, context: Context): bool {
return Is<FastJSArray>(o); return Is<FastJSArray>(o);
} }
macro BranchIfFastJSArray(o: Object, context: Context): never @export
labels True, False { macro BranchIfFastJSArray(o: Object, context: Context): never labels True,
False {
// Long-term, it's likely not a good idea to have this slow-path test here, // Long-term, it's likely not a good idea to have this slow-path test here,
// since it fundamentally breaks the type system. // since it fundamentally breaks the type system.
GotoIfForceSlowPath() otherwise False; GotoIfForceSlowPath() otherwise False;
BranchIf<FastJSArray>(o) otherwise True, False; BranchIf<FastJSArray>(o) otherwise True, False;
} }
macro BranchIfFastJSArrayForRead(o: Object, context: Context): never @export
labels True, False { macro BranchIfFastJSArrayForRead(o: Object, context: Context):
never labels True, False {
// Long-term, it's likely not a good idea to have this slow-path test here, // Long-term, it's likely not a good idea to have this slow-path test here,
// since it fundamentally breaks the type system. // since it fundamentally breaks the type system.
GotoIfForceSlowPath() otherwise False; GotoIfForceSlowPath() otherwise False;
...@@ -2857,6 +2858,7 @@ macro BranchIfFastJSArrayForCopy(o: Object, context: Context): never ...@@ -2857,6 +2858,7 @@ macro BranchIfFastJSArrayForCopy(o: Object, context: Context): never
BranchIf<FastJSArrayForCopy>(o) otherwise True, False; BranchIf<FastJSArrayForCopy>(o) otherwise True, False;
} }
@export
macro IsFastJSArrayWithNoCustomIteration(context: Context, o: Object): bool { macro IsFastJSArrayWithNoCustomIteration(context: Context, o: Object): bool {
return Is<FastJSArrayWithNoCustomIteration>(o); return Is<FastJSArrayWithNoCustomIteration>(o);
} }
...@@ -2914,6 +2916,7 @@ transitioning builtin FastCreateDataProperty(implicit context: Context)( ...@@ -2914,6 +2916,7 @@ transitioning builtin FastCreateDataProperty(implicit context: Context)(
return Undefined; return Undefined;
} }
@export
transitioning macro ToStringImpl(context: Context, o: Object): String { transitioning macro ToStringImpl(context: Context, o: Object): String {
let result: Object = o; let result: Object = o;
while (true) { while (true) {
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include 'src/builtins/builtins-collections-gen.h' #include 'src/builtins/builtins-collections-gen.h'
namespace collections { namespace collections {
@export
macro LoadKeyValuePairNoSideEffects(implicit context: Context)(o: Object): macro LoadKeyValuePairNoSideEffects(implicit context: Context)(o: Object):
KeyValuePair KeyValuePair labels MayHaveSideEffects {
labels MayHaveSideEffects {
typeswitch (o) { typeswitch (o) {
case (a: FastJSArray): { case (a: FastJSArray): {
const length: Smi = a.length; const length: Smi = a.length;
...@@ -42,6 +42,7 @@ namespace collections { ...@@ -42,6 +42,7 @@ namespace collections {
} }
} }
@export
transitioning macro LoadKeyValuePair(implicit context: Context)(o: Object): transitioning macro LoadKeyValuePair(implicit context: Context)(o: Object):
KeyValuePair { KeyValuePair {
try { try {
......
...@@ -141,6 +141,7 @@ Cast<ArgumentsAdaptorFrame>(implicit context: Context)(f: Frame): ...@@ -141,6 +141,7 @@ Cast<ArgumentsAdaptorFrame>(implicit context: Context)(f: Frame):
// beginning of builtin code while the target value is still in the register // beginning of builtin code while the target value is still in the register
// and the former should be used in slow paths in order to reduce register // and the former should be used in slow paths in order to reduce register
// pressure on the fast path. // pressure on the fast path.
@export
macro LoadTargetFromFrame(): JSFunction { macro LoadTargetFromFrame(): JSFunction {
return LoadFramePointer().function; return LoadFramePointer().function;
} }
...@@ -374,6 +374,7 @@ namespace typed_array_createtypedarray { ...@@ -374,6 +374,7 @@ namespace typed_array_createtypedarray {
} }
} }
@export
transitioning macro TypedArraySpeciesCreateByLength(implicit context: transitioning macro TypedArraySpeciesCreateByLength(implicit context:
Context)( Context)(
methodName: constexpr string, exemplar: JSTypedArray, methodName: constexpr string, exemplar: JSTypedArray,
......
...@@ -801,10 +801,12 @@ struct TorqueMacroDeclaration : MacroDeclaration { ...@@ -801,10 +801,12 @@ struct TorqueMacroDeclaration : MacroDeclaration {
TorqueMacroDeclaration(SourcePosition pos, bool transitioning, TorqueMacroDeclaration(SourcePosition pos, bool transitioning,
std::string name, base::Optional<std::string> op, std::string name, base::Optional<std::string> op,
ParameterList parameters, TypeExpression* return_type, ParameterList parameters, TypeExpression* return_type,
const LabelAndTypesVector& labels) const LabelAndTypesVector& labels, bool export_to_csa)
: MacroDeclaration(kKind, pos, transitioning, std::move(name), : MacroDeclaration(kKind, pos, transitioning, std::move(name),
std::move(op), std::move(parameters), return_type, std::move(op), std::move(parameters), return_type,
labels) {} labels),
export_to_csa(export_to_csa) {}
bool export_to_csa;
}; };
struct BuiltinDeclaration : CallableNode { struct BuiltinDeclaration : CallableNode {
......
...@@ -320,15 +320,18 @@ class Macro : public Callable { ...@@ -320,15 +320,18 @@ class Macro : public Callable {
const std::string& external_assembler_name() const { const std::string& external_assembler_name() const {
return external_assembler_name_; return external_assembler_name_;
} }
bool IsAccessibleFromCSA() const { return accessible_from_csa_; }
protected: protected:
Macro(Declarable::Kind kind, std::string external_name, Macro(Declarable::Kind kind, std::string external_name,
std::string readable_name, std::string external_assembler_name, std::string readable_name, std::string external_assembler_name,
const Signature& signature, bool transitioning, const Signature& signature, bool transitioning,
base::Optional<Statement*> body, bool is_user_defined) base::Optional<Statement*> body, bool is_user_defined,
bool accessible_from_csa)
: Callable(kind, std::move(external_name), std::move(readable_name), : Callable(kind, std::move(external_name), std::move(readable_name),
signature, transitioning, body), signature, transitioning, body),
external_assembler_name_(std::move(external_assembler_name)) { external_assembler_name_(std::move(external_assembler_name)),
accessible_from_csa_(accessible_from_csa) {
SetIsUserDefined(is_user_defined); SetIsUserDefined(is_user_defined);
if (signature.parameter_types.var_args) { if (signature.parameter_types.var_args) {
ReportError("Varargs are not supported for macros."); ReportError("Varargs are not supported for macros.");
...@@ -340,12 +343,13 @@ class Macro : public Callable { ...@@ -340,12 +343,13 @@ class Macro : public Callable {
Macro(std::string external_name, std::string readable_name, Macro(std::string external_name, std::string readable_name,
std::string external_assembler_name, const Signature& signature, std::string external_assembler_name, const Signature& signature,
bool transitioning, base::Optional<Statement*> body, bool transitioning, base::Optional<Statement*> body,
bool is_user_defined) bool is_user_defined, bool accessible_from_csa)
: Macro(Declarable::kMacro, std::move(external_name), : Macro(Declarable::kMacro, std::move(external_name),
std::move(readable_name), external_assembler_name, signature, std::move(readable_name), external_assembler_name, signature,
transitioning, body, is_user_defined) {} transitioning, body, is_user_defined, accessible_from_csa) {}
std::string external_assembler_name_; std::string external_assembler_name_;
bool accessible_from_csa_;
}; };
class Method : public Macro { class Method : public Macro {
...@@ -366,7 +370,7 @@ class Method : public Macro { ...@@ -366,7 +370,7 @@ class Method : public Macro {
const Signature& signature, bool transitioning, Statement* body) const Signature& signature, bool transitioning, Statement* body)
: Macro(Declarable::kMethod, std::move(external_name), : Macro(Declarable::kMethod, std::move(external_name),
std::move(readable_name), std::move(external_assembler_name), std::move(readable_name), std::move(external_assembler_name),
signature, transitioning, body, true), signature, transitioning, body, true, false),
aggregate_type_(aggregate_type) {} aggregate_type_(aggregate_type) {}
AggregateType* aggregate_type_; AggregateType* aggregate_type_;
}; };
......
...@@ -163,7 +163,7 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl, ...@@ -163,7 +163,7 @@ void DeclarationVisitor::Visit(ExternalRuntimeDeclaration* decl,
void DeclarationVisitor::Visit(ExternalMacroDeclaration* decl, void DeclarationVisitor::Visit(ExternalMacroDeclaration* decl,
const Signature& signature, const Signature& signature,
base::Optional<Statement*> body) { base::Optional<Statement*> body) {
Declarations::DeclareMacro(decl->name, decl->external_assembler_name, Declarations::DeclareMacro(decl->name, true, decl->external_assembler_name,
signature, decl->transitioning, body, decl->op); signature, decl->transitioning, body, decl->op);
} }
...@@ -177,9 +177,9 @@ void DeclarationVisitor::Visit(TorqueBuiltinDeclaration* decl, ...@@ -177,9 +177,9 @@ void DeclarationVisitor::Visit(TorqueBuiltinDeclaration* decl,
void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl, void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
const Signature& signature, const Signature& signature,
base::Optional<Statement*> body) { base::Optional<Statement*> body) {
Macro* macro = Macro* macro = Declarations::DeclareMacro(
Declarations::DeclareMacro(decl->name, base::nullopt, signature, decl->name, decl->export_to_csa, base::nullopt, signature,
decl->transitioning, body, decl->op); decl->transitioning, body, decl->op);
// TODO(szuend): Set identifier_position to decl->name->pos once all callable // TODO(szuend): Set identifier_position to decl->name->pos once all callable
// names are changed from std::string to Identifier*. // names are changed from std::string to Identifier*.
macro->SetPosition(decl->pos); macro->SetPosition(decl->pos);
...@@ -369,8 +369,8 @@ Callable* DeclarationVisitor::Specialize( ...@@ -369,8 +369,8 @@ Callable* DeclarationVisitor::Specialize(
Callable* callable; Callable* callable;
if (MacroDeclaration::DynamicCast(declaration) != nullptr) { if (MacroDeclaration::DynamicCast(declaration) != nullptr) {
callable = Declarations::CreateMacro( callable = Declarations::CreateMacro(
generated_name, readable_name.str(), base::nullopt, type_signature, generated_name, readable_name.str(), false, base::nullopt,
declaration->transitioning, *body, true); type_signature, declaration->transitioning, *body, true);
} else if (IntrinsicDeclaration::DynamicCast(declaration) != nullptr) { } else if (IntrinsicDeclaration::DynamicCast(declaration) != nullptr) {
callable = Declarations::CreateIntrinsic(declaration->name, type_signature); callable = Declarations::CreateIntrinsic(declaration->name, type_signature);
} else { } else {
......
...@@ -154,19 +154,25 @@ const TypeAlias* Declarations::PredeclareTypeAlias(const Identifier* name, ...@@ -154,19 +154,25 @@ const TypeAlias* Declarations::PredeclareTypeAlias(const Identifier* name,
Macro* Declarations::CreateMacro( Macro* Declarations::CreateMacro(
std::string external_name, std::string readable_name, std::string external_name, std::string readable_name,
bool accessible_from_csa,
base::Optional<std::string> external_assembler_name, Signature signature, base::Optional<std::string> external_assembler_name, Signature signature,
bool transitioning, base::Optional<Statement*> body, bool is_user_defined) { bool transitioning, base::Optional<Statement*> body, bool is_user_defined) {
if (!accessible_from_csa) {
// TODO(tebbi): Switch to more predictable names to improve incremental
// compilation.
external_name += "_" + std::to_string(GlobalContext::FreshId());
}
if (!external_assembler_name) { if (!external_assembler_name) {
external_assembler_name = CurrentNamespace()->ExternalName(); external_assembler_name = CurrentNamespace()->ExternalName();
} }
return RegisterDeclarable(std::unique_ptr<Macro>( return RegisterDeclarable(std::unique_ptr<Macro>(
new Macro(std::move(external_name), std::move(readable_name), new Macro(std::move(external_name), std::move(readable_name),
std::move(*external_assembler_name), std::move(signature), std::move(*external_assembler_name), std::move(signature),
transitioning, body, is_user_defined))); transitioning, body, is_user_defined, accessible_from_csa)));
} }
Macro* Declarations::DeclareMacro( Macro* Declarations::DeclareMacro(
const std::string& name, const std::string& name, bool accessible_from_csa,
base::Optional<std::string> external_assembler_name, base::Optional<std::string> external_assembler_name,
const Signature& signature, bool transitioning, const Signature& signature, bool transitioning,
base::Optional<Statement*> body, base::Optional<std::string> op, base::Optional<Statement*> body, base::Optional<std::string> op,
...@@ -175,8 +181,9 @@ Macro* Declarations::DeclareMacro( ...@@ -175,8 +181,9 @@ Macro* Declarations::DeclareMacro(
ReportError("cannot redeclare macro ", name, ReportError("cannot redeclare macro ", name,
" with identical explicit parameters"); " with identical explicit parameters");
} }
Macro* macro = CreateMacro(name, name, std::move(external_assembler_name), Macro* macro = CreateMacro(name, name, accessible_from_csa,
signature, transitioning, body, is_user_defined); std::move(external_assembler_name), signature,
transitioning, body, is_user_defined);
Declare(name, macro); Declare(name, macro);
if (op) { if (op) {
if (TryLookupMacro(*op, signature.GetExplicitTypes())) { if (TryLookupMacro(*op, signature.GetExplicitTypes())) {
......
...@@ -78,13 +78,13 @@ class Declarations { ...@@ -78,13 +78,13 @@ class Declarations {
TypeDeclaration* type, TypeDeclaration* type,
bool redeclaration); bool redeclaration);
static Macro* CreateMacro(std::string external_name, static Macro* CreateMacro(std::string external_name,
std::string readable_name, std::string readable_name, bool accessible_from_csa,
base::Optional<std::string> external_assembler_name, base::Optional<std::string> external_assembler_name,
Signature signature, bool transitioning, Signature signature, bool transitioning,
base::Optional<Statement*> body, base::Optional<Statement*> body,
bool is_user_defined); bool is_user_defined);
static Macro* DeclareMacro( static Macro* DeclareMacro(
const std::string& name, const std::string& name, bool accessible_from_csa,
base::Optional<std::string> external_assembler_name, base::Optional<std::string> external_assembler_name,
const Signature& signature, bool transitioning, const Signature& signature, bool transitioning,
base::Optional<Statement*> body, base::Optional<std::string> op = {}, base::Optional<Statement*> body, base::Optional<std::string> op = {},
......
...@@ -80,6 +80,7 @@ class GlobalContext : public ContextualClass<GlobalContext> { ...@@ -80,6 +80,7 @@ class GlobalContext : public ContextualClass<GlobalContext> {
return Get().force_assert_statements_; return Get().force_assert_statements_;
} }
static Ast* ast() { return &Get().ast_; } static Ast* ast() { return &Get().ast_; }
static size_t FreshId() { return Get().fresh_id_++; }
private: private:
bool collect_language_server_data_; bool collect_language_server_data_;
...@@ -89,6 +90,7 @@ class GlobalContext : public ContextualClass<GlobalContext> { ...@@ -89,6 +90,7 @@ class GlobalContext : public ContextualClass<GlobalContext> {
std::vector<std::unique_ptr<Declarable>> declarables_; std::vector<std::unique_ptr<Declarable>> declarables_;
std::vector<std::string> cpp_includes_; std::vector<std::string> cpp_includes_;
GlobalClassList classes_; GlobalClassList classes_;
size_t fresh_id_ = 0;
friend class LanguageServerData; friend class LanguageServerData;
}; };
......
...@@ -491,7 +491,8 @@ base::Optional<ParseResult> MakeIntrinsicDeclaration( ...@@ -491,7 +491,8 @@ base::Optional<ParseResult> MakeIntrinsicDeclaration(
CallableNode* callable = nullptr; CallableNode* callable = nullptr;
if (body) { if (body) {
callable = MakeNode<TorqueMacroDeclaration>( callable = MakeNode<TorqueMacroDeclaration>(
false, name, base::Optional<std::string>{}, args, return_type, labels); false, name, base::Optional<std::string>{}, args, return_type, labels,
false);
} else { } else {
callable = MakeNode<IntrinsicDeclaration>(name, args, return_type); callable = MakeNode<IntrinsicDeclaration>(name, args, return_type);
} }
...@@ -506,6 +507,7 @@ base::Optional<ParseResult> MakeIntrinsicDeclaration( ...@@ -506,6 +507,7 @@ base::Optional<ParseResult> MakeIntrinsicDeclaration(
base::Optional<ParseResult> MakeTorqueMacroDeclaration( base::Optional<ParseResult> MakeTorqueMacroDeclaration(
ParseResultIterator* child_results) { ParseResultIterator* child_results) {
auto export_to_csa = child_results->NextAs<bool>();
auto transitioning = child_results->NextAs<bool>(); auto transitioning = child_results->NextAs<bool>();
auto operator_name = child_results->NextAs<base::Optional<std::string>>(); auto operator_name = child_results->NextAs<base::Optional<std::string>>();
auto name = child_results->NextAs<std::string>(); auto name = child_results->NextAs<std::string>();
...@@ -520,13 +522,15 @@ base::Optional<ParseResult> MakeTorqueMacroDeclaration( ...@@ -520,13 +522,15 @@ base::Optional<ParseResult> MakeTorqueMacroDeclaration(
auto return_type = child_results->NextAs<TypeExpression*>(); auto return_type = child_results->NextAs<TypeExpression*>();
auto labels = child_results->NextAs<LabelAndTypesVector>(); auto labels = child_results->NextAs<LabelAndTypesVector>();
auto body = child_results->NextAs<base::Optional<Statement*>>(); auto body = child_results->NextAs<base::Optional<Statement*>>();
MacroDeclaration* macro = MakeNode<TorqueMacroDeclaration>( MacroDeclaration* macro =
transitioning, name, operator_name, args, return_type, labels); MakeNode<TorqueMacroDeclaration>(transitioning, name, operator_name, args,
return_type, labels, export_to_csa);
Declaration* result; Declaration* result;
if (generic_parameters.empty()) { if (generic_parameters.empty()) {
if (!body) ReportError("A non-generic declaration needs a body."); if (!body) ReportError("A non-generic declaration needs a body.");
result = MakeNode<StandardDeclaration>(macro, *body); result = MakeNode<StandardDeclaration>(macro, *body);
} else { } else {
if (export_to_csa) ReportError("Cannot export generics to CSA.");
result = MakeNode<GenericDeclaration>(macro, generic_parameters, body); result = MakeNode<GenericDeclaration>(macro, generic_parameters, body);
} }
return ParseResult{result}; return ParseResult{result};
...@@ -641,7 +645,7 @@ base::Optional<ParseResult> MakeMethodDeclaration( ...@@ -641,7 +645,7 @@ base::Optional<ParseResult> MakeMethodDeclaration(
auto labels = child_results->NextAs<LabelAndTypesVector>(); auto labels = child_results->NextAs<LabelAndTypesVector>();
auto body = child_results->NextAs<Statement*>(); auto body = child_results->NextAs<Statement*>();
MacroDeclaration* macro = MakeNode<TorqueMacroDeclaration>( MacroDeclaration* macro = MakeNode<TorqueMacroDeclaration>(
transitioning, name, operator_name, args, return_type, labels); transitioning, name, operator_name, args, return_type, labels, false);
Declaration* result = MakeNode<StandardDeclaration>(macro, body); Declaration* result = MakeNode<StandardDeclaration>(macro, body);
return ParseResult{result}; return ParseResult{result};
} }
...@@ -1880,7 +1884,7 @@ struct TorqueGrammar : Grammar { ...@@ -1880,7 +1884,7 @@ struct TorqueGrammar : Grammar {
{Token("extern"), CheckIf(Token("transitioning")), Token("runtime"), {Token("extern"), CheckIf(Token("transitioning")), Token("runtime"),
&identifier, &typeListMaybeVarArgs, &optionalReturnType, Token(";")}, &identifier, &typeListMaybeVarArgs, &optionalReturnType, Token(";")},
AsSingletonVector<Declaration*, MakeExternalRuntime>()), AsSingletonVector<Declaration*, MakeExternalRuntime>()),
Rule({CheckIf(Token("transitioning")), Rule({CheckIf(Token("@export")), CheckIf(Token("transitioning")),
Optional<std::string>( Optional<std::string>(
Sequence({Token("operator"), &externalString})), Sequence({Token("operator"), &externalString})),
Token("macro"), &identifier, Token("macro"), &identifier,
......
...@@ -393,8 +393,9 @@ void ClassType::GenerateAccessors() { ...@@ -393,8 +393,9 @@ void ClassType::GenerateAccessors() {
Statement* load_body = Statement* load_body =
MakeNode<ReturnStatement>(MakeNode<FieldAccessExpression>( MakeNode<ReturnStatement>(MakeNode<FieldAccessExpression>(
parameter, MakeNode<Identifier>(field.name_and_type.name))); parameter, MakeNode<Identifier>(field.name_and_type.name)));
Declarations::DeclareMacro(load_macro_name, base::nullopt, load_signature, Declarations::DeclareMacro(load_macro_name, true, base::nullopt,
false, load_body, base::nullopt, false); load_signature, false, load_body, base::nullopt,
false);
// Store accessor // Store accessor
IdentifierExpression* value = MakeNode<IdentifierExpression>( IdentifierExpression* value = MakeNode<IdentifierExpression>(
...@@ -413,8 +414,9 @@ void ClassType::GenerateAccessors() { ...@@ -413,8 +414,9 @@ void ClassType::GenerateAccessors() {
MakeNode<FieldAccessExpression>( MakeNode<FieldAccessExpression>(
parameter, MakeNode<Identifier>(field.name_and_type.name)), parameter, MakeNode<Identifier>(field.name_and_type.name)),
value)); value));
Declarations::DeclareMacro(store_macro_name, base::nullopt, store_signature, Declarations::DeclareMacro(store_macro_name, true, base::nullopt,
false, store_body, base::nullopt, false); store_signature, false, store_body,
base::nullopt, false);
} }
} }
......
This diff is collapsed.
...@@ -50,6 +50,7 @@ def preprocess(input): ...@@ -50,6 +50,7 @@ def preprocess(input):
input = re.sub(r'(\n\s*\S[^\n]*\s)otherwise', input = re.sub(r'(\n\s*\S[^\n]*\s)otherwise',
r'\1_OtheSaLi', input) r'\1_OtheSaLi', input)
input = re.sub(r'@if\(', r'@iF(', input) input = re.sub(r'@if\(', r'@iF(', input)
input = re.sub(r'@export', r'@eXpOrT', input)
# Special handing of '%' for intrinsics, turn the percent # Special handing of '%' for intrinsics, turn the percent
# into a unicode character so that it gets treated as part of the # into a unicode character so that it gets treated as part of the
...@@ -85,6 +86,8 @@ def postprocess(output): ...@@ -85,6 +86,8 @@ def postprocess(output):
output = re.sub(r'_OtheSaLi', output = re.sub(r'_OtheSaLi',
r"otherwise", output) r"otherwise", output)
output = re.sub(r'@iF\(', r'@if(', output) output = re.sub(r'@iF\(', r'@if(', output)
output = re.sub(r'@eXpOrT',
r"@export", output)
while True: while True:
old = output old = output
......
...@@ -30,7 +30,7 @@ syn keyword torqueFunction macro builtin runtime intrinsic ...@@ -30,7 +30,7 @@ syn keyword torqueFunction macro builtin runtime intrinsic
syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast syn keyword torqueKeyword cast convert from_constexpr min max unsafe_cast
syn keyword torqueLabel case syn keyword torqueLabel case
syn keyword torqueMatching try label catch syn keyword torqueMatching try label catch
syn keyword torqueModifier extern javascript constexpr transitioning transient weak syn keyword torqueModifier extern javascript constexpr transitioning transient weak export
syn match torqueNumber /\v<[0-9]+(\.[0-9]*)?>/ syn match torqueNumber /\v<[0-9]+(\.[0-9]*)?>/
syn match torqueNumber /\v<0x[0-9a-fA-F]+>/ syn match torqueNumber /\v<0x[0-9a-fA-F]+>/
syn keyword torqueOperator operator syn keyword torqueOperator operator
......
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
}, },
{ {
"name": "keyword.other.torque", "name": "keyword.other.torque",
"match": "\\b(constexpr|macro|builtin|runtime|intrinsic|javascript|implicit|deferred|label|labels|tail|let|generates|weak|extern|const|typeswitch|case|transient|transitioning|operator|namespace)\\b" "match": "\\b(constexpr|macro|builtin|runtime|intrinsic|javascript|implicit|deferred|label|labels|tail|let|generates|weak|extern|const|typeswitch|case|transient|transitioning|operator|namespace|export)\\b"
}, },
{ {
"name": "keyword.operator.torque", "name": "keyword.operator.torque",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment