ani-lang / anilang-core

Core functionality of Ani language.
Other
1 stars 0 forks source link

remove all String scopes and replace them by Objects #146

Open github-actions[bot] opened 1 year ago

github-actions[bot] commented 1 year ago

118

in this example we can't just replace it by the object since the string is used to be

compared and the object generates the String every time it needs it.

A cache type scope must be implemented to avoid multiple calculation of the same value.

https://github.com/ani-lang/anilang-core/blob/d80750d73eec828c53f86f590a8fdb890d74473c/anilang-context/src/main/java/com/anilang/context/analysis/TypeResolveListener.java#L44


     *
     * @param context Context.
     */
    TypeResolveListener(final AniContext context) {
        this.context = context;
    }

    @Override
    public void enterStructBodyMember(final AniParser.StructBodyMemberContext rule) {
        final String raw = new RuleType(rule.type()).raw();
        // @checkstyle MethodBodyCommentsCheck (10 lines)
        // TODO remove all String scopes and replace them by Objects
        // #118
        // in this example we can't just replace it by the object since the string is used to be
        // compared and the object generates the String every time it needs it.
        // A cache type scope must be implemented to avoid multiple calculation of the same value.
        final String scope = new FormattedScope(
            new ListParents(
                rule.variableDeclaratorId(),