class Yadriggy::Py::CodeGen

Constants

FreeVarInitName

The name of the function for initializing free variables.

Attributes

printer[R]

@return [Printer] the printer.

Public Class Methods

new(printer, checker) click to toggle source

@param [Printer] printer @param [PyTypeChecker] checker

Calls superclass method Yadriggy::Checker::new
# File lib/yadriggy/py/codegen.rb, line 13
def initialize(printer, checker)
  super()
  @printer = printer
  @typechecker = checker
end

Public Instance Methods

error_group() click to toggle source

@api private

# File lib/yadriggy/py/codegen.rb, line 20
def error_group
  'code generation'
end
is_omitted?(ast) click to toggle source

@api private

:n

in Python is written as [_..n] in Ruby.

# File lib/yadriggy/py/codegen.rb, line 188
def is_omitted?(ast)
  ast.is_a?(Name) && ast.name == '_'
end
method_name(name) click to toggle source

@api private

# File lib/yadriggy/py/codegen.rb, line 448
def method_name(name)
  if name == 'initialize'
    '__init__'
  else
    name
  end
end
newline() click to toggle source

Starts a new line.

# File lib/yadriggy/py/codegen.rb, line 39
def newline
  @printer.nl
end
print(an_ast) click to toggle source

Prints a given AST by {#printer}. @param [ASTree|ASTnode] an_ast the AST. @return [CodeGen] the `self` object.

print_binary(an_ast, op) click to toggle source

@api private

print_each(array, first, &block) click to toggle source

@api private

print_free_vars_initializer() click to toggle source

Prints a function for initializing free variables in Python. @return [Array<Object>] the arguments to the function.

print_lambda(func) click to toggle source
print_parameters(params) click to toggle source

@api private

print_tuple(an_ast) click to toggle source

@api private

python_binary_op(op) click to toggle source
# File lib/yadriggy/py/codegen.rb, line 310
def python_binary_op(op)
  if op == :'&&'
    'and'
  elsif op == :'||'
    'or'
  else
    op
  end
end