public void Memory(char action, string targetName, int paramCount) { //TODO: indexing uint crush; switch (action) { case 's' when paramCount > 1: //set indexed _opcodes.Add(NanTags.EncodeVariableRef(targetName, out crush)); AddSymbol(crush, targetName); _opcodes.Add(NanTags.EncodeOpcode('m', 'S', (ushort)paramCount, 0)); break; case 'g' when paramCount > 0: // get indexed _opcodes.Add(NanTags.EncodeVariableRef(targetName, out crush)); AddSymbol(crush, targetName); _opcodes.Add(NanTags.EncodeOpcode('m', 'G', (ushort)paramCount, 0)); break; default: NanTags.EncodeVariableRef(targetName, out crush); AddSymbol(crush, targetName); _opcodes.Add(NanTags.EncodeLongOpcode('m', action, crush)); break; } }
/// <summary> /// Add a define-and-skip set of opcodes *before* merging in the compiled function opcodes. /// </summary> public void FunctionDefine(string functionName, int argCount, uint tokenCount) { _opcodes.Add(NanTags.EncodeVariableRef(functionName, out var crushed)); AddSymbol(crushed, functionName); _opcodes.Add(NanTags.EncodeOpcode('f', 'd', (ushort)argCount, (ushort)tokenCount)); }
public void FunctionCall(string functionName, int parameterCount) { _opcodes.Add(NanTags.EncodeVariableRef(functionName, out _)); _opcodes.Add(NanTags.EncodeOpcode('f', 'c', (ushort)parameterCount, 0)); }
public void Increment(sbyte incr, string targetName) { NanTags.EncodeVariableRef(targetName, out var crush); AddSymbol(crush, targetName); _opcodes.Add(NanTags.EncodeLongOpcode('i', (char)incr, crush)); }
/// <summary> /// Reference a value name /// </summary> public void VariableReference(string valueName) { _opcodes.Add(NanTags.EncodeVariableRef(valueName, out var crushed)); AddSymbol(crushed, valueName); }