Skip to content

Commit

Permalink
Remove inlined_ctx from compile_ast_fragment_to_ir.
Browse files Browse the repository at this point in the history
  • Loading branch information
dnwpark committed Sep 25, 2024
1 parent a35e431 commit 8af3eb0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 28 deletions.
11 changes: 2 additions & 9 deletions edb/edgeql/compiler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@
from edb.ir import ast as irast
from edb.ir import staeval as ireval

from . import context
from . import dispatch as dispatch_mod
from . import inference as inference_mod
from . import normalization as norm_mod
Expand Down Expand Up @@ -274,10 +273,7 @@ def compile_ast_to_ir(
debug.header('EdgeQL AST')
debug.dump(tree, schema=schema)

ctx = stmtctx_mod.init_context(
schema=schema,
options=options,
)
ctx = stmtctx_mod.init_context(schema=schema, options=options)

if isinstance(tree, qlast.Expr) and ctx.implicit_limit:
tree = qlast.SelectQuery(result=tree, implicit=True)
Expand Down Expand Up @@ -321,7 +317,6 @@ def compile_ast_fragment_to_ir(
schema: s_schema.Schema,
*,
options: Optional[CompilerOptions] = None,
inlining_context: Optional[context.ContextLevel] = None,
) -> irast.Statement:
"""Compile given EdgeQL AST fragment into EdgeDB IR.
Expand All @@ -347,9 +342,7 @@ def compile_ast_fragment_to_ir(
if options is None:
options = CompilerOptions()

ctx = stmtctx_mod.init_context(
schema=schema, options=options, inlining_context=inlining_context
)
ctx = stmtctx_mod.init_context(schema=schema, options=options)
ir_set = dispatch_mod.compile(tree, ctx=ctx)

result_type = ctx.env.set_types[ir_set]
Expand Down
7 changes: 2 additions & 5 deletions edb/edgeql/compiler/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,9 @@ def compile_FunctionCall(

# Compile default
assert isinstance(param, s_func.Parameter)
p_ir_default = param.get_ir_default(
schema=env.schema,
inlining_context=ctx,
)
p_ir_default = dispatch.compile(p_default.parse(), ctx=ctx)
inline_args[param_shortname] = (
p_ir_default.expr
p_ir_default
)

argument_inliner = ArgumentInliner(inline_args, ctx=ctx)
Expand Down
7 changes: 0 additions & 7 deletions edb/schema/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@
from edb.schema import schema as s_schema
from edb.schema import types as s_types

from edb.edgeql.compiler import context as qlcontext

from edb.ir import ast as irast_


Expand Down Expand Up @@ -216,7 +214,6 @@ def compiled(
find_extra_refs: Optional[
Callable[[irast_.Set], set[so.Object]]
] = None,
inlining_context: Optional[qlcontext.ContextLevel] = None,
) -> CompiledExpression:

from edb.ir import ast as irast_
Expand All @@ -227,7 +224,6 @@ def compiled(
self.parse(),
schema=schema,
options=options,
inlining_context=inlining_context,
)
else:
ql_expr = self.parse()
Expand All @@ -245,9 +241,6 @@ def compiled(

assert isinstance(ir, irast_.Statement)

if inlining_context:
inlining_context.env.schema = ir.schema

# XXX: ref stuff - why doesn't it go into the delta tree? - temporary??
srefs: set[so.Object] = {
ref for ref in ir.schema_refs if schema.has_object(ref.id)
Expand Down
8 changes: 1 addition & 7 deletions edb/schema/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,20 +431,14 @@ def get_parameter_name(self, schema: s_schema.Schema) -> str:
fullname = self.get_name(schema)
return self.paramname_from_fullname(fullname)

def get_ir_default(
self,
*,
schema: s_schema.Schema,
inlining_context: Optional[qlcontext.ContextLevel] = None,
) -> irast.Statement:
def get_ir_default(self, *, schema: s_schema.Schema) -> irast.Statement:
from edb.ir import utils as irutils

defexpr = self.get_default(schema)
assert defexpr is not None
defexpr = defexpr.compiled(
as_fragment=True,
schema=schema,
inlining_context=inlining_context,
)
ir = defexpr.irast
if not irutils.is_const(ir.expr):
Expand Down

0 comments on commit 8af3eb0

Please sign in to comment.