未验证 提交 811c62b8 编写于 作者: D Don Syme 提交者: GitHub

cleanup (#12950)

上级 ce094be6
......@@ -2867,49 +2867,52 @@ hardwhiteDefnBindingsTerminator:
/* An 'extern' DllImport function definition in C-style syntax */
cPrototype:
| EXTERN cRetType opt_access ident opt_HIGH_PRECEDENCE_APP LPAREN cArgs rparen
| EXTERN cRetType opt_access ident opt_HIGH_PRECEDENCE_APP LPAREN externArgs rparen
{ let rty, vis, nm, args = $2, $3, $4, $7
let nmm = rhs parseState 3
let argsm = rhs parseState 6
let mBindLhs = lhs parseState
let mWhole = lhs parseState
let mRhs = lhs parseState
let rhsExpr = SynExpr.App (ExprAtomicFlag.NonAtomic,
false,
SynExpr.Ident (ident("failwith", rhs parseState 6)),
SynExpr.Const (SynConst.String("extern was not given a DllImport attribute", SynStringKind.Regular, rhs parseState 8), rhs parseState 8),
mRhs)
let rhsExpr =
SynExpr.App (
ExprAtomicFlag.NonAtomic,
false,
SynExpr.Ident (ident("failwith", rhs parseState 6)),
SynExpr.Const (SynConst.String("extern was not given a DllImport attribute", SynStringKind.Regular, rhs parseState 8), rhs parseState 8),
mRhs)
(fun attrs _ ->
let bindingPat = SynPat.LongIdent (LongIdentWithDots([nm], []), None, None, Some noInferredTypars, SynArgPats.Pats [SynPat.Tuple(false, args, argsm)], vis, nmm)
let mWholeBindLhs = (mBindLhs, attrs) ||> unionRangeWithListBy (fun (a: SynAttributeList) -> a.Range)
let xmlDoc = grabXmlDoc(parseState, attrs, 1)
let binding = mkSynBinding
(xmlDoc, bindingPat)
(vis, false, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, Some rty, rhsExpr, mRhs, [], attrs, None, SynBindingTrivia.Zero)
let binding =
mkSynBinding
(xmlDoc, bindingPat)
(vis, false, false, mWholeBindLhs, DebugPointAtBinding.NoneAtInvisible, Some rty, rhsExpr, mRhs, [], attrs, None, SynBindingTrivia.Zero)
[], [binding]) }
/* A list of arguments in an 'extern' DllImport function definition */
cArgs:
| cMoreArgs
externArgs:
| externMoreArgs
{ List.rev $1 }
| cArg
| externArg
{ [$1] }
|
{ [] }
/* Part of the list of arguments in an 'extern' DllImport function definition */
cMoreArgs:
| cMoreArgs COMMA cArg
externMoreArgs:
| externMoreArgs COMMA externArg
{ $3 :: $1 }
| cArg COMMA cArg
| externArg COMMA externArg
{ [$3; $1] }
/* A single argument in an 'extern' DllImport function definition */
cArg:
externArg:
| opt_attributes cType
{ let m = lhs parseState in SynPat.Typed(SynPat.Wild m, $2, m) |> addAttribs $1 }
......
......@@ -5287,16 +5287,19 @@ let foo (a: Foo): bool =
let ``Test typed AST for struct unions`` () = // See https://github.com/fsharp/FSharp.Compiler.Service/issues/756
let keepAssemblyContentsChecker = FSharpChecker.Create(keepAssemblyContents=true)
let wholeProjectResults = keepAssemblyContentsChecker.ParseAndCheckProject(ProjectStructUnions.options) |> Async.RunImmediate
let declarations =
let checkedFile = wholeProjectResults.AssemblyContents.ImplementationFiles.[0]
match checkedFile.Declarations.[0] with
| FSharpImplementationFileDeclaration.Entity (_, subDecls) -> subDecls
| _ -> failwith "unexpected declaration"
let getExpr exprIndex =
match declarations.[exprIndex] with
| FSharpImplementationFileDeclaration.MemberOrFunctionOrValue(_,_,e) -> e
| FSharpImplementationFileDeclaration.InitAction e -> e
| _ -> failwith "unexpected declaration"
match getExpr (declarations.Length - 1) with
| IfThenElse(UnionCaseTest(AddressOf(UnionCaseGet _),_,uci),
Const(trueValue, _), Const(falseValue, _))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册