AssignmentExpression.js — svelte Source File
Architecture documentation for AssignmentExpression.js, a javascript file in the svelte codebase. 17 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 96ee438d_6c6f_9aff_59f4_d00e63e9d98c["AssignmentExpression.js"] 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c a3992cec_6c90_d564_7bfc_3ad8518003cc["build_assignment_value"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> a3992cec_6c90_d564_7bfc_3ad8518003cc a997caf9_1d66_f005_5b11_675724bd0ed8["get_attribute_expression"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> a997caf9_1d66_f005_5b11_675724bd0ed8 e9a2c29e_d0ca_ab9f_b86f_f22ff802db91["is_event_attribute"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> e9a2c29e_d0ca_ab9f_b86f_f22ff802db91 62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6 bde97aff_493a_f552_a038_3e029fefca90["locate_node"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> bde97aff_493a_f552_a038_3e029fefca90 c518b20b_2355_7b11_4ac2_2d9bb5dcfb43["utils.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> c518b20b_2355_7b11_4ac2_2d9bb5dcfb43 88db3726_5740_3eb8_99fb_4b297fb19b24["should_proxy"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> 88db3726_5740_3eb8_99fb_4b297fb19b24 47b19192_eefb_9217_3996_3a0f4e07c6ed["assignments.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> 47b19192_eefb_9217_3996_3a0f4e07c6ed 3f298b15_f3b3_11d6_21ea_d35e2d476f80["visit_assignment_expression"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> 3f298b15_f3b3_11d6_21ea_d35e2d476f80 d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> d04d7971_88df_542d_dd4f_26170ce6f581 dcd117e6_7004_e4da_f4a2_f82f6e43060c["validate_mutation"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> dcd117e6_7004_e4da_f4a2_f82f6e43060c ee93d8a6_6fde_b1c1_e15b_3a4da5326305["scope.js"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> ee93d8a6_6fde_b1c1_e15b_3a4da5326305 bed91719_d047_2256_e199_ee875d5f49b9["get_rune"] 96ee438d_6c6f_9aff_59f4_d00e63e9d98c --> bed91719_d047_2256_e199_ee875d5f49b9 style 96ee438d_6c6f_9aff_59f4_d00e63e9d98c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { Context } from '../types.js' */
import * as b from '#compiler/builders';
import {
build_assignment_value,
get_attribute_expression,
is_event_attribute
} from '../../../../utils/ast.js';
import { dev, locate_node } from '../../../../state.js';
import { should_proxy } from '../utils.js';
import { visit_assignment_expression } from '../../shared/assignments.js';
import { validate_mutation } from './shared/utils.js';
import { get_rune } from '../../../scope.js';
import { get_name } from '../../../nodes.js';
/**
* @param {AssignmentExpression} node
* @param {Context} context
*/
export function AssignmentExpression(node, context) {
const expression = /** @type {Expression} */ (
visit_assignment_expression(node, context, build_assignment) ?? context.next()
);
return validate_mutation(node, context, expression);
}
/**
* Determines whether the value will be coerced on assignment (as with e.g. `+=`).
* If not, we may need to proxify the value, or warn that the value will not be
* proxified in time
* @param {AssignmentOperator} operator
*/
function is_non_coercive_operator(operator) {
return ['=', '||=', '&&=', '??='].includes(operator);
}
/** @type {Record<string, string>} */
const callees = {
'=': '$.assign',
'&&=': '$.assign_and',
'||=': '$.assign_or',
'??=': '$.assign_nullish'
};
/**
* @param {AssignmentOperator} operator
* @param {Pattern} left
* @param {Expression} right
* @param {Context} context
* @returns {Expression | null}
*/
function build_assignment(operator, left, right, context) {
if (context.state.analysis.runes && left.type === 'MemberExpression') {
const name = get_name(left.property);
const field = name && context.state.state_fields.get(name);
if (field) {
// special case — state declaration in class constructor
// ... (169 more lines)
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does AssignmentExpression.js do?
AssignmentExpression.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in AssignmentExpression.js?
AssignmentExpression.js defines 3 function(s): AssignmentExpression, build_assignment, is_non_coercive_operator.
What does AssignmentExpression.js depend on?
AssignmentExpression.js imports 17 module(s): assignments.js, ast.js, build_assignment_value, builders, get_attribute_expression, get_name, get_rune, is_event_attribute, and 9 more.
What files import AssignmentExpression.js?
AssignmentExpression.js is imported by 1 file(s): transform-client.js.
Where is AssignmentExpression.js in the architecture?
AssignmentExpression.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free