From cd59d801812ee553957b89337e9ec4ef183a8fdb Mon Sep 17 00:00:00 2001 From: LostbBlizzard <106630000+LostbBlizzard@users.noreply.github.com> Date: Sat, 24 Aug 2024 15:10:10 -0700 Subject: [PATCH] fixed template using private class --- .../Compilation/Front/SystematicAnalysis.hpp | 96 ++++++++++++++++--- 1 file changed, 83 insertions(+), 13 deletions(-) diff --git a/UCodeLang/UCodeLang/Compilation/Front/SystematicAnalysis.hpp b/UCodeLang/UCodeLang/Compilation/Front/SystematicAnalysis.hpp index b5342ca5..b8bd7115 100644 --- a/UCodeLang/UCodeLang/Compilation/Front/SystematicAnalysis.hpp +++ b/UCodeLang/UCodeLang/Compilation/Front/SystematicAnalysis.hpp @@ -1261,7 +1261,7 @@ class SystematicAnalysis void OnEnum(const EnumNode& node); void OnNamespace(const NamespaceNode& node); void OnAttributeNode(const AttributeNode& node, OptionalRef> Out = {}); - void OnAttributesNode(const Vector>& nodes,OptionalRef> Out = {}); + void OnAttributesNode(const Vector>& nodes, OptionalRef> Out = {}); void OnDeclareVariablenode(const DeclareVariableNode& node, DeclareStaticVariableNode_t type); bool IsEnableAttribute(const Symbol& symbol); @@ -1516,7 +1516,7 @@ class SystematicAnalysis { bool IsgenericInstantiation = false; }; - void Assembly_AddClass(const Vector>& attributes, const NeverNullPtr ClassSyb,Optional Extra = {}); + void Assembly_AddClass(const Vector>& attributes, const NeverNullPtr ClassSyb, Optional Extra = {}); ReflectionTypeInfo Assembly_ConvertToType(const TypeSymbol& Type); void Assembly_AddEnum(const NeverNullPtr ClassSyb); @@ -1563,7 +1563,7 @@ class SystematicAnalysis - void Type_Convert(const TypeNode& V, TypeSymbol& Out,bool allowtraitasself = false); + void Type_Convert(const TypeNode& V, TypeSymbol& Out, bool allowtraitasself = false); NullablePtr Generic_InstantiateOrFindGenericSymbol(const NeverNullPtr Token, const UseGenericsNode& GenericsVals, const String_view& Name); @@ -1729,7 +1729,7 @@ class SystematicAnalysis void Symbol_Update_ThreadAndStatic_ToFixedTypes(NeverNullPtr Sym); void Symbol_Update_ForType_ToFixedTypes(NeverNullPtr Sym); void Symbol_Update_ClassField_ToFixedTypes(NeverNullPtr Sym); - + void Symbol_Update_Sym_ToFixedTypes(NeverNullPtr Sym); Optional Type_GetSize(const TypeSymbol& Type) @@ -1757,7 +1757,7 @@ class SystematicAnalysis Vector Type_FindForTypeFuncions(const TypeSymbol& ThisType); Vector Type_FindForTypeFuncions(const TypeSymbol& ThisType, const String& FuncionName); - Get_FuncInfo Type_GetFunc(const TypeSymbol& Name, const ValueParametersNode& Pars,const NeverNullPtr token); + Get_FuncInfo Type_GetFunc(const TypeSymbol& Name, const ValueParametersNode& Pars, const NeverNullPtr token); Get_FuncInfo Type_GetFunc(const ScopedNameNode& Name, const ValueParametersNode& Pars, TypeSymbol Ret); Optional> Type_FuncinferGenerics(Vector& GenericInput, const Vector& ValueTypes @@ -1784,7 +1784,7 @@ class SystematicAnalysis const OptionalRef> GetTypePackFromInputPar(const Vector& Pars); ParInfo GetParInfoResolveTypePack(size_t i, const Vector& Pars, const OptionalRef> TypePack); size_t GetParCountResolveTypePack(const Vector& Pars); - + int Type_GetCompatibleScore(const ParInfo& ParFunc, const ParInfo& Value); int Type_GetCompatibleScore(const IsCompatiblePar& Func, const Vector& ValueTypes); @@ -1830,7 +1830,7 @@ class SystematicAnalysis void Generic_TypeInstantiate_Tag(const NeverNullPtr Trait, const Vector& Type); void Generic_TypeInstantiate_ForType(const NeverNullPtr ForType, const Vector& Type); - bool TypeHasTrait(const TypeSymbol& Type,SymbolID id); + bool TypeHasTrait(const TypeSymbol& Type, SymbolID id); EvaluatedEx Eval_MakeEx(const TypeSymbol& Type); RawEvaluatedObject Eval_MakeExr(const TypeSymbol& Type); @@ -1947,13 +1947,13 @@ class SystematicAnalysis if (GenericData.IsPack()) { auto mingenericcount = GenericData._Genericlist.size(); - hasbadgenericcount = mingenericcount < UseNode._Values.size(); + hasbadgenericcount = mingenericcount < UseNode._Values.size(); } - else + else { - hasbadgenericcount = GenericData._Genericlist.size() != UseNode._Values.size(); + hasbadgenericcount = GenericData._Genericlist.size() != UseNode._Values.size(); } - + if (hasbadgenericcount) { LogError_CanIncorrectGenericCount(Name, Name->Value._String, UseNode._Values.size(), GenericData._Genericlist.size()); @@ -2100,9 +2100,79 @@ class SystematicAnalysis bool Eval_Evaluate(EvaluatedEx& Out, const BinaryExpressionNode& node); bool Eval_Evaluate(EvaluatedEx& Out, const CastNode& node); bool Eval_Evaluate(EvaluatedEx& Out, const ReadVariableNode& nod); - bool Eval_Evaluate(EvaluatedEx& Out, const MatchExpression& nod,bool runmatchcheck = true); + bool Eval_Evaluate(EvaluatedEx& Out, const MatchExpression& nod, bool runmatchcheck = true); bool Eval_MatchArm(const TypeSymbol& MatchItem, const EvaluatedEx& Item, MatchArm& Arm, const ExpressionNodeType& ArmEx); - void DoBinaryOpContextWith(TypeSymbol type,const DoBinaryOpContext& context); + void DoBinaryOpContextWith(TypeSymbol type, const DoBinaryOpContext& context); + + template + static void DoBinaryIntOp(const SystematicAnalysis::DoBinaryOpContext& context) + { + T& op1 = *(T*)context.Op1->Object_AsPointer.get(); + T& op2 = *(T*)context.Op2->Object_AsPointer.get(); + T& out = *(T*)context.OpOut->Object_AsPointer.get(); + bool& outequal = *(bool*)context.OpOut->Object_AsPointer.get(); + + switch (context.type) + { + case TokenType::plus: + out = op1 + op2; + break; + case TokenType::minus: + out = op1 + op2; + break; + case TokenType::star: + out = op1 * op2; + break; + case TokenType::forwardslash: + out = op1 / op2; + break; + case TokenType::modulo: + out = op1 % op2; + break; + + case TokenType::equal_Comparison: + outequal = op1 == op2; + break; + case TokenType::Notequal_Comparison: + outequal = op1 != op2; + break; + case TokenType::logical_and: + outequal = op1 && op2; + break; + case TokenType::logical_or: + outequal = op1 || op2; + break; + case TokenType::greater_than_or_equalto: + outequal = op1 >= op2; + break; + case TokenType::less_than_or_equalto: + outequal = op1 <= op2; + break; + case TokenType::greaterthan: + outequal = op1 > op2; + break; + case TokenType::lessthan: + outequal = op1 < op2; + break; + + case TokenType::bitwise_LeftShift: + out = op1 << op2; + break; + case TokenType::bitwise_RightShift: + out = op1 >> op2; + break; + case TokenType::bitwise_and: + out = op1 && op2; + break; + case TokenType::bitwise_or: + out = op1 || op2; + break; + default: + UCodeLangUnreachable(); + break; + } + } + bool Eval_Evaluate_t(EvaluatedEx& Out, const Node* node, GetValueMode Mode); bool Eval_Evaluate(EvaluatedEx& Out, const ExpressionNodeType& node, GetValueMode Mode); bool Eval_EvaluatePostfixOperator(EvaluatedEx& Out, TokenType Op);