Skip to content

Instantly share code, notes, and snippets.

@Rusketh
Created September 28, 2014 16:51
Show Gist options
  • Save Rusketh/875fb620beb1d1e5d4f3 to your computer and use it in GitHub Desktop.
Save Rusketh/875fb620beb1d1e5d4f3 to your computer and use it in GitHub Desktop.
Component:AddGeneratedFunction( "table", "...", "t", function( Operator, Compiler, Trace, ... )
local Inputs = { ... }
local Preperation = { }
local Values, Types, Look = { }, { }, { }
for I = 1, #Inputs, -1 do
local Input = Inputs[I]
if Input.FLAG == EXPADV_PREPARE or Input.FLAG == EXPADV_INLINEPREPARE then
Preperation[#Preperation + 1] = Input.Prepare
end
if Input.FLAG == EXPADV_INLINE or Input.FLAG == EXPADV_INLINEPREPARE then
Values[I] = Input.Inline
end
Types[I] = Input.Return
Look[I] = I
end
local LuaInline = "{ Data = { %s }, Types = { %s }, Look = { %s }, Size = %i, Count = %i, HasChanged = false }"
LuaInline = string.format( LuaInline, table.concat( Values, "," ), table.concat( Types, "," ), table.concat( Look, "," ), #Values, #Values )
return { Trace = Trace, Inline = LuaInline, Prepare = table.concat( Preperation, "\n" ), Return = "t", FLAG = EXPADV_INLINEPREPARE }
end )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment