MCPcopy Create free account
hub / github.com/aiscript-dev/aiscript / add

Method add

src/interpreter/scope.ts:116–127  ·  view source on GitHub ↗
(name: string, variable: Variable)

Source from the content-addressed store, hash-verified

114 */
115 @autobind
116 public add(name: string, variable: Variable): void {
117 this.log('add', { var: name, val: variable });
118 const states = this.layerdStates[0]!;
119 if (states.has(name)) {
120 throw new AiScriptRuntimeError(
121 `Variable '${name}' already exists in scope '${this.name}'`,
122 { scope: this.layerdStates });
123 }
124 states.set(name, variable);
125 if (this.parent == null) this.onUpdated(name, variable.value);
126 else if (this.nsName != null) this.parent.add(this.nsName + ':' + name, variable);
127 }
128
129 /**
130 * 指定した名前の変数に値を再代入します

Callers 3

defineMethod · 0.80
reprValueFunction · 0.80
validateTypeParamsFunction · 0.80

Calls 3

logMethod · 0.95
onUpdatedMethod · 0.95
setMethod · 0.65

Tested by

no test coverage detected