Skip to content

Prevent optimisations of some parts #19

@YPetremann

Description

@YPetremann

I'm working on a library for tic80,
I already have some part that are optimised the way I want
I would like to prevent pakettic to do further "destructive" optimisation to keep clarity even in the minified version.
It would be interesting to have a magic comment like --< and --> that would limit pakettic to be limited on whitespace optimisation
An extended version --<< and -->> would tell to even keep whitespace like it is
And finaly a --i"" would force to insert some content for release

An example:

--<
local TG={}
--i"\n"
function TG:BeginTabs(x,y,w,h)
-->
	line(x, y+8, x+w-1, y+8, self.theme.dark)
	return self:Element(true, x, y, w, h)
end
--i"\n"
--<
function TG:BeginTab(t,o,x,y,w,h)
-->
	if o==nil then o=self:state().open end
	o = self:Button(t, x,y, w,h) or o
	return self:Element(o, x,y, w,h)

end

For now it optimise as

local s={} s.BeginTabs=function(self,k,u,g,h)line(k,u+8,k+g-1,u+8,self.theme.dark)return self:Element(true,k,u,g,h)end  s.BeginTab=function(self,o,m,k,u,g,h)if nil==m then m=self:state().open end m=self:Button(o,k,u,g,h)or m return self:Element(m,k,u,g,h)end 

I would prefer that it does that

local TG={}
function TG:BeginTabs(x,y,w,h)line(x,y+8,x+w-1,y+8,self.theme.dark)return self:Element(true,x,y,w,h)end
function TG:BeginTab(t,o,x,y,w,h)if nil==o then o=self:state().open end o=self:Button(t,x,y,w,h)or o return self:Element(o,x,y,w,h)end

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions