createObject() public static method

public static createObject ( IoSeq symbol ) : IoSeq
symbol IoSeq
return IoSeq
示例#1
0
        public static IoObject slotCode(IoObject target, IoObject locals, IoObject m)
        {
            string  s    = "";
            IoBlock self = target as IoBlock;

            if (self.scope != null)
            {
                s += "block(";
            }
            else
            {
                s += "method(";
            }
            int nargs = self.argNames.Count;

            for (int i = 0; i < nargs; i++)
            {
                IoSeq name = self.argNames[i] as IoSeq;
                s += name.value + ", ";
            }

            IoMessage msg = self.containedMessage;
            IoSeq     seq = IoMessage.slotCode(msg, locals, m) as IoSeq;

            s += seq.value + ")";

            return(IoSeq.createObject(target.state, s));
        }
示例#2
0
文件: IoMessage.cs 项目: ypyf/io
        public static IoObject slotCode(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage self = target as IoMessage;
            string    s    = "";

            s = self.descriptionToFollow(true);
            return(IoSeq.createObject(self.state, s));
        }
示例#3
0
 public static IoSeq createSymbolInMachine(IoState state, string symbol)
 {
     if (state.symbols[symbol] == null)
     {
         state.symbols[symbol] = IoSeq.createObject(state, symbol);
     }
     return(state.symbols[symbol] as IoSeq);
 }
示例#4
0
 public static IoSeq createSymbolInMachine(IoState state, string symbol)
 {
     if (!state.symbols.ContainsKey(symbol))
     {
         state.symbols[symbol] = IoSeq.createObject(state, symbol);
     }
     return(state.symbols[symbol]);
 }
示例#5
0
        public static IoObject slotAt(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m   = message as IoMessage;
            IoSeq     o   = target as IoSeq;
            IoSeq     res = IoSeq.createObject(target.state);
            IoNumber  arg = m.localsNumberArgAt(locals, 0);

            res.value += o.value.Substring(arg.asInt(), 1);
            return(res);
        }
示例#6
0
        public static IoObject slotReverse(IoObject target, IoObject locals, IoObject message)
        {
            IoMessage m   = message as IoMessage;
            IoSeq     o   = target as IoSeq;
            IoSeq     res = IoSeq.createObject(target.state);

            char[] A = o.asCharArray;
            Array.Reverse(A);
            res.value = new string(A);
            return(res);
        }
示例#7
0
        public static IoSeq rawAsUnquotedSymbol(IoSeq 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(IoSeq.createObject(s.state, str));
        }
示例#8
0
        public static IoSeq rawAsUnescapedSymbol(IoSeq 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(IoSeq.createObject(s.state, str));
        }
示例#9
0
文件: IoMessage.cs 项目: ypyf/io
        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;
        }
示例#10
0
 public static IoObject slotType(IoObject target, IoObject locals, IoObject message)
 {
     return(IoSeq.createObject(target.state, target.name));
 }