Sha256: 981043ecf9ee9c36df15045375afcffe3677e8a8d3462c644cdf65e2ace24f8d

Contents?: true

Size: 1016 Bytes

Versions: 3

Compression:

Stored size: 1016 Bytes

Contents

class Fancy AST {

  class Script : Node {
    read_slots: ['file, 'line, 'body]

    @@stack = []

    def push_script {
      @@stack push(self)
    }

    def pop_script {
      @@stack pop()
    }

    def self current {
      @@stack last()
    }

    def initialize: @line file: @file body: @body {
    }

    def bytecode: g {
      pos(g)
      try {
        push_script

        # docs, code = body.expressions.partition do |s|
        #   s.kind_of?(Rubinius::AST::StringLiteral)
        # end

        # if code.empty?
        #   # only literal string found, we have to evaluate to it, not
        #   # use as documentation.
        #   docs, code = [], docs
        # end

        # code.each { |c| c.bytecode(g) }

        @body bytecode: g

        # the docs array has top-level expressions that are
        # simply string literals, we can use them for file-level
        # documentation.
        # TODO: implement file documentation here.
      } finally {
        pop_script
      }
    }
  }

}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fancy-0.3.3 lib/compiler/ast/script.fy
fancy-0.3.2 lib/compiler/ast/script.fy
fancy-0.3.1 lib/compiler/ast/script.fy