Skip to content

Migrate to dart3 #1

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

Merged
merged 10 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
format-and-analyze-and-test:
runs-on: ubuntu-latest
container:
image: google/dart:latest
image: dart:3.5.4

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: install dependencies
run: pub get
run: dart pub get

- name: dartfmt
run: dart format . --output=none --set-exit-if-changed

- name: analyzer
run: dartanalyzer --fatal-warnings --fatal-infos .
run: dart analyze --fatal-warnings --fatal-infos .

- name: test
run: pub run test ./
run: dart test ./
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dart 3.5.4
16 changes: 4 additions & 12 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.

analyzer:
strong-mode:
implicit-casts: false
implicit-dynamic: false
# exclude:
# - path/to/excluded/files/**
language:
strict-casts: true
strict-raw-types: true

# https://dart-lang.github.io/linter/lints/options/options.html
linter:
rules:
- always_declare_return_types
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_bool_literals_in_conditional_expressions
Expand All @@ -38,8 +35,6 @@ linter:
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
- avoid_returning_this
- avoid_setters_without_getters
Expand Down Expand Up @@ -75,14 +70,12 @@ linter:
- file_names
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- collection_methods_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- lines_longer_than_80_chars
- list_remove_unrelated_type
- literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
Expand Down Expand Up @@ -111,7 +104,6 @@ linter:
- prefer_const_literals_to_create_immutables
- prefer_constructors_over_static_methods
- prefer_contains
- prefer_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
Expand Down
4 changes: 2 additions & 2 deletions lib/monkey/evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object.Object _evalIntegerInfixExpr(
} else if (ope == ast.Operator.gt) {
return (left.value > right.value).toBooleanObject();
} else if (ope == ast.Operator.equal) {
return (left.monkeyEqual(right)).toBooleanObject();
return left.monkeyEqual(right).toBooleanObject();
} else if (ope == ast.Operator.notEqual) {
return (!left.monkeyEqual(right)).toBooleanObject();
} else {
Expand Down Expand Up @@ -439,7 +439,7 @@ Environment _extendMacroEnv(object.Macro macro, List<object.Quote> args) {
}

List<object.Quote> _quoteArgs(ast.Call call) =>
call.args.map((arg) => object.Quote(arg)).toList();
call.args.map(object.Quote.new).toList();

void defineMacros(ast.Program program, Environment env) {
program.statements
Expand Down
2 changes: 2 additions & 0 deletions lib/monkey/evaluator/builtin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ extension BuiltinFunction on object.Builtin {
return _builtinPush;
case 'puts':
return _builtinPuts;
default:
return null;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions lib/monkey/evaluator/object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ class Hash extends Object {
return false;
}

if (pair.value is MonkeyEq && otherValue is MonkeyEq) {
if (!pair.value.monkeyEqual(otherValue)) {
return false;
}
if (!pair.value.monkeyEqual(otherValue)) {
return false;
}
}

Expand Down
Loading