コード例 #1
0
ファイル: UserType.cs プロジェクト: LukaHorvat/Hype
 public UserType(CodeBlock propertyBlock)
     : base(ValueType.GetNewType())
 {
     PropertyBlock = propertyBlock;
     Type = ValueType.UserType;
 }
コード例 #2
0
ファイル: Expression.cs プロジェクト: LukaHorvat/Hype
        public void GenerateLookupCache(ExecutionNode node, Interpreter interpreter)
        {
            var items = node.InnerExpression;

            if (node.Cache == null)
            {
                node.Cache = new List<Reference>();
                for (int i = 0; i < items.Count; ++i) node.Cache.Add(null);
            }

            for (int i = 0; i < items.Count; ++i)
            {
                //Fixed references aren't meant to be modified.
                if (node.Cache[i] != null && node.Cache[i].Fixed) continue;

                var tok = items[i].OriginalToken;
                switch (tok.Type)
                {
                    case TokenType.Literal:
                        node.Cache[i] = new Reference(interpreter.ParseLiteral(tok.Content));
                        break;
                    case TokenType.Identifier:
                        node.Cache[i] = interpreter.CurrentScopeNode.Lookup(tok.Content);
                        break;
                    case TokenType.Group:
                        var exp = items[i] as Expression;
                        if (exp.OriginalToken.Content == "{")
                        {
                            var codeblock = new CodeBlock(exp);
                            node.Cache[i] = new Reference(codeblock);
                        }
                        else
                        {
                            exp.GenerateLookupCache(interpreter);
                            exp.FixAllReferences();
                            if (exp.OriginalToken.Content == "[")
                            {
                                node.Cache[i] = new ListCache(exp, interpreter);
                            }
                            else
                            {
                                node.Cache[i] = new ExpressionCache(exp, interpreter);
                            }
                        }
                        break;
                }

            }
        }