Current section

Files

Jump to
caffeine_lang src caffeine_lang@linker@linker.erl
Raw

src/caffeine_lang@linker@linker.erl

-module(caffeine_lang@linker@linker).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/caffeine_lang/linker/linker.gleam").
-export([link/3]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-file("src/caffeine_lang/linker/linker.gleam", 68).
-spec parse_expectation_sources(
list(caffeine_lang@source_file:source_file(caffeine_lang@source_file:expectation_source())),
list(caffeine_lang@linker@measurements:measurement(caffeine_lang@linker@measurements:measurement_validated())),
gleam@dict:dict(binary(), caffeine_lang@linker@slo_params:param_info())
) -> {ok,
list({list({caffeine_lang@linker@expectations:expectation(),
gleam@option:option(caffeine_lang@linker@measurements:measurement(caffeine_lang@linker@measurements:measurement_validated()))}),
binary()})} |
{error, caffeine_lang@errors:compilation_error()}.
parse_expectation_sources(Sources, Validated_measurements, Slo_params) ->
_pipe = Sources,
_pipe@3 = gleam@list:map(
_pipe,
fun(Source) ->
_pipe@1 = caffeine_lang@frontend@pipeline:compile_expects(Source),
_pipe@2 = gleam@result:'try'(
_pipe@1,
fun(Raw_expectations) ->
caffeine_lang@linker@expectations:validate_expectations(
Raw_expectations,
Validated_measurements,
Slo_params,
erlang:element(2, Source)
)
end
),
gleam@result:map(
_pipe@2,
fun(Exps) -> {Exps, erlang:element(2, Source)} end
)
end
),
caffeine_lang@errors:from_results(_pipe@3).
-file("src/caffeine_lang/linker/linker.gleam", 20).
?DOC(false).
-spec link(
list(caffeine_lang@source_file:vendor_measurement_source()),
list(caffeine_lang@source_file:source_file(caffeine_lang@source_file:expectation_source())),
gleam@dict:dict(binary(), caffeine_lang@linker@slo_params:param_info())
) -> {ok,
list(caffeine_lang@linker@ir:intermediate_representation(caffeine_lang@linker@ir:linked()))} |
{error, caffeine_lang@errors:compilation_error()}.
link(Measurements, Expectation_sources, Slo_params) ->
Reserved_labels = caffeine_lang@linker@ir_builder:reserved_labels(
Slo_params
),
gleam@result:'try'(
begin
_pipe = Measurements,
_pipe@2 = gleam@list:map(
_pipe,
fun(Vbs) ->
_pipe@1 = caffeine_lang@frontend@pipeline:compile_measurements(
erlang:element(2, Vbs)
),
gleam@result:map(
_pipe@1,
fun(Raw_bps) -> {Raw_bps, erlang:element(3, Vbs)} end
)
end
),
caffeine_lang@errors:from_results(_pipe@2)
end,
fun(Compiled_pairs) ->
All_raw_measurements = begin
_pipe@3 = Compiled_pairs,
gleam@list:flat_map(
_pipe@3,
fun(Pair) -> erlang:element(1, Pair) end
)
end,
Vendor_lookup = begin
_pipe@4 = Compiled_pairs,
_pipe@5 = gleam@list:flat_map(
_pipe@4,
fun(Pair@1) ->
{Raw_bps@1, V} = Pair@1,
gleam@list:map(
Raw_bps@1,
fun(Bp) -> {erlang:element(2, Bp), V} end
)
end
),
maps:from_list(_pipe@5)
end,
gleam@result:'try'(
caffeine_lang@linker@measurements:validate_measurements(
All_raw_measurements,
Slo_params
),
fun(Validated_measurements) ->
gleam@result:'try'(
parse_expectation_sources(
Expectation_sources,
Validated_measurements,
Slo_params
),
fun(Expectations_with_paths) ->
caffeine_lang@linker@ir_builder:build_all(
Expectations_with_paths,
Reserved_labels,
Vendor_lookup,
Slo_params
)
end
)
end
)
end
).