예제 #1
0
 public static IoString createObject(IoState state, string symbol)
 {
     IoString str = new IoString();
     str = str.clone(state) as IoString;
     str.value = symbol;
     return str;
 }
예제 #2
0
        public static IoString rawAsUnescapedSymbol(IoString s)
        {
            string str = "";
            int i = 0;
            while (i < s.value.Length)
            {
                char c = s.value[i];
                if (c != '\\')
                {
                    str += c;
                }
                else
                {
                    c = s.value[i];
                    switch (c)
                    {
                        case 'a': c = '\a'; break;
                        case 'b': c = '\b'; break;
                        case 'f': c = '\f'; break;
                        case 'n': c = '\n'; break;
                        case 'r': c = '\r'; break;
                        case 't': c = '\t'; break;
                        case 'v': c = '\v'; break;
                        case '\0': c = '\\'; break;
                        default:
                            if (c > '0' && c < '9')
                            {
                                c -= '0';
                            }
                            break;
                    }
                    str += c;
                }

                i++;
            }
            return IoString.createObject(s.state, str);
        }
예제 #3
0
 public static new IoString createProto(IoState state)
 {
     IoString s = new IoString();
     return s.proto(state) as IoString;
 }
예제 #4
0
        public override IoObject proto(IoState state)
        {
            IoString pro = new IoString();
            pro.state = state;
            //    pro.tag.cloneFunc = new IoTagCloneFunc(this.clone);
            //    pro.tag.compareFunc = new IoTagCompareFunc(this.compare);
            pro.createSlots();
            pro.createProtos();
            state.registerProtoWithFunc(name, new IoStateProto(name, pro, new IoStateProtoFunc(this.proto)));
            pro.protos.Add(state.protoWithInitFunc("Object"));

            IoCFunction[] methodTable = new IoCFunction[] {
                new IoCFunction("appendStr", new IoMethodFunc(IoString.slotAppendStr)),
                new IoCFunction("at", new IoMethodFunc(IoString.slotAt)),
                new IoCFunction("reverse", new IoMethodFunc(IoString.slotReverse)),
            };

            pro.addTaglessMethodTable(state, methodTable);
            return pro;
        }
예제 #5
0
 public static new IoString createObject(IoState state)
 {
     IoString s = new IoString();
     return s.clone(state) as IoString;
 }
예제 #6
0
 public static IoString rawAsUnquotedSymbol(IoString s)
 {
     string str = "";
     if (s.value.StartsWith("\"")) str = s.value.Substring(1, s.value.Length - 1);
     if (s.value.EndsWith("\"")) str = str.Substring(0,s.value.Length-2);
     return IoString.createObject(s.state, str);
 }
예제 #7
0
 public override IoObject clone(IoState state)
 {
     IoString proto = state.protoWithInitFunc(name) as IoString;
     IoString result = new IoString();
     result.state = state;
     result.value = proto.value;
     result.createProtos();
     result.createSlots();
     result.protos.Add(proto);
     return result;
 }
예제 #8
0
 public void setupSymbols()
 {
     activateSymbol = IOSYMBOL("activate");
     callSymbol = IOSYMBOL("call");
     forwardSymbol = IOSYMBOL("forward");
     noShufflingSymbol = IOSYMBOL("__noShuffling__");
     opShuffleSymbol = IOSYMBOL("opShuffle");
     semicolonSymbol = IOSYMBOL(";");
     selfSymbol = IOSYMBOL("self");
     setSlotSymbol = IOSYMBOL("setSlot");
     setSlotWithTypeSymbol = IOSYMBOL("setSlotWithType");
     stackSizeSymbol = IOSYMBOL("stackSize");
     typeSymbol = IOSYMBOL("type");
     updateSlotSymbol = IOSYMBOL("updateSlot");
 }
예제 #9
0
 // Message Public Raw Methods
 public static IoMessage newWithName(IoState state, IoString ioSymbol)
 {
     IoMessage msg = IoMessage.createObject(state);
     msg.messageName = ioSymbol;
     return msg;
 }
예제 #10
0
 void parseName(IoState state, IoLexer lexer)
 {
     IoToken token = lexer.pop();
     messageName = IoString.createSymbolInMachine(state, token.name);
     ifPossibleCacheToken(token);
     //rawSetLineNumber(token.lineNumber);
     //rawSetCharNumber(token.charNumber);
 }
예제 #11
0
 IoMessage newWithNameReturnsValue(IoState state, IoString symbol, IoObject v)
 {
     IoMessage self = clone(state) as IoMessage;
     self.messageName = symbol;
     self.cachedResult = v;
     return self;
 }
예제 #12
0
 IoMessage newFromTextLabelSymbol(IoState state, string code, IoString labelSymbol)
 {
     IoLexer lexer = new IoLexer();
     IoMessage msg = new IoMessage();
     msg = msg.clone(state) as IoMessage;
     lexer.s = code;
     lexer.lex();
     msg = this.newParse(state, lexer);
     msg.opShuffle();
     msg.label = labelSymbol;
     return msg;
 }