예제 #1
0
파일: Call.cs 프로젝트: rquackenbush/EVM
        public byte[] GenerateInstruction(FinalAssembleContext context)
        {
            var labelName = LabelNameGetter.GetLabelName(context.ParsedInstruction.Arguments[0]);

            if (string.IsNullOrWhiteSpace(labelName))
            {
                context.Messages.Add(new AssemblerMessage(ErrorLevel.Error,
                                    string.Format("Invalid label argument - argument 1"),
                                    context.ParsedInstruction.SourceLine.LineNumber));

                return null;
            }

            //Attempt to get the address
            byte? address = context.GetLabelAddress(labelName);

            if (address == null)
            {
                context.Messages.Add(new AssemblerMessage(ErrorLevel.Error,
                    string.Format("Unable to find label '{0}'", labelName),
                    context.ParsedInstruction.SourceLine.LineNumber));

                return null;
            }

            return new[] { address.Value };
        }
예제 #2
0
파일: Push1.cs 프로젝트: rquackenbush/EVM
        public byte[] GenerateInstruction(FinalAssembleContext context)
        {
            byte value;

            if (!byte.TryParse(context.ParsedInstruction.Arguments[0], out value))
            {
                context.Messages.Add(new AssemblerMessage(ErrorLevel.Error,
                    string.Format("Unable to parse argument 1"),
                    context.ParsedInstruction.SourceLine.LineNumber));
                return null;
            }

            return new[] {value};
        }