-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
closes #1448 #1456
closes #1448 #1456
Conversation
WalkthroughThe changes involve significant refactoring in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs (8 hunks)
- src/ScriptEngine/Machine/Core.cs (0 hunks)
💤 Files with no reviewable changes (1)
- src/ScriptEngine/Machine/Core.cs
🔇 Additional comments (9)
src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs (9)
262-264
: Update: ReplacingConstDefinition
withBslPrimitiveValue
in default parameter handlingThe code now uses
CreateConstValue
andGetConstNumber(BslPrimitiveValue)
instead ofConstDefinition
, streamlining the process of handling default parameter values and enhancing code clarity.
Line range hint
684-688
: Update: Simplifying method resolution with updated constant handlingBy using
GetConstNumber(DataType.String, name.GetIdentifier())
, the method resolution process is streamlined, aligning with the revised constant management approach and improving maintainability.
694-696
: Update: Enhanced property resolution using consistent constant retrievalThe change to utilize
GetConstNumber(DataType.String, identifier)
in property resolution ensures consistency in how constants are handled throughout the codebase.
Line range hint
977-984
: Refactor: Consistent constant handling in object creationIn the
MakeNewObjectStatic
method, usingGetConstNumber(DataType.String, node.TypeNameNode.GetIdentifier())
ensures that type names are handled consistently as constants, enhancing code uniformity.
1091-1094
: Update: Streamlining constant processing inVisitConstant
The method now leverages
CreateConstValue
andGetConstNumber(BslPrimitiveValue)
to process constants, eliminating the need forConstDefinition
and simplifying the constant handling mechanism.
Line range hint
1121-1130
: Enhancement: Improved annotation parameter handlingBy creating a
BslPrimitiveValue
for annotation parameters and retrieving its constant index, the code enhances consistency and clarity in annotation processing.
1149-1162
: Addition: ImplementingCreateConstValue
for unified constant creationThe new
CreateConstValue
method effectively mapsLexemType
toDataType
and parses lexem content to generate aBslPrimitiveValue
, promoting code reuse and simplification.
1165-1170
: Enhancement: OverloadedGetConstNumber
method for flexibilityAdding an overloaded
GetConstNumber(DataType type, string presentation)
method allows for direct constant retrieval using data type and presentation string, increasing the flexibility of constant management.
1172-1180
: Optimization: Efficient constant storage inGetConstNumber
The
GetConstNumber(BslPrimitiveValue value)
method now checks for existing constants before adding new ones, preventing duplicates and optimizing memory usage.
|
||
AddCommand(OperationCode.PushConst, GetConstNumber(undefConst)); | ||
} | ||
AddCommand(OperationCode.PushConst, GetConstNumber(DataType.Undefined, "Неопределено")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: Hardcoded string "Неопределено" may cause localization concerns
Using the Russian string "Неопределено" for the undefined value might lead to localization issues if the codebase needs to support multiple languages.
Consider using a language-neutral representation or retrieving the appropriate localized string to ensure better internationalization support.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- кролик прав насчет локализации
- presentation для Неопределено = "" (пустая строка)
- нужно ли хранить для констант presentation, или будет достаточно ToString?
- IMHO давно бы стоило добавить в ВМ опкоды PushUndef, PushTrue/False, да и PushInt можно
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mr-Rm, спасибо за ваш комментарий. Вы правы, для значения 'Неопределено'
поле presentation
должно быть пустой строкой (""
). Это поможет избежать проблем с локализацией.
Относительно необходимости хранения presentation
для констант: если метод ToString()
может предоставить необходимое представление значения, возможно, хранение отдельного поля presentation
не требуется. Это упростит код и снизит использование памяти.
Идея добавить опкоды PushUndef
, PushTrue/False
и PushInt
в виртуальную машину звучит отлично. Это может повысить производительность и оптимизировать работу кода.
(^_^/)
✏️ Learnings added
Learnt from: Mr-Rm
PR: EvilBeaver/OneScript#1456
File: src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs:308-308
Timestamp: 2024-10-01T08:10:34.026Z
Learning: Для значения `'Неопределено'` поле `presentation` должно быть пустой строкой (`""`).
Learnt from: Mr-Rm
PR: EvilBeaver/OneScript#1456
File: src/ScriptEngine/Compiler/StackMachineCodeGenerator.cs:308-308
Timestamp: 2024-10-01T08:10:34.026Z
Learning: Если метод `ToString()` обеспечивает достаточное представление константы, возможно, хранение поля `presentation` не требуется.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
ConstDefinition
struct to simplify constant handling.