Skip to content

Conversation

@joeldrapper
Copy link
Collaborator

No description provided.

def initialize(compiler)
@compiler = compiler
@mutations = []
@in_scope = true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tracks if we may have gone out of scope via a block to an unknown method. Out of scope, we need to use a conditional to check that we’re in scope at runtime. Example

10.times do
  if self == component_instance
    # compiled code here
  else
    # original code here
  end
end

Comment on lines +12 to +14
def visit_def_node(node)
Phlex::Compiler::MethodCompiler.new(@compiler).compile(node)
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to check the receiver of this method definition. Not sure if this node would be triggered for something like def Foo.bar

end

def visit_class_node(node)
if @compiler.line == node.location.start_line
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s possible to define more than one class on a single line, so we should also check the name.

[
node.location.start_offset,
node.location.length,
[:buffer, "<h1></h1>"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These array allocations aren’t necessary, we should just have a type symbol in the outer array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants