コンパイラ構成論ソース読み会 〜ghc〜

ghcインストール前に入れる

 $ git clone --recursive git://git.haskell.org/ghc.git

インストール

1日目

どこのghcが呼ばれているのかを調べる

これで、ghcを実行する時、どのファイルが呼ばれるかがわかる

lldbで追っかけようとした

 $ lldb -- /Users/one/workspace... append.hs

これでは、mainがないというエラーが出る話が

アセンブラを生成する

ghc_build/compiler/main/HscMain?.hsをghciで動かす

 -cpp : Cのプリプロセッサを通す
 -I   : #includeファイルを探すディレクトリを、通常のCでの方法で指定する
 -S   : .s(アセンブラコード)を生成
 -i   : 必要なモジュールのディレクトリを指定する
 -D   : 値を定義する

Main.hsを動かす

 $ ghci -fno-code -cpp -DSTAGE=2 -I. -I../ghc -I./stage2 -I./stage2/build -iutils:main:prelude:hsSyn:types:typecheck:deSugar:stage2/build:parser:iface:basicTypes:profiling:specialise:coreSyn:cmm:simplCore:codeGen:nativeGen:StgSyn:cbits:rename:simplStg:specialise:stranal:types:vectorise:llvmGen ../ghc/Main.hs

2日目

Haskell Compilerについて勉強する

スライド(http://www.scs.stanford.edu/11au-cs240h/notes/ghc-slides.html#%281%29)を 読んで、Haskell Compilerについて勉強する。

GCについて勉強

スライド(http://www.slideshare.net/dec9ue/rts-gc)を読んで、 Gerbage Collectionについて勉強する。

Main.hsを動かす(2)

デバッグオプションがついてない?(問題編)

3日目

デバッグオプションがついてない?(解決編)

GhcDebugged=YES

lldbで読もう

parser/Lexer.x を読む。

定義を確認し、alexにかけることで**.hsに変換  alex Parser.x 変換したParser.hsを読む。

Lexer.hsをghciにいれてみる。

$ ../../build/bin/ghci -fno-code -cpp -DSTAGE=2 -I. -I../ghc -I./stage2 -I./stage2/build -iutils:main:prelude:hsSyn:types:typecheck:deSugar:stage2/build:parser:iface:basicTypes:profiling:specialise:coreSyn:cmm:simplCore:codeGen:nativeGen:StgSyn:cbits:rename:simplStg:specialise:stranal:types:vectorise:llvmGen ./parser/Lexer.hs

parser/Parser.hsを読む

Parser.y を happyで *.hsに変換

happy Parser.y

ParseResult?とは?

parser を実行したい

    runParser :: DynFlags -> String -> P a -> ParseResult a
    runParser flags str parser = unP parser parseState
    where
      filename = "\<interactive\>"
      location = mkRealSrcLoc (mkFastString filename) 1 1
      buffer = stringToStringBuffer str
      parseState = mkPState flags buffer location in

PState とは?

Desugar を追う。

Hskellからcoreにするときにdesugarするので、Desugarを追う。
-> desugar/Desugar.hsに書かれてる。

dsLExprとは

他に読むものは?


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS