예제 #1
0
class HelperVM(object):
    def __init__(self):
        self.compiler = Compiler()

    def eval(self, code):
        vm = VM()
        proc = self.compiler.compile(parse(code), vm.env)
        return vm.run(proc)
예제 #2
0
파일: helper.py 프로젝트: adamfeuer/skime
class HelperVM(object):
    def __init__(self):
        self.compiler = Compiler()
        
    def eval(self, code):
        vm = VM()
        proc = self.compiler.compile(parse(code), vm.env)
        return vm.run(proc)
예제 #3
0
 def __init__(self):
     self.compiler = Compiler()
예제 #4
0
파일: helper.py 프로젝트: adamfeuer/skime
 def __init__(self):
     self.compiler = Compiler()
예제 #5
0
파일: skime.py 프로젝트: adamfeuer/skime
op.add_option('-S', action="store_true", dest="do_not_run",
              help = "Compile source file and drop into .s file then stop.");

(options, args) = op.parse_args()

def is_valid_path(source_file_path):
   """
   Returns true if given path exists and is a file
   Arguments:
   - `path`: path of Scheme source file
   """
   source_file_path = path.abspath(source_file_path)
   return path.exists(source_file_path) and path.isfile(source_file_path)


source_file = open(args[0])

vm          = VM()
compiler    = Compiler()
proc        = compiler.compile(parse(source_file.read()), vm.env)


if not options.do_not_run:
    result      = vm.run(proc)

    print "Result is %s" % result
    source_file.close()
else:
    print "Bytecode:\n%s" % str(proc.bytecode)
    print "Disasm run:\n%s\n" % str(proc.disasm())