UNPKG

@powerlang/egg-js

Version:

A Smalltalk VM that runs on top of JavaScript

144 lines (118 loc) 2.42 kB
import SExpression from './SExpression.js'; let SMessage = class extends SExpression { constructor() { super(); this._selector = nil; this._receiver = nil; this.__arguments = nil; this._cache = nil; this._inlined = nil; } static decodeUsing_(aTreecodeDecoder) { return aTreecodeDecoder.decodeMessage(); } static new() { return this.basicNew().initialize(); } acceptVisitor_(visitor) { return visitor.visitMessage_(this); } argumentCount() { return this.__arguments.size(); } arguments() { return this.__arguments; } arguments_(aCollection) { this.__arguments = aCollection; return this; } cache_when_(anSCompiledMethod, type) { if (nil === this._cache) { return this._cache = Array.with_with_(type, anSCompiledMethod) } ; this._cache = this._cache._comma(Array.with_with_(type, anSCompiledMethod)); return this; } cacheUndermessage_(aBlockClosure) { this._cache = aBlockClosure; return this; } cachedUndermessage() { let _retval; _retval = nil; if (this._cache.isBlock()) { _retval = this._cache } ; return _retval; } flushCache() { this._cache = nil; return this; } initialize() { super.initialize(); this.__arguments = []; this._inlined = false; return this; } inlined_(aBoolean) { this._inlined = aBoolean; return this; } isInlined() { return this._inlined; } isMessage() { return true; } methodFor_(requiredType) { let type, _retval; const _home = {}; try { if (nil === this._cache) { return nil } ; (1).to_by_do_(this._cache.size(), 2, (i) => { type = this._cache.at_(i); _retval = nil; if (type._equalEqual(requiredType)) { throw [_home, this._cache.at_((i+1))] } ; return _retval }); return nil; } catch(e) { if (e[0] == _home) return e[1]; else throw(e); } } receiver() { return this._receiver; } receiver_(anSExpression) { this._receiver = anSExpression; return this; } registerCacheWith_(runtime) { if (nil === this._cache) { runtime.registerCache_for_(this, this._selector) } ; return this; } selector() { return this._selector; } selector_(aSelector) { this._selector = aSelector; return this; } } export default SMessage