Locked Select a special element from a sequence.

  • martedì 21 agosto 2012 02:41
     
      Contiene codice

    Hi,

    I am trying to model a system in which an element can be inserted into any possible location in a container,and I am using an instance-based solution Modeling.

    I would like to create a scenario that insert an element after the head element. I am using the following script to simulate the scenario, but it  does not work, and spec explorer crashes.The root reason seems to be "object for instance field selection neither reference nor compound nor native".

    machine RandomInsertWithOneItem(DlinkAdapter container) : Main where ForExploration = true
    {
        (let DLinkedListNode<string> newNode
        in
        ((. newNode!= container.GetHead() .):container.InsertAfter("c",newNode)))
    } 

    Here is the Debug Log:

    FATAL ERROR: Executor failure:
    Xrt Stacktrace:
       at DlinkTest.DlinkAdapter.GetHead
       at CordCode.constraint_5(DlinkTest.DlinkAdapter,DataStructures.DLinkedListNode<System.String>)
    
    stacktrace: 
       在 Microsoft.SpecExplorer.VS.SpecExplorerPackage.RecoverFromFatalError(Exception exception)
       在 Microsoft.SpecExplorer.RecoverFromFatalErrorEventObserver.HandleEvent(ExplorerEvent e)
       在 Microsoft.SpecExplorer.EventManager.HandleEvent(ExplorerEvent e)
    
    involved exception: Microsoft.Xrt.Execution.ExecutionFatalErrorException: Executor failure:
    Xrt Stacktrace:
       at DlinkTest.DlinkAdapter.GetHead
       at CordCode.constraint_5(DlinkTest.DlinkAdapter,DataStructures.DLinkedListNode<System.String>)
     ---> Microsoft.Xrt.RecoverFromFatalErrorException: object for instance field selection neither reference nor compound nor native

    I have two questions here.

    1. how to get a reference to a single element from a container?

    2. what is wrong with the the method "getHead"?

    Thanks in advance.

Tutte le risposte

  • venerdì 24 agosto 2012 16:43
     
     

    Hi all,

    Finally, I figured out why it does not work, and now it works.

    After I read all the questions in this forum and the documents and trying again and again, it turns out I have used the wrong collection type.

    Regards,

    • Contrassegnato come risposta lzh_ing sabato 25 agosto 2012 03:00
    • Contrassegno come risposta annullato lzh_ing sabato 25 agosto 2012 03:01
    •