Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fd0392

Browse files
Vasily KirichenkoVasily Kirichenko
Vasily Kirichenko
authored and
Vasily Kirichenko
committed
Revert "Implementing basic nameof and typenameof operators"
This reverts commit223d313.Conflicts:tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAppliedFunction.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAsAFunction.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfDictLookup.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntConst.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntegerAppliedFunction.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfParameterAppliedFunction.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfPartiallyAppliedFunction.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfStringConst.fstests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfWithPipe.fs
1 parentf3c4ba5 commit8fd0392

File tree

8 files changed

+3
-104
lines changed

8 files changed

+3
-104
lines changed

‎src/fsharp/FSharp.Core/prim-types.fs‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4748,12 +4748,6 @@ namespace Microsoft.FSharp.Core
47484748
[<CompiledName("TypeOf")>]
47494749
let inlinetypeof<'T>= BasicInlinedOperations.typeof<'T>
47504750

4751-
[<CompiledName("TypeNameOf")>]
4752-
let inlinetypenameof<'T>:string= raise(Exception"may not call directly, should always be optimized away")
4753-
4754-
[<CompiledName("NameOf")>]
4755-
let inlinenameof(_:'T):string= raise(Exception"may not call directly, should always be optimized away")
4756-
47574751
[<CompiledName("MethodHandleOf")>]
47584752
letmethodhandleof(_call:('T-> 'TResult)):System.RuntimeMethodHandle= raise(Exception"may not call directly, should always be optimized away")
47594753

‎src/fsharp/FSharp.Core/prim-types.fsi‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,15 +2320,6 @@ namespace Microsoft.FSharp.Core
23202320
[<CompiledName("TypeOf")>]
23212321
val inline typeof<'T>:System.Type
23222322

2323-
///<summary>Returns the name of the given static type.</summary>
2324-
[<RequiresExplicitTypeArguments>]
2325-
[<CompiledName("TypeNameOf")>]
2326-
val inline typenameof<'T>:string
2327-
2328-
///<summary>Returns the name of the given symbol.</summary>
2329-
[<CompiledName("NameOf")>]
2330-
val inline nameof: 'T->string
2331-
23322323
///<summary>An internal,library-only compiler intrinsic for compile-time
23332324
///generation of a RuntimeMethodHandle.</summary>
23342325
[<CompiledName("MethodHandleOf")>]

‎src/fsharp/Optimizer.fs‎

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ let AbstractAndRemapModulInfo msg g m (repackage,hidden) info =
11851185
info
11861186

11871187
//-------------------------------------------------------------------------
1188-
// Mischelpers
1188+
// Mischelerps
11891189
//-------------------------------------------------------------------------
11901190

11911191
// Mark some variables (the ones we introduce via abstractBigTargets) as don't-eliminate
@@ -2501,37 +2501,6 @@ and TryDevirtualizeApplication cenv env (f,tyargs,args,m) =
25012501
MightMakeCriticalTailcall=false
25022502
Info=UnknownValue})
25032503

2504-
// Analyze the name of the given symbol and rewrite AST to constant string expression with the name
2505-
| Expr.Val(vref,_,_),_,_when valRefEq cenv.g vref cenv.g.nameof_vref->
2506-
PostTypeCheckSemanticChecks.tryExtractNameOf args
2507-
|> Option.map(fun name->
2508-
Expr.Const(Const.String name, m, cenv.g.string_ty),
2509-
{ TotalSize=1
2510-
FunctionSize=1
2511-
HasEffect=false
2512-
MightMakeCriticalTailcall=false
2513-
Info= UnknownValue})
2514-
// Analyze the name of the given type and rewrite AST to constant string expression with the name
2515-
| Expr.Val(vref,_,_),_,_when valRefEq cenv.g vref cenv.g.typenameof_vref->
2516-
match tyargswith
2517-
|(typeName:TType)::_->
2518-
letname=
2519-
match typeNamewith
2520-
| TType_forall(_tps,ty)-> ty.ToString()
2521-
| TType_app(tcref,_)-> tcref.CompiledRepresentationForNamedType.FullName
2522-
| TType_tuple tinst->"("+ String.concat","(List.map string tinst)+")"
2523-
| TType_fun(d,r)->"("+ string d+" ->"+ string r+")"
2524-
| TType_ucase(uc,_)-> uc.CaseName
2525-
| TType_var tp-> tp.DisplayName
2526-
| TType_measure ms-> sprintf"%A" ms
2527-
2528-
Some(Expr.Const(Const.String name, m, cenv.g.string_ty),
2529-
{ TotalSize=1
2530-
FunctionSize=1
2531-
HasEffect=false
2532-
MightMakeCriticalTailcall=false
2533-
Info= UnknownValue})
2534-
|_-> None
25352504
|_-> None
25362505

25372506
/// Attempt to inline an application of a known value at callsites

‎src/fsharp/PostInferenceChecks.fs‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -507,27 +507,6 @@ let CheckMultipleInterfaceInstantiations cenv interfaces m =
507507
let recCheckExprNoByrefs(cenv:cenv)(env:env)expr=
508508
CheckExpr cenv env expr NoByrefs
509509

510-
// tries to extract the name of an expression
511-
lettryExtractNameOf args=
512-
match argswith
513-
|[Expr.App(Expr.Val(r,_,_),_,_,Expr.Const(constant,_,_)::_,_)]->
514-
if r.CompiledName.StartsWith("get_")&& constant= Const.Unitthen// TODO: We need a better way to find static property getters
515-
Some(r.CompiledName.Substring(4))
516-
else
517-
None// the function was applied
518-
|[Expr.App(Expr.Val(r,_,_),_,_,[],_)]-> Some(r.CompiledName)
519-
|[Expr.App(Expr.Val(r,_,_),_,_,_,_)]->
520-
if r.CompiledName.StartsWith("get_")then// TODO: We need a better way to find member property getters
521-
Some(r.CompiledName.Substring(4))
522-
else
523-
None// the function was applied
524-
|[Expr.Let(_,Expr.Val(r,_,_),_,_)]-> Some(r.CompiledName)
525-
|[Expr.Let(_,Expr.Lambda(_,_,_,_,Expr.App(Expr.Val(r,_,_),_,_,_,_),_,_),_,_)]-> Some(r.CompiledName)
526-
|[Expr.Lambda(_,_,_,_,Expr.App(Expr.Val(r,_,_),_,_,_,_),_,_)]-> Some(r.CompiledName)
527-
|[Expr.Op(TOp.ValFieldGet(r),_,_,_)]-> Some(r.FieldName)
528-
|[Expr.Lambda(_,_,_,_,Expr.Op(TOp.ILCall(_,_,_,_,_,_,_,r,_,_,_),_,_,_),_,_)]-> Some(r.Name)
529-
|_-> None
530-
531510
/// Check a value
532511
andCheckVal(cenv:cenv)(env:env)v m context=
533512
if cenv.reportErrorsthen
@@ -557,18 +536,8 @@ and CheckExpr (cenv:cenv) (env:env) expr (context:ByrefContext) =
557536
CheckExpr cenv env body context
558537

559538
| Expr.Const(_,m,ty)->
560-
CheckTypePermitByrefs cenv env m ty
561-
562-
| Expr.App(Expr.Val(v,_,_),_,_,args,m)->
563-
if cenv.reportErrorsthen
564-
if valRefEq cenv.g v cenv.g.nameof_vref&& tryExtractNameOf args= Nonethen
565-
errorR(Error(FSComp.SR.expressionHasNoName(), m))
566-
match argswith
567-
|[_;Expr.App(Expr.Val(v,_,_),_,_,args,m)]->
568-
if valRefEq cenv.g v cenv.g.nameof_vref&& tryExtractNameOf args= Nonethen
569-
errorR(Error(FSComp.SR.nameofNotPermitted(), m))
570-
|_->()
571-
539+
CheckTypePermitByrefs cenv env m ty
540+
572541
| Expr.Val(v,vFlags,m)->
573542
if cenv.reportErrorsthen
574543
if v.BaseOrThisInfo= BaseValthen

‎src/fsharp/PostInferenceChecks.fsi‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ open Microsoft.FSharp.Compiler.InfoReader
1010

1111
valtestFlagMemberBody:bool ref
1212
valCheckTopImpl:TcGlobals* Import.ImportMap* bool* InfoReader* Tast.CompilationPath list* Tast.CcuThunk* Tastops.DisplayEnv* Tast.ModuleOrNamespaceExprWithSig* Tast.Attribs*(bool* bool)-> bool
13-
val tryExtractNameOf: Microsoft.FSharp.Compiler.Tast.Expr list-> string option

‎src/fsharp/TastOps.fs‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,11 +2879,6 @@ let isTypeOfValRef g vref =
28792879
// There is an internal version of typeof defined in prim-types.fs that needs to be detected
28802880
||(g.compilingFslib&& vref.LogicalName="typeof")
28812881

2882-
letisTypeNameOfValRef g vref=
2883-
valRefEq g vref g.typenameof_vref
2884-
// There is an internal version of typenameof defined in prim-types.fs that needs to be detected
2885-
||(g.compilingFslib&& vref.LogicalName="typenameof")
2886-
28872882
letisSizeOfValRef g vref=
28882883
valRefEq g vref g.sizeof_vref
28892884
// There is an internal version of typeof defined in prim-types.fs that needs to be detected
@@ -2904,11 +2899,6 @@ let (|TypeOfExpr|_|) g expr =
29042899
| Expr.App(Expr.Val(vref,_,_),_,[ty],[],_)when isTypeOfValRef g vref-> Some ty
29052900
|_-> None
29062901

2907-
let(|TypeNameOfExpr|_|)g expr=
2908-
match exprwith
2909-
| Expr.App(Expr.Val(vref,_,_),_,[ty],[],_)when isTypeNameOfValRef g vref-> Some ty
2910-
|_-> None
2911-
29122902
let(|SizeOfExpr|_|)g expr=
29132903
match exprwith
29142904
| Expr.App(Expr.Val(vref,_,_),_,[ty],[],_)when isSizeOfValRef g vref-> Some ty
@@ -6089,7 +6079,6 @@ let mkCallUnboxFast (g:TcGlobals) m ty e1 = mkApps g (typedExprFor
60896079
letmkCallTypeTest(g:TcGlobals)m ty e1= mkApps g(typedExprForIntrinsic g m g.istype_info,[[ty]],[ e1], m)
60906080
letmkCallTypeOf(g:TcGlobals)m ty= mkApps g(typedExprForIntrinsic g m g.typeof_info,[[ty]],[], m)
60916081
letmkCallTypeDefOf(g:TcGlobals)m ty= mkApps g(typedExprForIntrinsic g m g.typedefof_info,[[ty]],[], m)
6092-
letmkCallTypeNameOf g m ty= mkApps g(typedExprForIntrinsic g m g.typenameof_info,[[ty]],[], m)
60936082

60946083

60956084
letmkCallDispose(g:TcGlobals)m ty e1= mkApps g(typedExprForIntrinsic g m g.dispose_info,[[ty]],[ e1], m)
@@ -7751,7 +7740,6 @@ let IsSimpleSyntacticConstantExpr g inputExpr =
77517740
| Expr.Op(TOp.UnionCase_,_,[],_)// Nullary union cases
77527741
| UncheckedDefaultOfExpr g_
77537742
| SizeOfExpr g_
7754-
| TypeNameOfExpr g_
77557743
| TypeOfExpr g_->true
77567744
// All others are not simple constant expressions
77577745
|_->false

‎src/fsharp/TastOps.fsi‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ val mkCallTypeTest : TcGlobals -> range -> TType -> Expr -> Expr
11791179
val canUseTypeTestFast: TcGlobals-> TType-> bool
11801180

11811181
val mkCallTypeOf: TcGlobals-> range-> TType-> Expr
1182-
val mkCallTypeNameOf: TcGlobals-> range-> TType-> Expr
11831182
val mkCallTypeDefOf: TcGlobals-> range-> TType-> Expr
11841183

11851184
val mkCallCreateInstance: TcGlobals-> range-> TType-> Expr

‎src/fsharp/TcGlobals.fs‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
162162
// The helper to find system types amongst referenced DLLs
163163
tryFindSysTypeCcu,
164164
emitDebugInfoInQuotations: bool, usesMscorlib: bool, noDebugData: bool)=
165-
nameof_info: IntrinsicValRef
166-
nameof_vref: ValRef
167-
typenameof_info: IntrinsicValRef
168-
typenameof_vref: ValRef
169165

170166
letvara= NewRigidTypar"a" envRange
171167
letvarb= NewRigidTypar"b" envRange
@@ -573,8 +569,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
573569
letv_typeof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"typeof", None, Some"TypeOf",[vara],([], v_system_Type_typ))
574570
letv_methodhandleof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"methodhandleof", None, Some"MethodHandleOf",[vara;varb],([[varaTy--> varbTy]], v_system_RuntimeMethodHandle_typ))
575571
letv_sizeof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"sizeof", None, Some"SizeOf",[vara],([], v_int_ty))
576-
lettypenameof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"typenameof",None,Some"TypeNameOf",[vara],([],string_ty))
577-
letnameof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"nameof",None,Some"NameOf",[vara],([[varaTy]],string_ty))
578572
letv_unchecked_defaultof_info= makeIntrinsicValRef(fslib_MFOperatorsUnchecked_nleref,"defaultof", None, Some"DefaultOf",[vara],([], varaTy))
579573
letv_typedefof_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"typedefof", None, Some"TypeDefOf",[vara],([], v_system_Type_typ))
580574
letv_enum_info= makeIntrinsicValRef(fslib_MFOperators_nleref,"enum", None, Some"ToEnum",[vara],([[v_int_ty]], varaTy))
@@ -916,10 +910,6 @@ type public TcGlobals(compilingFslib: bool, ilg:ILGlobals, fslibCcu: CcuThunk, d
916910
member valsystem_MarshalByRefObject_typ= tryMkSysNonGenericTy sys"MarshalByRefObject"
917911

918912
member__.system_Reflection_MethodInfo_typ= v_system_Reflection_MethodInfo_typ
919-
nameof_info= nameof_info
920-
nameof_vref= ValRefForIntrinsic nameof_info
921-
typenameof_info= typenameof_info
922-
typenameof_vref= ValRefForIntrinsic typenameof_info
923913

924914
member valsystem_Array_tcref= findSysTyconRef sys"Array"
925915
member valsystem_Object_tcref= findSysTyconRef sys"Object"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp