Skip to content

Commit

Permalink
Merge branch 'develop' into wip/akirathan/nan-in-map-5833
Browse files Browse the repository at this point in the history
# Conflicts:
#	distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso
  • Loading branch information
Akirathan committed Apr 17, 2023
2 parents aebbf0b + f720bd2 commit c5b5696
Show file tree
Hide file tree
Showing 29 changed files with 902 additions and 893 deletions.
16 changes: 8 additions & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ Cargo.toml
/std-bits/ @jdunkerley @radeusgd

# Cloud Dashboard & Authentication
/app/ide-desktop/dashboard @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/content @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/client @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/types @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/common @PabloBuchu @indiv0 @somebody1234

# Eslint configuration
/app/ide-desktop/esbuild-plugin-copy-directories @somebody1234
/app/ide-desktop/lib/dashboard @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/lib/content @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/lib/client @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/lib/types @PabloBuchu @indiv0 @somebody1234
/app/ide-desktop/lib/common @PabloBuchu @indiv0 @somebody1234

# Eslint & Esbuild Configuration
/app/ide-desktop/lib/esbuild-plugin-copy-directories @somebody1234
/app/ide-desktop/eslint.config.js @somebody1234
/app/ide-desktop/utils.ts @somebody1234
1 change: 0 additions & 1 deletion .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ pull_request_rules:
conditions:
- or:
- "label=CI: Keep up to date"
- "label=CI: Ready to merge"
actions:
update:
16 changes: 0 additions & 16 deletions app/gui/src/controller/graph/executed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,6 @@ impl Handle {
Ok(node_info)
}

/// Enter node by given ID.
///
/// This will cause pushing a new stack frame to the execution context and changing the graph
/// controller to point to a new definition.
///
/// Fails if there's no information about target method pointer (e.g. because node value hasn't
/// been yet computed by the engine) or if method graph cannot be created (see
/// `graph_for_method` documentation).
pub async fn enter_node(&self, node: double_representation::node::Id) -> FallibleResult {
let computed_value = self.node_computed_value(node)?;
let method_pointer = computed_value.method_call.as_ref().ok_or(NoResolvedMethod(node))?;
let definition = method_pointer.clone();
let local_call = LocalCall { call: node, definition };
self.enter_method_pointer(&local_call).await
}

/// Leave the current node. Reverse of `enter_node`.
///
/// Fails if this execution context is already at the stack's root or if the parent graph
Expand Down
3 changes: 3 additions & 0 deletions app/gui/src/model/execution_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ pub trait API: Debug {
/// Restart the program execution.
#[allow(clippy::needless_lifetimes)] // Note: Needless lifetimes
fn restart<'a>(&'a self) -> BoxFuture<'a, FallibleResult>;

/// Adjust method pointers after the project rename action.
fn rename_method_pointers(&self, old_project_name: String, new_project_name: String);
}

// Note: Needless lifetimes
Expand Down
21 changes: 18 additions & 3 deletions app/gui/src/model/execution_context/plain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct InvalidVisualizationId(VisualizationId);
#[derive(Debug)]
pub struct ExecutionContext {
/// A name of definition which is a root call of this context.
pub entry_point: MethodPointer,
pub entry_point: RefCell<MethodPointer>,
/// Local call stack.
stack: RefCell<Vec<LocalCall>>,
/// Set of active visualizations.
Expand All @@ -65,7 +65,8 @@ pub struct ExecutionContext {

impl ExecutionContext {
/// Create new execution context
pub fn new(entry_point: MethodPointer) -> Self {
pub fn new(method_pointer: MethodPointer) -> Self {
let entry_point = RefCell::new(method_pointer);
let stack = default();
let visualizations = default();
let computed_value_info_registry = default();
Expand Down Expand Up @@ -166,7 +167,7 @@ impl model::execution_context::API for ExecutionContext {
if let Some(top_frame) = self.stack.borrow().last() {
top_frame.definition.clone()
} else {
self.entry_point.clone()
self.entry_point.borrow().clone()
}
}

Expand Down Expand Up @@ -258,6 +259,20 @@ impl model::execution_context::API for ExecutionContext {
fn restart(&self) -> BoxFuture<FallibleResult> {
futures::future::ready(Ok(())).boxed_local()
}

fn rename_method_pointers(&self, old_project_name: String, new_project_name: String) {
let update_method_pointer = |method_pointer: &mut MethodPointer| {
let module = method_pointer.module.replacen(&old_project_name, &new_project_name, 1);
let defined_on_type =
method_pointer.defined_on_type.replacen(&old_project_name, &new_project_name, 1);
let name = method_pointer.name.clone();
MethodPointer { module, defined_on_type, name }
};
self.entry_point.replace_with(update_method_pointer);
self.stack.borrow_mut().iter_mut().for_each(|local_call| {
local_call.definition = update_method_pointer(&mut local_call.definition)
});
}
}


Expand Down
9 changes: 7 additions & 2 deletions app/gui/src/model/execution_context/synchronized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ExecutionContext {
}

fn push_root_frame(&self) -> impl Future<Output = FallibleResult> {
let method_pointer = self.model.entry_point.clone();
let method_pointer = self.model.entry_point.borrow().clone();
let this_argument_expression = default();
let positional_arguments_expressions = default();

Expand Down Expand Up @@ -304,6 +304,10 @@ impl model::execution_context::API for ExecutionContext {
}
.boxed_local()
}

fn rename_method_pointers(&self, old_project_name: String, new_project_name: String) {
self.model.rename_method_pointers(old_project_name, new_project_name);
}
}

impl Drop for ExecutionContext {
Expand Down Expand Up @@ -433,7 +437,8 @@ pub mod test {
let f = Fixture::new();
assert_eq!(f.data.context_id, f.context.id);
let name_in_data = f.data.module_qualified_name();
let name_in_ctx_model = QualifiedName::try_from(&f.context.model.entry_point.module);
let name_in_ctx_model =
QualifiedName::try_from(&f.context.model.entry_point.borrow().module);
assert_eq!(name_in_data, name_in_ctx_model.unwrap());
assert_eq!(Vec::<LocalCall>::new(), f.context.model.stack_items().collect_vec());
}
Expand Down
14 changes: 12 additions & 2 deletions app/gui/src/model/project/synchronized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ impl ExecutionContextsRegistry {
pub fn insert(&self, context: Rc<execution_context::Synchronized>) {
self.0.borrow_mut().insert(context.id(), context);
}

/// Adjust execution contexts after renaming the project.
pub fn rename_project(&self, old_name: impl Str, new_name: impl Str) {
self.0.borrow().iter().for_each(|(_, execution_context)| {
execution_context
.rename_method_pointers(old_name.as_ref().to_owned(), new_name.as_ref().to_owned());
});
}
}


Expand Down Expand Up @@ -695,12 +703,14 @@ impl model::project::API for Project {

fn rename_project(&self, name: String) -> BoxFuture<FallibleResult> {
async move {
let referent_name = name.as_str().try_into()?;
let old_name = self.properties.borrow_mut().name.project.clone_ref();
let referent_name = name.to_im_string();
let project_manager = self.project_manager.as_ref().ok_or(ProjectManagerUnavailable)?;
let project_id = self.properties.borrow().id;
let project_name = ProjectName::new_unchecked(name);
project_manager.rename_project(&project_id, &project_name).await?;
self.properties.borrow_mut().name.project = referent_name;
self.properties.borrow_mut().name.project = referent_name.clone_ref();
self.execution_contexts.rename_project(old_name, referent_name);
Ok(())
}
.boxed_local()
Expand Down
18 changes: 1 addition & 17 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Any.enso
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,7 @@ type Any
a = 7 * 21
a == 147
== : Any -> Boolean
== self that =
case Meta.is_same_object self that of
True -> True
False ->
eq_self = Comparable.from self
eq_that = Comparable.from that
similar_type = Meta.is_same_object eq_self eq_that
case similar_type of
False -> False
True ->
case Meta.is_same_object eq_self Default_Comparator of
# Shortcut for objects with Default_Comparator, because of the performance.
True -> Comparable.equals_builtin self that
False ->
case eq_self.compare self that of
Ordering.Equal -> True
_ -> False
== self that = @Builtin_Method "Any.=="

## ALIAS Inequality

Expand Down
10 changes: 1 addition & 9 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/Ordering.enso
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,14 @@ type Comparable
ordering = Ordering.compare atom that
if ordering.is_error then Nothing else ordering.to_sign

## PRIVATE
A custom comparator is any comparator that is different than the
default ones.
has_custom_comparator : Atom -> Boolean
has_custom_comparator atom =
comp = Comparable.from atom
(comp.is_a Default_Comparator).not

## PRIVATE
Default implementation of a _comparator_.
@Builtin_Type
type Default_Comparator
## PRIVATE
compare : Any -> Any -> (Ordering|Nothing)
compare x y =
case Comparable.equals_builtin x y of
case Any.== x y of
True -> Ordering.Equal
False ->
case Comparable.less_than_builtin x y of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3622,7 +3622,7 @@ class RuntimeServerTest
contextId,
Seq(
Api.ExecutionResult.Diagnostic.error(
"Type error: expected `that` to be Number, but got quux (Unresolved_Symbol).",
"Type error: expected `that` to be Number, but got Function.",
Some(mainFile),
Some(model.Range(model.Position(11, 8), model.Position(11, 17))),
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {

var benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
var code = """
import Standard.Base.Any.Any
avg fn len =
sum acc i = if i == len then acc else
sum (acc + fn i) i+1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
var benchmarkName = params.getBenchmark().replaceFirst(".*\\.", "");
var codeBuilder = new StringBuilder("""
import Standard.Base.Data.Range.Extensions
import Standard.Base.Any.Any
type Node
C1 f1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void initializeBenchmark(BenchmarkParams params) throws Exception {
var code = """
import Standard.Base.Data.Vector.Vector
import Standard.Base.Data.Array_Proxy.Array_Proxy
import Standard.Base.Any.Any
avg arr =
sum acc i = if i == arr.length then acc else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class AtomFixtures extends DefaultInterpreterRunner {

val millionElementList = eval(
s"""import Standard.Base.Data.List.List
|import Standard.Base.Any.Any
|
|main =
| generator fn acc i end = if i == end then acc else @Tail_Call generator fn (fn acc i) i+1 end
Expand All @@ -17,7 +16,6 @@ class AtomFixtures extends DefaultInterpreterRunner {

val generateListCode =
"""import Standard.Base.Data.List.List
|import Standard.Base.Any.Any
|
|main = length ->
| generator = acc -> i -> if i == 0 then acc else @Tail_Call generator (List.Cons i acc) (i - 1)
Expand All @@ -29,7 +27,6 @@ class AtomFixtures extends DefaultInterpreterRunner {

val generateListQualifiedCode =
"""import Standard.Base.Data.List.List
|import Standard.Base.Any.Any
|
|main = length ->
| generator = acc -> i -> if i == 0 then acc else @Tail_Call generator (List.Cons i acc) (i - 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class CallableFixtures extends DefaultInterpreterRunner {
val sumTCOfromCallCode =
"""
|from Standard.Base.Data.Numbers import all
|import Standard.Base.Any.Any
|
|type Foo
|
Expand All @@ -23,8 +22,7 @@ class CallableFixtures extends DefaultInterpreterRunner {


val sumTCOmethodCallCode =
"""import Standard.Base.Any.Any
|
"""
|summator = acc -> current ->
| if current == 0 then acc else @Tail_Call summator (acc + current) (current - 1)
|
Expand All @@ -35,8 +33,7 @@ class CallableFixtures extends DefaultInterpreterRunner {
val sumTCOmethodCall = getMain(sumTCOmethodCallCode)

val sumTCOmethodCallWithNamedArgumentsCode =
"""import Standard.Base.Any.Any
|
"""
|summator = acc -> current ->
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
|
Expand All @@ -48,8 +45,7 @@ class CallableFixtures extends DefaultInterpreterRunner {
getMain(sumTCOmethodCallWithNamedArgumentsCode)

val sumTCOmethodCallWithDefaultedArgumentsCode =
"""import Standard.Base.Any.Any
|
"""
|summator = (acc = 0) -> current ->
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class NamedDefaultedArgumentFixtures extends DefaultInterpreterRunner {
val hundredMillion: Long = 100000000

val sumTCOWithNamedArgumentsCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = acc -> current ->
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
Expand All @@ -18,8 +17,7 @@ class NamedDefaultedArgumentFixtures extends DefaultInterpreterRunner {
val sumTCOWithNamedArguments = getMain(sumTCOWithNamedArgumentsCode)

val sumTCOWithDefaultedArgumentsCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = (acc = 0) -> current ->
| if current == 0 then acc else @Tail_Call summator (current = current - 1) (acc = acc + current)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class RecursionFixtures extends DefaultInterpreterRunner {
val hundred: Long = 100

val sumTCOCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = acc -> current ->
| if current == 0 then acc else @Tail_Call summator acc+current current-1
Expand All @@ -21,8 +20,7 @@ class RecursionFixtures extends DefaultInterpreterRunner {
val sumTCO = getMain(sumTCOCode)

val sumTCOFoldLikeCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = acc -> i -> f ->
| if i == 0 then acc else @Tail_Call summator (f acc i) (i - 1) f
Expand All @@ -32,8 +30,7 @@ class RecursionFixtures extends DefaultInterpreterRunner {
val sumTCOFoldLike = getMain(sumTCOFoldLikeCode)

val sumRecursiveCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = i -> if i == 0 then 0 else i + summator (i - 1)
| res = summator sumTo
Expand All @@ -42,8 +39,7 @@ class RecursionFixtures extends DefaultInterpreterRunner {
val sumRecursive = getMain(sumRecursiveCode)

val oversaturatedRecursiveCallTCOCode =
"""import Standard.Base.Any.Any
|
"""
|main = sumTo ->
| summator = acc -> i -> f ->
| if i == 0 then acc else @Tail_Call summator (f acc i) (i - 1) f
Expand Down
Loading

0 comments on commit c5b5696

Please sign in to comment.