2012-10-03 53 views
1

如果在Ubuntu上安裝自助使用上http://selflanguage.org/文件,那麼我們就可以用關於自我語言,我們如何在虛擬機上運行代碼?

$ Self 
Self Virtual Machine Version 4.1.13, Sat 20 Feb 10 22:39:48 Linux 
Copyright 1989-2003: The Self Group (type _Credits for credits) 

for I386: LogVMMessages = true 
for I386: PrintScriptName = true 
for I386: Inline = true 
for I386: SICDeferUncommonBranches = false (not implemented) 
for I386: SICReplaceOnStack = false (not implemented) 
for I386: SaveOutgoingArgumentsOfPatchedFrames = true 

然而,一些簡單的線條不能運行:

VM# 'Hello, World!' print. 
A lookup error happened while sending the message 
    print 
to 
    'Hello, World!'. 
Subsequently, the lookup error message 
    undefinedSelector:Receiver:Type:Delegatee:MethodHolder:Arguments: 
was sent to 
    <0>, 
and was also not understood, causing the process to be aborted by the Self VM. 

#0 (<error>:1): print = (| self* = 'Hello, World!'. delegatee = nil. selector = 'print'. | 
"undefined selector error; 
this method was automatically generated by the VM." 
) 


#1 (<stdin>:1): <top level expr> = (| self* = lobby. | 'Hello, World!' print) 

或者另一個嘗試的插槽:

VM# _AddSlots: (| vehicle <- (|parent* = traits clonable|) |). 
A lookup error happened while sending the message 
    traits 
to 
    lobby. 
Subsequently, the lookup error message 
    undefinedSelector:Receiver:Type:Delegatee:MethodHolder:Arguments: 
was sent to 
    <0>, 
and was also not understood, causing the process to be aborted by the Self VM. 

#0 (<error>:1): traits = (| self* = lobby. delegatee = nil. selector = 'traits'. | 
"undefined selector error; 
this method was automatically generated by the VM." 
) 


#1 (<stdin>:1): <top level expr> = (| self* = lobby. | traits clonable) 


          ^
Self VM error: couldn't construct object literal on line 1, character 30 
      ^
Self VM error: couldn't construct object literal on line 1, character 16 
VM# 

有人知道如何使它工作嗎?

回答

3

你遇到的是自我的最基本形式。

虛擬機本身只知道很少的消息。它們包括所有基元 和一些消息,如bootstrap

如果你嘗試一下,像_Quit'some/path/to/self/script' _RunScript 這樣的東西將會起作用,因爲它們是始終可用的基元。

如果你想要一個工作環境,你必須要麼

  • 負載快照通過與-s選項啓動VM:

    Self -s mySnapshot.snap 
    

    你可以找到自己的主頁快照。

  • 運行世界建築腳本。爲此,您需要自帶的objects目錄 。如果找不到,請使用github page中的那個。然後,將工作目錄更改爲objects目錄並運行世界生成器腳本。

    cd $PATH_TO_OBJECTS/objects 
    Self -f worldBuilder.self 
    

    可替代地,點SELF_WORKING_DIR環境變量來包含的objects目錄的目錄並運行sctipt。

    SELF_WORKING_DIR=$PATH_TO_OBJECTS Self -f s$PATH_TO_OBJECTS/worldBuilder.self 
    

這個自舉一個自我的世界裏,每一個已知的消息應該理解。

PS:當然,您也可以從正在運行的VM中運行字詞生成器腳本:'/path/to/dir/with/objects/worldBuilder.self' _RunScript'。但請確保已設置SELF_WORKING_DIR。

相關問題