-- ============================================================================
-- Aegis macro runtime (safe reference implementations)
-- https://aegisob.com
--
-- Aegis macros are marker functions. When you pass your source through Aegis,
-- these names are preserved (never renamed) and their string / number
-- arguments are protected. The definitions below are safe no-op stubs so you
-- can develop and test locally without Aegis; the protected build injects the
-- real behaviour. Include this file (or paste it) at the top of your source.
-- ============================================================================

-- Marks a scope/function for full protection (compatibility marker).
local function AEG_OBFUSCATED()
    return nil
end

-- Explicitly marks a string literal for encryption.
local function AEG_ENCSTR(s)
    return s
end

-- Explicitly marks a byte buffer for encryption.
local function AEG_ENCBUF(buf)
    return buf
end

-- Explicitly marks a number for obfuscation.
local function AEG_ENCNUM(n)
    return n
end

-- Produces an opaque value the compiler cannot constant-fold away.
local function AEG_OPAQUE(x)
    return x
end

-- Crashes / stops execution if reached (dead-code trap).
local function AEG_CRASH()
    error("Aegis: unreachable code executed", 2)
end

-- Hints the obfuscator to allocate a scratch stack frame.
local function AEG_STACKALLOC(size)
    return size or 0
end

-- A pre-check assertion helper.
local function AEG_PRECHECK(cond, msg)
    if not cond then
        error(msg or "Aegis precheck failed", 2)
    end
    return true
end

-- Requests a control-flow rewrite of the enclosing scope.
local function AEG_REWRITE()
    return nil
end

-- Injected source line marker (compatibility no-op).
local function AEG_LINE(line)
    return line
end

-- Prevents virtualization of the marked function.
local function AEG_NO_VIRTUALIZE(fn)
    return fn
end

-- Prevents any obfuscation of the marked value/block.
local function AEG_NO_OBFUSCATE(x)
    return x
end
