createSymbolInMachine() public static méthode

public static createSymbolInMachine ( IoState state, string symbol ) : IoSeq
state IoState
symbol string
Résultat IoSeq
Exemple #1
0
        void parseName(IoState state, IoLexer lexer)
        {
            IoToken token = lexer.pop();

            messageName = IoSeq.createSymbolInMachine(state, token.name);
            ifPossibleCacheToken(token);
            //rawSetLineNumber(token.lineNumber);
            //rawSetCharNumber(token.charNumber);
        }
Exemple #2
0
        void ifPossibleCacheToken(IoToken token)
        {
            IoSeq    method = this.messageName;
            IoObject r      = null;

            switch (token.type)
            {
            case IoTokenType.TRIQUOTE_TOKEN:
                break;

            case IoTokenType.MONOQUOTE_TOKEN:
                r = IoSeq.createSymbolInMachine(
                    method.state,
                    IoSeq.rawAsUnescapedSymbol(
                        IoSeq.rawAsUnquotedSymbol(
                            IoSeq.createObject(method.state, method.value)
                            )
                        ).value
                    );
                break;

            case IoTokenType.NUMBER_TOKEN:
                r = IoNumber.newWithDouble(this.state, Convert.ToDouble(method.value, CultureInfo.InvariantCulture));
                break;

            default:
                if (method.value.Equals("nil"))
                {
                    r = state.ioNil;
                }
                else if (method.value.Equals("true"))
                {
                    r = state.ioTrue;
                }
                else if (method.value.Equals("false"))
                {
                    r = state.ioFalse;
                }
                break;
            }
            this.cachedResult = r;
        }
Exemple #3
0
        IoMessage newParse(IoState state, IoLexer lexer)
        {
            if (lexer.errorToken != null)
            {
            }

            if (lexer.topType() == IoTokenType.TERMINATOR_TOKEN)
            {
                lexer.pop();
            }

            if (lexer.top() != null && lexer.top().isValidMessageName())
            {
                IoMessage self = newParseNextMessageChain(state, lexer);
                if (lexer.topType() != IoTokenType.NO_TOKEN)
                {
                    state.error(self, "compile error: %s", "unused tokens");
                }
                return(self);
            }

            return(newWithNameReturnsValue(state, IoSeq.createSymbolInMachine(state, "nil"), state.ioNil));
        }
Exemple #4
0
        public override IoObject proto(IoState state)
        {
            IoMessage pro = new IoMessage();

            pro.state = state;
            //  pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            //pro.tag.activateFunc = new IoTagActivateFunc(this.activate);
            pro.createSlots();
            pro.createProtos();
            pro.uniqueId    = 0;
            pro.messageName = IoSeq.createSymbolInMachine(state, "anonymous");
            pro.label       = IoSeq.createSymbolInMachine(state, "unlabeled");
            pro.args        = new List <IoMessage>();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("name", new IoMethodFunc(IoMessage.slotName)),
                new IoCFunction("setName", new IoMethodFunc(IoMessage.slotSetName)),
                new IoCFunction("next", new IoMethodFunc(IoMessage.slotNext)),
                new IoCFunction("setNext", new IoMethodFunc(IoMessage.slotSetNext)),
                new IoCFunction("code", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("arguments", new IoMethodFunc(IoMessage.slotArguments)),
                new IoCFunction("appendArg", new IoMethodFunc(IoMessage.slotAppendArg)),
                new IoCFunction("argAt", new IoMethodFunc(IoMessage.slotArgAt)),
                new IoCFunction("argCount", new IoMethodFunc(IoMessage.slotArgCount)),
                new IoCFunction("asString", new IoMethodFunc(IoMessage.slotCode)),
                new IoCFunction("cachedResult", new IoMethodFunc(IoMessage.slotCachedResult)),
                new IoCFunction("setCachedResult", new IoMethodFunc(IoMessage.slotSetCachedResult)),
                new IoCFunction("removeCachedResult", new IoMethodFunc(IoMessage.slotRemoveCachedResult)),
                new IoCFunction("hasCachedResult", new IoMethodFunc(IoMessage.slotHasCachedResult)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return(pro);
        }
Exemple #5
0
 public IoSeq IOSYMBOL(string name)
 {
     return(IoSeq.createSymbolInMachine(this, name));
 }
Exemple #6
0
        public IoMessage newFromTextLabel(IoState state, string code, string label)
        {
            IoSeq labelSymbol = IoSeq.createSymbolInMachine(state, label);

            return(newFromTextLabelSymbol(state, code, labelSymbol));
        }