private void SolveStrLiteral() { TypeRef = Context.RefOf(Context.NeedStringDomain(StrData)); }
public static PasRef RefOf(PasRef declRef) { return new PasRef { Decl = declRef != null ? declRef.Decl : null, Name = declRef != null ? declRef.Name : null }; }
private void SolveOperation() { switch (Operator) { case PasValueOperator.None: break; case PasValueOperator.Positive: TypeRef = Context.RefOf(Context.NeedSignedDomain(Args[0].TypeRef.Decl as PasTypeDecl)); break; case PasValueOperator.Negative: TypeRef = Args[0].TypeRef != null ? Context.RefOf(Context.NeedSignedDomain(Args[0].TypeRef.Decl as PasTypeDecl)) : null; break; case PasValueOperator.NotMask: TypeRef = Context.RefOf(Args[0].TypeRef); break; case PasValueOperator.AndMask: TypeRef = Context.RefOf(Context.NeedCommonDomain(Args)); break; case PasValueOperator.OrMask: TypeRef = Context.RefOf(Context.NeedCommonDomain(Args)); break; case PasValueOperator.XorMask: TypeRef = Context.RefOf(Context.NeedCommonDomain(Args)); break; case PasValueOperator.Concat: TypeRef = Context.RefOf(Context.NeedStringDomain()); break; case PasValueOperator.Sum: TypeRef = Context.RefOf(Context.NeedCommonDomainUp(Args)); break; case PasValueOperator.Subtract: TypeRef = Context.RefOf(Context.NeedCommonDomainUp(Args)); break; case PasValueOperator.Multiply: TypeRef = Context.RefOf(Context.NeedCommonDomainUp(Args)); break; case PasValueOperator.Divide: TypeRef = Context.RefOf(Context.NeedFloatDomain()); break; case PasValueOperator.IntDiv: TypeRef = Context.RefOf(Context.NeedIntDomain()); break; case PasValueOperator.Remainder: //DomainRef = NeedCommonDomain(Args); break; case PasValueOperator.ShiftLeft: break; case PasValueOperator.ShiftRight: break; case PasValueOperator.Equal: break; case PasValueOperator.Inequal: break; case PasValueOperator.Less: break; case PasValueOperator.Greater: break; case PasValueOperator.NonLess: break; case PasValueOperator.NonGreater: break; case PasValueOperator.Not: break; case PasValueOperator.And: break; case PasValueOperator.Or: break; case PasValueOperator.Xor: break; case PasValueOperator.Interval: break; case PasValueOperator.Union: break; case PasValueOperator.Intersection: break; case PasValueOperator.Diference: break; case PasValueOperator.Belongs: break; case PasValueOperator.CastAs: break; case PasValueOperator.InstanceOf: break; case PasValueOperator.AddressOf: break; default: throw new Exception("invalid operator " + Operator.ToString()); } }
private void SolveParenthesis() { if (Args.Count == 1) TypeRef = Context.RefOf(Args[0].TypeRef); else throw new Exception("invalid parenthesis expression"); }
private void SolveIntLiteral() { TypeRef = Context.RefOf(Context.NeedIntDomain(IntData)); }
private void SolveName() { DeclRef = Context.RefOf(Context.Find(StrData)); if (DeclRef != null && DeclRef.Decl != null) TypeRef = Context.RefOf(DeclRef.Decl.GetDomain()); }
private void SolveBrackets() { TypeRef = Context.RefOf(Context.NeedArrayDomain(Args)); }
private void SolveFloatLiteral() { TypeRef = Context.RefOf(Context.NeedFloatDomain(FloatData)); }
public void Solve() { Context.Solve(Args); if (Prior == null) switch (Kind) { case PasValueKind.Parenthesis: SolveParenthesis(); break; case PasValueKind.Brackets: SolveBrackets(); break; case PasValueKind.IntLiteral: case PasValueKind.HexLiteral: SolveIntLiteral(); break; case PasValueKind.StrLiteral: SolveStrLiteral(); break; case PasValueKind.FloatLiteral: SolveFloatLiteral(); break; case PasValueKind.Name: SolveName(); break; case PasValueKind.Operation: SolveOperation(); break; case PasValueKind.Params: SolveParams(); break; case PasValueKind.Symbol: SolveSymbol(); break; case PasValueKind.DataAt: SolveDataAt(); break; case PasValueKind.Interval: SolveInterval(); break; default: throw new Exception("unsolvable value kind " + Kind.ToString()); } else { Context.Solve(Prior); switch (Kind) { case PasValueKind.Name: { if (Prior.TypeRef != null) { var found = Prior.TypeRef.DotFind(StrData); if (found != null) TypeRef = Context.RefOf(found.GetDomain()); } break; } ///default: throw new Exception("invalid member kind " + Kind.ToString()); } } }
public void Add(CsRef toSolve, PasRef toFollow) { _pendings.Add(new Pending { ToSolve = toSolve, ToFollow = toFollow }); }
string CsTypeNameOf(PasRef pasTypeRef) { if (pasTypeRef == null) return null; if (pasTypeRef.Decl != null) return CsTypeNameOf(pasTypeRef.Decl as PasTypeDecl); return CsTypeNameOf(pasTypeRef.Name); }
CsRef CsRefOf(PasRef pasDeclRef) { if (pasDeclRef == null || pasDeclRef.Decl == null) return null; var csDeclRef = new CsRef(); _pendings.Add(csDeclRef, pasDeclRef); return csDeclRef; }
CsRef ConvertPasTypeRef(PasRef pasTypeRef) { if (pasTypeRef == null) return null; if (pasTypeRef.Decl is PasStringTypeDecl) return CsAliasType("String"); if (pasTypeRef.Decl is PasAliasTypeDecl) { var pat = pasTypeRef.Decl as PasAliasTypeDecl; string eqv; if (typeTable.TryGetValue(pat.TargetType.Name.ToLower(), out eqv)) return CsAliasType(eqv); else return CsAliasType(pat.TargetType.Name); } return CsRefOf(pasTypeRef); }