Skip to content

Commit

Permalink
Introduce with() APIs mirroring from() for generality
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-kim1 committed Jan 2, 2025
1 parent e3cbb3b commit 2398fd3
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,13 @@ private void registerTDS()
)
);

register(
m(
m(h("meta::pure::mapping::with_T_m__Runtime_1__T_m_", false, ps -> res(ps.get(0)._genericType(), ps.get(0)._multiplicity()), ps -> ps.size() == 2 && typeOne(ps.get(1), Sets.immutable.with("Runtime", "EngineRuntime", "PackageableRuntime")))),
m(h("meta::pure::mapping::with_T_m__Mapping_1__Runtime_1__T_m_", false, ps -> res(ps.get(0)._genericType(), ps.get(0)._multiplicity()), ps -> ps.size() == 3))
)
);

register(m(grp(LambdaCollectionInference, h("meta::pure::tds::tdsContains_T_1__Function_MANY__TabularDataSet_1__Boolean_1_", false, ps -> res("Boolean", "one"), ps -> ps.size() == 3)),
grp(TDSContainsInference, h("meta::pure::tds::tdsContains_T_1__Function_MANY__String_MANY__TabularDataSet_1__Function_1__Boolean_1_", false, ps -> res("Boolean", "one"), ps -> true))));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,16 @@ function <<functionType.NotImplementedFunction>> meta::pure::mapping::from(tds:T
$tds;
}

function meta::pure::mapping::with<T|m>(t:T[m], runtime:Runtime[1]):T[m]
{
$t->from($runtime);
}

function meta::pure::mapping::with<T|m>(t:T[m], m:meta::pure::mapping::Mapping[1], runtime:Runtime[1]):T[m]
{
$t->from($m, $runtime);
}


###Mapping
Mapping meta::pure::mapping::MergedMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ function <<access.private>> meta::pure::router::store::routing::wrapValueSpecifi
function meta::pure::router::store::routing::specializedFunctionExpressionRouterProcessorForStore(extensions:meta::pure::extension::Extension[*]):Pair<Function<{FunctionExpression[1]->Boolean[1]}>, Function<{Function<Any>[1], FunctionExpression[1], RoutingState[1], meta::pure::runtime::ExecutionContext[1], Map<VariableExpression, ValueSpecification>[1], Map<String, List<Any>>[1], meta::pure::extension::Extension[*], DebugContext[1]->RoutingState[1]}>>[*]
{
[
pair(fe:FunctionExpression[1] | $fe.func->in([meta::pure::mapping::from_T_m__Runtime_1__T_m_]),
pair(fe:FunctionExpression[1] | $fe.func->in([meta::pure::mapping::from_T_m__Runtime_1__T_m_,
meta::pure::mapping::with_T_m__Runtime_1__T_m_]),
{f:Function<Any>[1], fe:FunctionExpression[1], state:RoutingState[1], executionContext:meta::pure::runtime::ExecutionContext[1], vars:Map<VariableExpression, ValueSpecification>[1], inScopeVars:Map<String, List<Any>>[1], extensions:meta::pure::extension::Extension[*], debug:DebugContext[1] |
let resolvedParameters = $fe.parametersValues->tail()->map(p|$p->evaluateAndDeactivate()->match([v:VariableExpression[1] |let iv = meta::pure::functions::meta::resolve($v, $vars, $inScopeVars)->cast(@InstanceValue).values,
f:FunctionExpression[1] |let r = $f->meta::pure::router::preeval::preval($inScopeVars, $extensions, $debug);
Expand All @@ -358,7 +359,8 @@ function meta::pure::router::store::routing::specializedFunctionExpressionRoute
),
pair(fe:FunctionExpression[1] | $fe.func->in([meta::pure::mapping::from_TabularDataSet_1__Mapping_1__Runtime_1__TabularDataSet_1_,
meta::pure::mapping::from_TabularDataSet_1__Mapping_1__Runtime_1__ExecutionContext_1__TabularDataSet_1_,
meta::pure::mapping::from_T_m__Mapping_1__Runtime_1__T_m_]),
meta::pure::mapping::from_T_m__Mapping_1__Runtime_1__T_m_,
meta::pure::mapping::with_T_m__Mapping_1__Runtime_1__T_m_]),
{f:Function<Any>[1], fe:FunctionExpression[1], state:RoutingState[1], executionContext:meta::pure::runtime::ExecutionContext[1], vars:Map<VariableExpression, ValueSpecification>[1], inScopeVars:Map<String, List<Any>>[1], extensions:meta::pure::extension::Extension[*], debug:DebugContext[1] |
let resolvedParameters = $fe.parametersValues->tail()->map(p|$p->evaluateAndDeactivate()->match([v:VariableExpression[1] |let iv = meta::pure::functions::meta::resolve($v, $vars, $inScopeVars)->cast(@InstanceValue).values,
f:FunctionExpression[1] |let r = $f->meta::pure::router::preeval::preval($inScopeVars, $extensions, $debug);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ function meta::relational::tests::pct::process::reprocess(f:Function<Any>[1], db
expressionSequence = ^SimpleFunctionExpression
(
importGroup=system::imports::coreImport,
func = if($reprocessed.mapping->isEmpty(),|from_T_m__Runtime_1__T_m_,|from_T_m__Mapping_1__Runtime_1__T_m_),
functionName = 'from',
func = if($reprocessed.mapping->isEmpty(),|with_T_m__Runtime_1__T_m_,|with_T_m__Mapping_1__Runtime_1__T_m_),
functionName = 'with',
genericType = $returnGenericType,
multiplicity = $returnMultiplicity,
parametersValues = $reprocessed.current->toOne()->cast(@ValueSpecification)
Expand Down
Loading

0 comments on commit 2398fd3

Please sign in to comment.