Skip to content

Instantly share code, notes, and snippets.

@ben221199
Last active August 1, 2025 17:57
Show Gist options
  • Save ben221199/e17745d14b661ae3e1e491190030acf6 to your computer and use it in GitHub Desktop.
Save ben221199/e17745d14b661ae3e1e491190030acf6 to your computer and use it in GitHub Desktop.
ECMAScript
/**
* @since ES5
*/
public class DeclarativeEnvironmentRecord extends EnvironmentRecord{
/**
* @since ES5
*/
public Object HasBinding(Object N){
Object envRec = this;
}
//TODO HasBinding
//TODO CreateMutableBinding
//TODO SetMutableBinding
//TODO GetBindingValue
//TODO DeleteBinding
//TODO ImplicitThisValue
//TODO CreateImmutableBinding
//TODO InitializeImmutableBinding
/**
* @deprecated ES6
* @since ES5
*/
@Override
public Object ImplicitThisValue(){
return ESUndefined.UNDEFINED;
}
}
/**
* @since ES5
*/
abstract class EnvironmentRecord{
/**
* @since ES5
*/
public abstract Object HasBinding(Object N);
/**
* @since ES5
*/
public abstract Object CreateMutableBinding(Object N,Object D);
/**
* @since ES6
*/
public abstract Object CreateImmutableBinding(Object N,Object S);
/**
* @since ES6
*/
public abstract Object InitializeBinding(Object N,Object V);
/**
* @since ES5
*/
public abstract Object SetMutableBinding(Object N,Object V,Object S);
/**
* @since ES5
*/
public abstract Object GetBindingValue(Object N,Object S);
/**
* @since ES5
*/
public abstract Object DeleteBinding(Object N);
/**
* @since ES6
*/
public abstract Object HasThisBinding();
/**
* @since ES6
*/
public abstract Object HasSuperBinding();
/**
* @since ES6
*/
public abstract Object WithBaseObject();
/**
* @deprecated ES6
* @since ES5
*/
public abstract Object ImplicitThisValue();
}
/**
* @since ES5
*/
public class ObjectEnvironmentRecord extends EnvironmentRecord{
public Object BindingObject;
/**
* Boolean. Old names: provideThis, withEnvironment
*/
public Object IsWithEnvironment;
@Override
public Object HasBinding(Object N){
Object envRec = this;
//TODO get bindings
return bindings.HasProperty(N);
}
@Override
public Object CreateMutableBinding(Object N,Object D){
Object envRec = this;
//TODO get bindings
assert bindings.HasProperty(N)==false;
Object configValue = D;
bindings.DefineOwnProperty(N,...,false);
}
//TODO CreateMutableBinding
//TODO SetMutableBinding
//TODO GetBindingValue
//TODO DeleteBinding
/**
* @deprecated ES6
* @since ES5
*/
@Override
public Object ImplicitThisValue(){
Object envRec = this;
if(envRec.IsWithEnvironment){
//TODO return binding object;
}
return ESUndefined.UNDEFINED;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment