Example #1
0
        protected override void EmitGetCode(CompilerTarget target, StackSemantics stackSemantics)
        {
            var constType = TypeExpr as AstConstantTypeExpression;

            var justEffect = stackSemantics == StackSemantics.Effect;
            if (constType != null)
            {
                EmitArguments(target);
                target.EmitStaticGetCall(Position, Arguments.Count, constType.TypeExpression, _memberId, justEffect);
            }
            else
            {
                TypeExpr.EmitValueCode(target);
                target.EmitConstant(Position, _memberId);
                EmitArguments(target);
                target.EmitGetCall(Position, Arguments.Count + 1, PType.StaticCallFromStackId, justEffect);
            }
        }
Example #2
0
        protected override void DoEmitCode(CompilerTarget target, StackSemantics stackSemantics)
        {
            if (Elements.Count == 0)
            {
                target.Emit(Position,OpCode.newobj, 0, "Hash");
            }
            else
            {
                foreach (var element in Elements)
                {
                    if (element is AstConstant)
                        throw new PrexoniteException(
                            String.Concat(
                                "Hashes are built from key-value pairs, not constants like ",
                                element,
                                ". [File: ",
                                File,
                                ", Line: ",
                                Line,
                                "]"));
                    element.EmitCode(target,stackSemantics);
                }

                if(stackSemantics == StackSemantics.Effect)
                    return;

                target.EmitStaticGetCall(Position, Elements.Count, "Hash", "Create", false);
            }
        }