diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_01_09_2024,_16_17_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_01_09_2024,_16_17_[Changes]/shelved.patch new file mode 100644 index 0000000..0d9c630 --- /dev/null +++ b/.idea/shelf/Uncommitted_changes_before_Update_at_01_09_2024,_16_17_[Changes]/shelved.patch @@ -0,0 +1,205 @@ +Index: src/root/compiler/evaluation/type_only.rs +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>use crate::root::compiler::evaluation::function_only;\nuse crate::root::compiler::global_tracker::GlobalTracker;\nuse crate::root::compiler::local_variable_table::LocalVariableTable;\nuse crate::root::errors::evaluable_errors::EvalErrs;\nuse crate::root::errors::evaluable_errors::EvalErrs::ExpectedReference;\nuse crate::root::errors::name_resolver_errors::NRErrs;\nuse crate::root::errors::WErr;\nuse crate::root::name_resolver::name_resolvers::{GlobalTable, NameResult};\nuse crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, EvaluableTokens};\nuse crate::root::parser::parse_function::parse_operator::{OperatorTokens, PrefixOrInfixEx};\nuse crate::root::parser::parse_name::SimpleNameToken;\nuse crate::root::shared::common::{FunctionID, Indirection, TypeRef};\n\nfn handle_name_result(name: &SimpleNameToken, name_result: NameResult) -> Result {\n Ok(match name_result {\n NameResult::Function(_) => {\n return WErr::ne(\n EvalErrs::FunctionMustBeCalled(name.name().clone()),\n name.location().clone(),\n )\n }\n NameResult::Type(t) => {\n t.immediate_single()\n // println!(\"> {}\", name.name());\n // std::process::exit(123);\n // return WErr::ne(\n // EvalErrs::CannotEvalStandaloneType(name.name().clone()),\n // name.location().clone(),\n // )\n }\n NameResult::Variable(address) => address.type_ref().clone(),\n NameResult::File(_) => {\n return WErr::ne(\n EvalErrs::ExpectedTypeNotImportedFile(name.name().clone()),\n name.location().clone(),\n )\n }\n })\n}\n\n/// Evaluates the type `et` evaluates to. Does not generate any assembly.\npub fn compile_evaluable_type_only(\n fid: FunctionID,\n et: &EvaluableToken,\n local_variables: &mut LocalVariableTable,\n global_table: &mut GlobalTable,\n global_tracker: &mut GlobalTracker,\n) -> Result {\n let ets = et.token();\n\n Ok(match ets {\n EvaluableTokens::Name(name, containing_class) => handle_name_result(\n name,\n global_table.resolve_name(\n name,\n None,\n containing_class.as_ref(),\n local_variables,\n global_tracker,\n )?,\n )?,\n EvaluableTokens::Literal(literal) => {\n let tid = literal.literal().default_type();\n // TODO: Don't use 0 here\n TypeRef::new(tid, 0, Indirection(0))\n }\n EvaluableTokens::InfixOperator(lhs, op, _) => {\n // if op.is_prefix_opt_t() {\n // return Err(WErr::n(EvalErrs::FoundPrefixNotInfixOp(op.operator().to_str().to_string()), op.location().clone()));\n // }\n\n // let (mut code, lhs) = compile_evaluable(fid, lhs, local_variables, global_table, global_tracker)?;\n let lhs_type = compile_evaluable_type_only(\n fid,\n lhs,\n local_variables,\n global_table,\n global_tracker,\n )?;\n\n // code += \"\\n\";\n let op_fn = global_table.get_operator_function(\n *lhs_type.type_id(),\n op,\n PrefixOrInfixEx::Infix,\n )?;\n let signature = global_table.get_function_signature(op_fn);\n signature.return_type().as_ref().unwrap().clone()\n }\n EvaluableTokens::PrefixOperator(op, lhs) => {\n let lhs_type = compile_evaluable_type_only(\n fid,\n lhs,\n local_variables,\n global_table,\n global_tracker,\n )?;\n\n match op.operator() {\n OperatorTokens::Reference => return Ok(lhs_type.plus_one_indirect()),\n OperatorTokens::Multiply => {\n if !lhs_type.indirection().has_indirection() {\n return WErr::ne(\n ExpectedReference(global_table.get_type_name(&lhs_type)),\n lhs.location().clone(),\n );\n }\n return Ok(lhs_type.minus_one_indirect());\n }\n _ => {}\n };\n\n // code += \"\\n\";\n let op_fn = global_table.get_operator_function(\n *lhs_type.type_id(),\n op,\n PrefixOrInfixEx::Prefix,\n )?;\n let signature = global_table.get_function_signature(op_fn);\n signature.return_type().as_ref().unwrap().clone()\n }\n EvaluableTokens::DynamicAccess {\n parent: inner,\n section: access,\n } => {\n let t = compile_evaluable_type_only(\n fid,\n inner,\n local_variables,\n global_table,\n global_tracker,\n )?;\n\n let t = global_table.get_type(*t.type_id());\n let attribs = t.get_attributes(access.location())?;\n\n let mut out = None;\n\n for (_, name, t) in attribs {\n if name.name() == access.name() {\n out = Some(t.clone());\n break;\n }\n }\n\n if let Some(out) = out {\n out.plus_one_indirect()\n } else {\n return WErr::ne(\n EvalErrs::TypeDoesntHaveAttribute(\n global_table.get_type_name(&t.id().immediate_single()),\n access.name().clone(),\n ),\n access.location().clone(),\n );\n }\n }\n EvaluableTokens::StaticAccess {\n parent: p,\n section: n,\n } => {\n match p.token() {\n EvaluableTokens::Name(file_name, containing_class) => {\n if let Some(file) = global_table.get_imported_file(file_name, global_tracker) {\n return handle_name_result(\n n,\n global_table.resolve_name(\n n,\n Some(file),\n containing_class.as_ref(),\n local_variables,\n global_tracker,\n )?,\n );\n };\n }\n EvaluableTokens::StaticAccess {\n parent,\n section: file_name,\n } => {\n if let EvaluableTokens::Name(folder_name, containing_class) = parent.token() {\n if let Some(file) = global_table.get_file_from_folder(\n folder_name.name(),\n file_name.name(),\n global_tracker,\n ) {\n return handle_name_result(\n n,\n global_table.resolve_name(\n n,\n Some(file),\n containing_class.as_ref(),\n local_variables,\n global_tracker,\n )?,\n );\n }\n }\n }\n _ => (),\n }\n\n return WErr::ne(\n NRErrs::CannotFindConstantAttribute(n.name().clone()),\n n.location().clone(),\n );\n } // Accessed methods must be called\n EvaluableTokens::FunctionCall {\n function: inner,\n args: _args,\n } => {\n let (_slf, ifid, _) = function_only::compile_evaluable_function_only(\n fid,\n inner,\n local_variables,\n global_table,\n global_tracker,\n )?;\n\n let signature = global_table.get_function_signature(ifid);\n let Some(return_type) = signature.return_type().clone() else {\n return WErr::ne(EvalErrs::ExpectedNotNone, et.location().clone());\n };\n return_type\n }\n EvaluableTokens::StructInitialiser(struct_init) => {\n let mut t = global_table.resolve_to_type_ref(struct_init.name(), None)?;\n if *struct_init.heap_alloc() {\n t = t.plus_one_indirect();\n }\n t\n }\n EvaluableTokens::None => {\n return WErr::ne(EvalErrs::ExpectedNotNone, et.location().clone());\n }\n })\n}\n +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/root/compiler/evaluation/type_only.rs b/src/root/compiler/evaluation/type_only.rs +--- a/src/root/compiler/evaluation/type_only.rs (revision 61cc3af4f0f06c1b7513a3acd51a55917b913396) ++++ b/src/root/compiler/evaluation/type_only.rs (date 1723917091750) +@@ -182,6 +182,7 @@ + if let Some(file) = global_table.get_file_from_folder( + folder_name.name(), + file_name.name(), ++ + global_tracker, + ) { + return handle_name_result( +Index: .idea/workspace.xml +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP +<+>\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n {\n "lastFilter": {\n "state": "OPEN",\n "assignee": "Robert-M-Lucas"\n }\n}\n \n \n \n {\n "selectedUrlAndAccountId": {\n "url": "https://github.com/Robert-M-Lucas/whython-8.git",\n "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"\n }\n}\n \n \n \n \n {\n "customColor": "",\n "associatedIndex": 4\n}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 1714088144106\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n